From 1e7884748840a7bcc8377db960218f759d040e5e Mon Sep 17 00:00:00 2001 From: M_Viper Date: Sat, 20 Jun 2026 19:28:55 +0000 Subject: [PATCH] Delete src/main/java/de/lasertec/arena/ArenaManager.java via Git Manager GUI --- .../java/de/lasertec/arena/ArenaManager.java | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 src/main/java/de/lasertec/arena/ArenaManager.java diff --git a/src/main/java/de/lasertec/arena/ArenaManager.java b/src/main/java/de/lasertec/arena/ArenaManager.java deleted file mode 100644 index 03febf1..0000000 --- a/src/main/java/de/lasertec/arena/ArenaManager.java +++ /dev/null @@ -1,163 +0,0 @@ -package de.lasertec.arena; - -import de.lasertec.LasertecPlugin; -import de.lasertec.game.Team; -import org.bukkit.Location; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -public class ArenaManager { - - private final LasertecPlugin plugin; - private final Map arenas = new LinkedHashMap<>(); - private File file; - private FileConfiguration cfg; - - public ArenaManager(LasertecPlugin plugin) { - this.plugin = plugin; - load(); - } - - // ─── CRUD ──────────────────────────────────────────────────────────────── - - public Arena createArena(String name) { - String key = name.toLowerCase(); - if (arenas.containsKey(key)) return null; - Arena arena = new Arena(name); - arenas.put(key, arena); - save(); - return arena; - } - - public Arena getArena(String name) { - return arenas.get(name.toLowerCase()); - } - - public boolean deleteArena(String name) { - if (arenas.remove(name.toLowerCase()) == null) return false; - save(); - return true; - } - - public Collection getAll() { return Collections.unmodifiableCollection(arenas.values()); } - - public List getReady() { - List list = new ArrayList<>(); - for (Arena a : arenas.values()) - if (a.isReady() && a.isEnabled()) list.add(a); - return list; - } - - // ─── Persistence ───────────────────────────────────────────────────────── - - private void load() { - file = new File(plugin.getDataFolder(), "arenas.yml"); - if (!file.exists()) { - try { plugin.getDataFolder().mkdirs(); file.createNewFile(); } - catch (IOException ex) { ex.printStackTrace(); return; } - } - cfg = YamlConfiguration.loadConfiguration(file); - - ConfigurationSection root = cfg.getConfigurationSection("arenas"); - if (root == null) return; - - for (String key : root.getKeys(false)) { - ConfigurationSection sec = root.getConfigurationSection(key); - if (sec == null) continue; - - Arena arena = new Arena(sec.getString("display-name", key)); - arena.setEnabled(sec.getBoolean("enabled", false)); - - // Lobby - if (sec.contains("lobby")) - arena.setLobbyLocation(sec.getLocation("lobby")); - - // Corners - if (sec.contains("corner1")) arena.setCorner1(sec.getLocation("corner1")); - if (sec.contains("corner2")) arena.setCorner2(sec.getLocation("corner2")); - - // Team spawns - ConfigurationSection spawnsSec = sec.getConfigurationSection("spawns"); - if (spawnsSec != null) { - for (Team t : Team.values()) { - List> locs = spawnsSec.getMapList(t.name()); - for (Map m : locs) { - Location loc = deserializeLoc(m); - if (loc != null) arena.addSpawn(t, loc); - } - } - } - - // Team bases - ConfigurationSection basesSec = sec.getConfigurationSection("bases"); - if (basesSec != null) { - for (Team t : Team.values()) { - if (basesSec.contains(t.name())) { - Location loc = basesSec.getLocation(t.name()); - if (loc != null) arena.setBase(t, loc); - } - } - } - - arenas.put(key.toLowerCase(), arena); - plugin.getLogger().info("Arena geladen: §e" + key + (arena.isReady() ? " §a[OK]" : " §c[Setup unvollständig]")); - } - } - - public void save() { - cfg.set("arenas", null); - for (Map.Entry entry : arenas.entrySet()) { - Arena a = entry.getValue(); - String path = "arenas." + entry.getKey() + "."; - - cfg.set(path + "display-name", a.getDisplayName()); - cfg.set(path + "enabled", a.isEnabled()); - - if (a.getLobbyLocation() != null) - cfg.set(path + "lobby", a.getLobbyLocation()); - if (a.getCorner1() != null) cfg.set(path + "corner1", a.getCorner1()); - if (a.getCorner2() != null) cfg.set(path + "corner2", a.getCorner2()); - - // Spawns - for (Team t : Team.values()) { - List> list = new ArrayList<>(); - for (Location loc : a.getSpawns(t)) list.add(serializeLoc(loc)); - cfg.set(path + "spawns." + t.name(), list); - } - - // Bases - for (Map.Entry be : a.getAllBases().entrySet()) { - cfg.set(path + "bases." + be.getKey().name(), be.getValue()); - } - } - try { cfg.save(file); } catch (IOException ex) { ex.printStackTrace(); } - } - - // ─── Location serialization (compatible without external libs) ─────────── - - private Map serializeLoc(Location loc) { - Map m = new LinkedHashMap<>(); - m.put("world", loc.getWorld().getName()); - m.put("x", loc.getX()); m.put("y", loc.getY()); m.put("z", loc.getZ()); - m.put("yaw", (double) loc.getYaw()); - m.put("pitch", (double) loc.getPitch()); - return m; - } - - private Location deserializeLoc(Map m) { - try { - String world = (String) m.get("world"); - double x = ((Number) m.get("x")).doubleValue(); - double y = ((Number) m.get("y")).doubleValue(); - double z = ((Number) m.get("z")).doubleValue(); - float yaw = m.containsKey("yaw") ? ((Number)m.get("yaw")).floatValue() : 0f; - float pitch = m.containsKey("pitch") ? ((Number)m.get("pitch")).floatValue() : 0f; - return new Location(plugin.getServer().getWorld(world), x, y, z, yaw, pitch); - } catch (Exception ex) { return null; } - } -}