/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/EternalDayCommand.java
ViewVC logotype

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/EternalDayCommand.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1480 by torben, Thu May 26 18:57:50 2011 UTC revision 1598 by torben, Tue Sep 20 06:24:39 2011 UTC
# Line 17  public class EternalDayCommand implement Line 17  public class EternalDayCommand implement
17                    
18          int taskId = -1;          int taskId = -1;
19                    
20          List<World> worlds;              World world;    
21          Server server;          Server server;
22          Plugin plugin;          Plugin plugin;
23                    
# Line 25  public class EternalDayCommand implement Line 25  public class EternalDayCommand implement
25                                    
26                  this.plugin = plugin;                  this.plugin = plugin;
27                  server = plugin.getServer();                  server = plugin.getServer();
28                  worlds = server.getWorlds();                  world = server.getWorld("world");
29          }          }
30                    
31          @Override          @Override
32          public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {          public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
                 //debug  
                 System.out.println("world count " + worlds.size());  
33    
                   
34                  if (taskId == -1) {                  if (taskId == -1) {
35                          taskId = server.getScheduler().scheduleSyncRepeatingTask(plugin, new EternalDayRunner(), 2*20, 60*20);                          taskId = server.getScheduler().scheduleSyncRepeatingTask(plugin, new EternalDayRunner(), 2*20, 60*20);
36                          server.broadcastMessage(ChatColor.YELLOW + "Eternal day is enabled - have a nice long day");                          server.broadcastMessage(ChatColor.YELLOW + "Eternal day is enabled - have a nice long day");
# Line 43  public class EternalDayCommand implement Line 40  public class EternalDayCommand implement
40                          server.broadcastMessage(ChatColor.YELLOW + "Eternal day is disabled - watch out for zombies");                          server.broadcastMessage(ChatColor.YELLOW + "Eternal day is disabled - watch out for zombies");
41                  }                  }
42                                    
                   
43                  return true;                  return true;
44          }          }
45                    
# Line 52  public class EternalDayCommand implement Line 48  public class EternalDayCommand implement
48                  // 1000=1 hour, 0 is 06:00 so 12000 is 18:00                  // 1000=1 hour, 0 is 06:00 so 12000 is 18:00
49                  @Override                  @Override
50                  public void run() {                  public void run() {
51                          for(World world : worlds) {                          if (world.getTime() > 12000) {                                  
52                                  if (world.getTime() > 12000) {                                  world.setTime(0);
53                                          System.out.println(" >" + world.getName() + " : " + world.getTime() );                                  String msg = ChatColor.YELLOW + "Eternalday has extended the period of light once again!";              
54                                          world.setTime(0);                                  //server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, msg));
55                                          server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, ChatColor.YELLOW + "Eternalday has extended the period of light once again!"));                                  Util.broadcastWorld(world, msg);
56                                  }                                                        }                                                      
                         }  
57                  }                  }
58                                    
59          }          }

Legend:
Removed from v.1480  
changed lines
  Added in v.1598

  ViewVC Help
Powered by ViewVC 1.1.20