Timing....

Discussion in 'Plugin Development' started by Marcohan, Jul 27, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Marcohan

    Code:
     
    package com.MarcoHan.startuhc;
    
    
    
    import org.bukkit.Bukkit;
    
    import org.bukkit.ChatColor;
    
    import org.bukkit.World;
    
    import org.bukkit.command.Command;
    
    import org.bukkit.command.CommandSender;
    
    import org.bukkit.entity.Entity;
    
    import org.bukkit.entity.Monster;
    
    import org.bukkit.entity.Player;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import org.bukkit.potion.PotionEffect;
    
    import org.bukkit.potion.PotionEffectType;
    
    
    
    public class Main extends JavaPlugin {
    
    
    public String prefix = ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + "Eureka" + ChatColor.DARK_GRAY + "]"
    
    + ChatColor.AQUA;
    
    
    @SuppressWarnings("deprecation")
    
    public boolean onCommand(final CommandSender sender, Command cmd, String Label, final String[] args) {
    
    if (args.length == 1){
    
    if(cmd.getName().equalsIgnoreCase("startuhc")){
    
            if (sender.hasPermission("start.startuhc")){
    
        Bukkit.broadcastMessage(prefix + " The Game Will be Starting Shortly");
    
        for (Player p : Bukkit.getServer().getOnlinePlayers()){
    
        p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 999999999, 3));
    
        p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 999999999, 3));
    
        p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 999999999, 3));
    
        p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999999, 3));
    
        p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999999, 3));
    
        }
    
        for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    
    p.setHealth(20);
    
    }
    
        Bukkit.broadcastMessage(ChatColor.GREEN + "Healed all players");
    
    for (Player p: Bukkit.getServer().getOnlinePlayers()) {
    
    p.setFoodLevel(20);
    
    }
    
    Bukkit.broadcastMessage(ChatColor.GREEN + "Fed all players");
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starting in 5...");
    
    }
    
    },20L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starting in 4...");
    
    }
    
    },40L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starting in 3...");
    
    }
    
    }, 60L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starting in 2...");
    
    }
    
    }, 80L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starting in 1...");
    
    }
    
    },100L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Game Starts Now!");
    
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    
    p.setHealth(20);
    
    }
    
    for (Player p: Bukkit.getServer().getOnlinePlayers()) {
    
    p.setFoodLevel(20);
    
    }
    
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
    
    p.removePotionEffect(PotionEffectType.BLINDNESS);
    
    p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
    
    p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
    
    p.removePotionEffect(PotionEffectType.INVISIBILITY);
    
    p.removePotionEffect(PotionEffectType.SLOW);
    
    }
    
    Bukkit.getWorld(args[0]).setTime(0);
    
    World world = getServer().getWorld(args[0]);
    
    for (Entity e : world.getEntities()) {
    
      if (e instanceof Monster) {
    
        e.remove();
    
      }
    
    }
    
    }
    
    }, 120L);
    
    sender.getServer().dispatchCommand(sender.getServer().getConsoleSender(), "timer 900 PvP In...");
    
    Bukkit.broadcastMessage(prefix + " PvP In 15 Minutes...");
    
    sender.getServer().dispatchCommand(sender.getServer().getConsoleSender(), "pvp global off");
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    sender.getServer().dispatchCommand(sender.getServer().getConsoleSender(), "timer 4200 Meetup in..");
    
    Bukkit.broadcastMessage(prefix + " PvP Enabled - Meetup in 70 Minutes!");
    
    sender.getServer().dispatchCommand(sender.getServer().getConsoleSender(), "pvp global on");
    
    }
    
    },4200L);
    
    this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
    
    public void run(){
    
    Bukkit.broadcastMessage(prefix + " Meetup is now!");
    
    }
    
    }, 5100L);
    
            }
    
    }
    
    }
    
    returnfalse;
    
    }
    
    
    
    }
    Trying to get this going where if you do /startuhc it will do a countdown waiting 1 second inbetween and then it will wait 15 minutes for the PvP Enabled Message and then 70 for the Meetup is now Message

    this is the console log

    Code:
    [19:13:10 INFO]: [Eureka] The Game Will be Starting Shortly
    
    [19:13:10 INFO]: Healed all players
    
    [19:13:10 INFO]: Fed all players
    
    [19:13:10 INFO]: Unknown command. Type "/help" for help.
    
    [19:13:10 INFO]: [Eureka] PvP In 15 Minutes...
    
    [19:13:10 INFO]: Unknown command. Type "/help" for help.
    
    [19:13:11 INFO]: [Eureka] Game Starting in 5...
    
    [19:13:12 INFO]: [Eureka] Game Starting in 4...
    
    [19:13:13 INFO]: [Eureka] Game Starting in 3...
    
    [19:13:14 INFO]: [Eureka] Game Starting in 2...
    
    [19:13:15 INFO]: [Eureka] Game Starting in 1...
    
    [19:13:16 INFO]: [Eureka] Game Starts Now!
    
    [19:16:47 INFO]: Unknown command. Type "/help" for help.
    
    [19:16:47 INFO]: [Eureka] PvP Enabled - Meetup in 70 Minutes!
    
    [19:16:47 INFO]: Unknown command. Type "/help" for help.
    
    [19:17:33 INFO]: [Eureka] Meetup is now!
    
    >
    as you can see the times are very short and not the correct times. What am i doing wrong?
     
  2. Offline

    MCMatters

    ((15 * 60) * 20) for pvp and ((70 * 60) * 20) for meetup
     
  3. Offline

    lilian58660

    20 ticks = 1 second
     
Thread Status:
Not open for further replies.

Share This Page