blob: 7c7e23075b4acbf73496dbd02a7b2969f54a0363 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package net.tylermurphy.hideAndSeek.util;
import static net.tylermurphy.hideAndSeek.Config.*;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import net.tylermurphy.hideAndSeek.Main;
public class Util {
public static void broadcastMessage(String message) {
for(Player player : Main.plugin.board.getPlayers()) {
player.sendMessage(message);
}
}
public static boolean isSetup() {
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) return false;
if(lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) return false;
if(exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) return false;
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(!destenation.exists()) return false;
return true;
}
public static void unloadMap(String mapname){
if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
Main.plugin.getLogger().info("Successfully unloaded " + mapname);
}else{
Main.plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
}
}
public static void loadMap(String mapname){
Bukkit.getServer().createWorld(new WorldCreator(mapname));
Bukkit.getServer().getWorld("hideandseek_"+spawnWorld).setAutoSave(false);
}
public static void rollback(String mapname){
unloadMap(mapname);
loadMap(mapname);
}
public static void sendDelayedMessage(String message, int gameId, int delay) {
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.plugin, new Runnable() {
public void run() {
if(gameId == Main.plugin.gameId)
Util.broadcastMessage(messagePrefix + "Hiders have 1 seconds to hide!");
}
}, delay);
}
}
|