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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1598 - (show annotations) (download)
Tue Sep 20 06:24:39 2011 UTC (12 years, 8 months ago) by torben
File size: 1620 byte(s)
eternal daylight messages should only be broadcast to the current world
1 package dk.thoerup.bukkit.hoeruputils;
2
3 import java.util.List;
4
5 import org.bukkit.ChatColor;
6 import org.bukkit.Server;
7 import org.bukkit.World;
8 import org.bukkit.command.Command;
9 import org.bukkit.command.CommandExecutor;
10 import org.bukkit.command.CommandSender;
11 import org.bukkit.plugin.Plugin;
12
13 import dk.thoerup.bukkit.hoeruputils.utils.MessageBroadcaster;
14
15 public class EternalDayCommand implements CommandExecutor {
16
17
18 int taskId = -1;
19
20 World world;
21 Server server;
22 Plugin plugin;
23
24 public EternalDayCommand(Plugin plugin) {
25
26 this.plugin = plugin;
27 server = plugin.getServer();
28 world = server.getWorld("world");
29 }
30
31 @Override
32 public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
33
34 if (taskId == -1) {
35 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");
37 } else {
38 server.getScheduler().cancelTask(taskId);
39 taskId = -1;
40 server.broadcastMessage(ChatColor.YELLOW + "Eternal day is disabled - watch out for zombies");
41 }
42
43 return true;
44 }
45
46 class EternalDayRunner implements Runnable {
47
48 // 1000=1 hour, 0 is 06:00 so 12000 is 18:00
49 @Override
50 public void run() {
51 if (world.getTime() > 12000) {
52 world.setTime(0);
53 String msg = ChatColor.YELLOW + "Eternalday has extended the period of light once again!";
54 //server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, msg));
55 Util.broadcastWorld(world, msg);
56 }
57 }
58
59 }
60
61 }

  ViewVC Help
Powered by ViewVC 1.1.20