1 |
package dk.thoerup.bukkit.hoeruputils; |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
3 |
import java.util.List; |
import java.util.ArrayList; |
4 |
|
|
5 |
import org.bukkit.ChatColor; |
import org.bukkit.ChatColor; |
6 |
import org.bukkit.Server; |
import org.bukkit.Server; |
10 |
import org.bukkit.command.CommandSender; |
import org.bukkit.command.CommandSender; |
11 |
import org.bukkit.plugin.Plugin; |
import org.bukkit.plugin.Plugin; |
12 |
|
|
|
import dk.thoerup.bukkit.hoeruputils.utils.MessageBroadcaster; |
|
|
|
|
13 |
public class EternalDayCommand implements CommandExecutor { |
public class EternalDayCommand implements CommandExecutor { |
14 |
|
|
15 |
|
|
16 |
int taskId = -1; |
int taskId = -1; |
17 |
|
|
18 |
World world; |
ArrayList<World> worlds = new ArrayList<World>(); |
19 |
|
|
20 |
Server server; |
Server server; |
21 |
Plugin plugin; |
Plugin plugin; |
22 |
|
|
24 |
|
|
25 |
this.plugin = plugin; |
this.plugin = plugin; |
26 |
server = plugin.getServer(); |
server = plugin.getServer(); |
27 |
world = server.getWorld("world"); |
|
28 |
|
addWorld( server, "world" ); |
29 |
|
addWorld( server, "creative" ); |
30 |
|
} |
31 |
|
|
32 |
|
private void addWorld(Server server, String worldName) { |
33 |
|
World world = server.getWorld( worldName ); |
34 |
|
if (world != null) { |
35 |
|
worlds.add( world ); |
36 |
|
} |
37 |
} |
} |
38 |
|
|
39 |
@Override |
@Override |
56 |
// 1000=1 hour, 0 is 06:00 so 12000 is 18:00 |
// 1000=1 hour, 0 is 06:00 so 12000 is 18:00 |
57 |
@Override |
@Override |
58 |
public void run() { |
public void run() { |
59 |
if (world.getTime() > 12000) { |
|
60 |
world.setTime(0); |
for (World world : worlds) { |
61 |
server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, ChatColor.YELLOW + "Eternalday has extended the period of light once again!")); |
if (world.getTime() > 12000) { |
62 |
} |
world.setTime(0); |
63 |
|
String msg = ChatColor.YELLOW + "Eternalday has extended the period of light once again!"; |
64 |
|
//server.getScheduler().scheduleSyncDelayedTask(plugin, new MessageBroadcaster(server, msg)); |
65 |
|
Util.broadcastWorld(world, msg); |
66 |
|
} |
67 |
|
} |
68 |
} |
} |
69 |
|
|
70 |
} |
} |