2025-06-28 00:36:06 +03:00
|
|
|
package hdvtdev.blockAndSeek.managers;
|
|
|
|
|
|
|
|
|
|
import hdvtdev.blockAndSeek.BlockAndSeek;
|
|
|
|
|
import hdvtdev.blockAndSeek.BlockAndSeekGame;
|
|
|
|
|
import hdvtdev.blockAndSeek.BlockAndSeekMap;
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
import org.bukkit.WorldCreator;
|
2025-07-03 02:40:14 +03:00
|
|
|
import org.bukkit.entity.Player;
|
2025-06-28 00:36:06 +03:00
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
|
public class GamesManager {
|
|
|
|
|
|
|
|
|
|
private static final ConcurrentHashMap<String, BlockAndSeekGame> games = new ConcurrentHashMap<>();
|
2025-07-03 02:40:14 +03:00
|
|
|
private static final Set<Player> seekerImmune = ConcurrentHashMap.newKeySet();
|
2025-06-28 00:36:06 +03:00
|
|
|
|
2025-07-03 02:40:14 +03:00
|
|
|
public static boolean triggerSeekerImmune(Player player) {
|
|
|
|
|
return seekerImmune.remove(player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void addSeekerImmune(Player player) {
|
|
|
|
|
seekerImmune.add(player);
|
2025-06-28 00:36:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Set<String> getAvailableGames() {
|
|
|
|
|
return games.keySet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int createGame(String name) {
|
|
|
|
|
if (games.containsKey(name)) return 1;
|
|
|
|
|
|
|
|
|
|
if (Bukkit.getWorld(name) == null) {
|
|
|
|
|
if (new File(BlockAndSeek.getServerDataFolder(), name).exists()) {
|
|
|
|
|
Bukkit.createWorld(new WorldCreator(name));
|
|
|
|
|
} else return 2;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-01 03:25:09 +03:00
|
|
|
BlockAndSeekMap map = MapsManager.getMap(name);
|
2025-07-02 17:49:15 +03:00
|
|
|
BlockAndSeekGame game = new BlockAndSeekGame(name, map);
|
2025-06-28 00:36:06 +03:00
|
|
|
|
2025-07-02 17:49:15 +03:00
|
|
|
games.put(name, game);
|
2025-06-28 00:36:06 +03:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 17:49:15 +03:00
|
|
|
public static void remove(String name) {
|
|
|
|
|
games.remove(name);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-28 00:36:06 +03:00
|
|
|
public static BlockAndSeekGame get(String name) {
|
|
|
|
|
return games.get(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|