/[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 1243 by torben, Wed Mar 23 21:47:26 2011 UTC revision 1479 by torben, Thu May 26 18:55:45 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.bukkit.hoeruputils;  package dk.thoerup.bukkit.hoeruputils;
2    
3    import java.util.List;
4    
5  import org.bukkit.ChatColor;  import org.bukkit.ChatColor;
6  import org.bukkit.Server;  import org.bukkit.Server;
7  import org.bukkit.World;  import org.bukkit.World;
# Line 15  public class EternalDayCommand implement Line 17  public class EternalDayCommand implement
17                    
18          int taskId = -1;          int taskId = -1;
19                    
20          World world;              List<World> worlds;    
21          Server server;          Server server;
22          Plugin plugin;          Plugin plugin;
23                    
# Line 23  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                  world = server.getWorlds().get(0);                  worlds = server.getWorlds();
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) {
33                                    //debug
34                    System.out.println("world count " + worlds.size());
35                    for (World world : worlds) {
36                            System.out.println(" >" + world.getName() + " : " + world.getTime() );
37                    }
38                                    
39                  if (taskId == -1) {                  if (taskId == -1) {
40                          taskId = server.getScheduler().scheduleSyncRepeatingTask(plugin, new EternalDayRunner(), 2*20, 60*20);                          taskId = server.getScheduler().scheduleSyncRepeatingTask(plugin, new EternalDayRunner(), 2*20, 60*20);
# Line 48  public class EternalDayCommand implement Line 54  public class EternalDayCommand implement
54                  // 1000=1 hour, 0 is 06:00 so 12000 is 18:00                  // 1000=1 hour, 0 is 06:00 so 12000 is 18:00
55                  @Override                  @Override
56                  public void run() {                  public void run() {
57                          if (world.getTime() > 12000) {                          for(World world : worlds) {
58                                  world.setTime(0);                                  if (world.getTime() > 12000) {
59                                  server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, ChatColor.YELLOW + "Eternalday has extended the period of light once again!"));                                          world.setTime(0);
60                                            server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, ChatColor.YELLOW + "Eternalday has extended the period of light once again!"));
61                                    }                              
62                          }                          }
63                  }                  }
64                                    

Legend:
Removed from v.1243  
changed lines
  Added in v.1479

  ViewVC Help
Powered by ViewVC 1.1.20