/** * search modules by module name * * @param mName the module name to find * @return the module if found, null otherwise */ public ArenaRegion getModule(String mName) { for (ArenaRegion region : regions) { if (region.getName().equalsIgnoreCase(mName)) { return region; } } return null; }
public void reload() { regions = loader.reload(); regions.add(new Cuboid()); for (ArenaRegion mod : regions) { db.i("module ArenaRegion loaded: " + mod.getName() + " (version " + mod.version() + ")"); } }
public ArenaRegion newRegion(String name, RegionShape shape) { for (ArenaRegion region : regions) { if (region.getShape().equals(shape)) { ArenaRegion result = region.clone(); result.name = name; setRegionTypeByName(result, name); return result; } } return null; }
/** * create an arena region manager instance * * @param plugin the plugin instance */ public ArenaRegionManager(PVPArena plugin) { File path = new File(plugin.getDataFolder().toString() + "/regions"); if (!path.exists()) { path.mkdir(); } loader = new NCLoader<ArenaRegion>(plugin, path, new Object[] {}); regions = loader.load(); regions.add(new Cuboid()); for (ArenaRegion mod : regions) { db.i("module ArenaRegion loaded: " + mod.getName() + " (version " + mod.version() + ")"); } }
public ArenaRegion readRegionFromConfig( String regionName, YamlConfiguration config, Arena arena) { db.i("reading config region: " + arena.name + "=>" + regionName); String coords = config.getString("regions." + regionName); ArenaRegion.RegionShape shape = ArenaRegionManager.getShapeByCoords(coords); ArenaRegion region = PVPArena.instance.getArm().newRegion(regionName, shape); if (region != null) { region.arena = arena; region.set(Bukkit.getWorld(arena.getWorld()), coords); } return region; }
public ArenaRegion newRegion( String name, Arena arena, Location pos1, Location pos2, RegionShape shape) { for (ArenaRegion region : regions) { if (region.getShape().equals(shape)) { ArenaRegion result = region.clone(); result.name = name; result.min = pos1.toVector(); result.max = pos2.toVector(); result.arena = arena; result.world = pos1.getWorld(); setRegionTypeByName(result, name); result.initialize(); return result; } } return null; }
private void setRegionTypeByName(ArenaRegion r, String s) { if (s.equals("battlefield")) { r.setType(RegionType.BATTLEFIELD); } else if (s.equals("spectator")) { r.setType(RegionType.SPECTATOR); } else if (s.equals("exit")) { r.setType(RegionType.EXIT); } else if (s.endsWith("lounge")) { r.setType(RegionType.LOUNGE); } else if (s.equals("join")) { r.setType(RegionType.JOIN); } else if (s.startsWith("death")) { r.setType(RegionType.DEATH); } else if (s.startsWith("nocamp")) { r.setType(RegionType.NOCAMP); } else if (s.startsWith("win")) { r.setType(RegionType.WIN); } else if (s.startsWith("lose")) { r.setType(RegionType.LOSE); } else { r.setType(RegionType.CUSTOM); } }