From cf25bdc44f4b024391e29dd06b36798f1238faa7 Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Mon, 7 Jul 2014 19:04:44 -0700 Subject: [PATCH] Bridges fix being able to break mid chests before gamestart Map parser Updates --- .../mineplex/core/common/util/MapUtil.java | 10 +- .../src/mineplex/mapparser/MapParser.java | 69 +- .../src/mineplex/mapparser/Parse.java | 739 +++++++++--------- .../src/mineplex/mapparser/WorldManager.java | 5 +- .../game/arcade/game/games/bridge/Bridge.java | 19 + 5 files changed, 468 insertions(+), 374 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java index cf7708fdd..2e7736308 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/MapUtil.java @@ -175,7 +175,15 @@ public class MapUtil public static void UnloadWorld(JavaPlugin plugin, World world) { - world.setAutoSave(false); + UnloadWorld(plugin, world, false); + } + + public static void UnloadWorld(JavaPlugin plugin, World world, boolean save) + { + if (save) + world.save(); + + world.setAutoSave(save); for (Entity entity : world.getEntities()) { diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index a75c2df97..fe8a9423e 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -117,7 +117,7 @@ public class MapParser extends JavaPlugin implements Listener String worldName = "map_" + args[0]; - UtilPlayer.message(caller, F.main("Parser", "Creating World: " + F.elem(worldName))); + Announce("Creating World: " + F.elem(worldName)); WorldCreator worldCreator = new WorldCreator(worldName); worldCreator.environment(Environment.NORMAL); @@ -140,7 +140,7 @@ public class MapParser extends JavaPlugin implements Listener if (!DoesMapExist(worldName)) { - UtilPlayer.message(caller, F.main("Parser", "World does not exist: " + F.elem(worldName))); + UtilPlayer.message(caller, F.main("Parser", "Map does not exist: " + F.elem(worldName))); return; } @@ -159,7 +159,34 @@ public class MapParser extends JavaPlugin implements Listener //Delete FileUtils.deleteQuietly(new File(worldName)); - Inform(caller, "Deleted World: " + F.elem(args[0])); + Announce("Deleted World: " + F.elem(args[0])); + } + else if (event.getMessage().toLowerCase().startsWith("/save")) + { + event.setCancelled(true); + + String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" "); + + String worldName = "map_" + args[0]; + + if (GetMapWorld(worldName) != null) + { + World world = GetMapWorld(worldName); + + //Teleport Out + for (Player other : world.getPlayers()) + other.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0)); + + //Unload World + MapUtil.UnloadWorld(this, world, true); + } + else + { + UtilPlayer.message(caller, F.main("Parser", "World is not loaded: " + F.elem(worldName))); + return; + } + + Announce("Saved World: " + F.elem(args[0])); } else if (event.getMessage().toLowerCase().startsWith("/hub")) { @@ -175,19 +202,16 @@ public class MapParser extends JavaPlugin implements Listener String worldName = "map_" + args[0]; - UtilPlayer.message(caller, F.main("Parser", "Loading Map: " + F.elem(worldName))); - World world = GetMapWorld(worldName); if (world == null) { if (DoesMapExist(worldName)) { - UtilPlayer.message(caller, F.main("Parser", "Map Exists!")); - world = Bukkit.getWorld(worldName); + world = Bukkit.createWorld(new WorldCreator(worldName)); } else { - UtilPlayer.message(caller, F.main("Parser", "Map Doesn't Exist!")); + UtilPlayer.message(caller, F.main("Parser", "Map Not Found: " + F.elem(worldName))); return; } } @@ -278,7 +302,7 @@ public class MapParser extends JavaPlugin implements Listener World parseableWorld = Bukkit.getWorld(worldName); //Parse the World - Parse(event.getPlayer(), parseableWorld, msg.split(" "), parseLoc); + Parse(parseableWorld, msg.split(" "), parseLoc); //Finalize and Save to Zip _worldManager.finalizeParsedWorld(gameType, parseableWorld); @@ -296,9 +320,9 @@ public class MapParser extends JavaPlugin implements Listener } } - public void Parse(Player caller, World world, String[] args, Location loc) + public void Parse(World world, String[] args, Location loc) { - _curParse = new Parse(this, world, args, caller, loc); + _curParse = new Parse(this, world, args, loc); } @EventHandler @@ -335,6 +359,22 @@ public class MapParser extends JavaPlugin implements Listener event.getPlayer().setOp(true); } + @EventHandler + public void SaveUnloadWorlds(TickEvent event) + { + for (World world : getServer().getWorlds()) + { + if (world.getName().equalsIgnoreCase("world")) + continue; + + if (world.getPlayers().isEmpty()) + { + Announce("Saving & Closing World: " + F.elem(world.getName())); + MapUtil.UnloadWorld(this, world, true); + } + } + } + public void Announce(String msg) { for (Player player : UtilServer.getPlayers()) @@ -345,13 +385,6 @@ public class MapParser extends JavaPlugin implements Listener } } - public void Inform(Player player, String message) - { - UtilPlayer.message(player, F.main("Parser", message)); - - System.out.println(message); - } - public boolean DoesMapExist(String name) { File mapsFolder = new File("."); diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java index f75374b1a..5f403649a 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.HashSet; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import org.bukkit.Location; @@ -25,10 +26,12 @@ public class Parse private MapParser Host; private World _world; private String[] _args; - private Player _caller; private Location _callLoc; private int _size = 400; - private int y = 0; + + private int _x = 0; + private int _y = 0; + private int _z = 0; //World Data private HashSet _dataId = new HashSet(); @@ -41,14 +44,13 @@ public class Parse private int _processed = 0; - public Parse(MapParser host, World world, String[] args, Player caller, Location loc) + public Parse(MapParser host, World world, String[] args, Location loc) { Host = host; _world = world; _args = args; - _callLoc = loc; - Host.Announce("Parse Called: " + F.elem(caller.getName())); + _callLoc = new Location(world, loc.getX(), loc.getY(), loc.getZ()); Initialize(); } @@ -69,385 +71,414 @@ public class Parse } catch (Exception e) { - _caller.sendMessage("Invalid Data ID: " + arg); + Host.Announce("Invalid Data ID: " + F.elem(arg)); } } + + _x = -_size; + _z = -_size; + _y = 0; } @SuppressWarnings("deprecation") public boolean Update() { - for (int x=-_size ; x < _size ; x++) - for (int z=-_size ; z < _size ; z++) + long startTime = System.currentTimeMillis(); + + for ( ; _x <= _size ; _x++) + { + for ( ; _z <= _size ; _z++) { - _processed++; - if (_processed % 20000000 == 0) - Host.Announce("Processed: " + F.elem((int)(_processed/1000000) + "M of " + (int)(((_size*2)*(_size*2)*256)/1000000) + "M")); - - Block block = _world.getBlockAt(_callLoc.getBlockX()+x, _callLoc.getBlockY()+y, _callLoc.getBlockZ()+z); - - //ID DATA - if (_dataId.contains(block.getTypeId())) + for ( ; _y <= 256 ; _y++) { - String key = ""+block.getTypeId(); + if (UtilTime.elapsed(startTime, 10)) + return false; - if (!_customLocs.containsKey(key)) - _customLocs.put(key, new ArrayList()); + _processed++; + if (_processed % 10000000 == 0) + Host.Announce("Scanning World: " + F.elem((int)(_processed/1000000) + "M of " + (int)(((_size*2)*(_size*2)*256)/1000000) + "M")); - _customLocs.get(key).add(block.getLocation()); - continue; - } + Block block = _world.getBlockAt(_callLoc.getBlockX()+_x, _y, _callLoc.getBlockZ()+_z); - //Signs - if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) - { - if (block.getRelative(BlockFace.DOWN).getType() == Material.SPONGE) + //if (block.getType() != Material.AIR) + // System.out.println(_world.getName() + " " + _x + " " + _y + " " + _z + " " + block.getType()); + + //ID DATA + if (_dataId.contains(block.getTypeId())) { - Sign s = (Sign) block.getState(); + String key = ""+block.getTypeId(); - String name = ""; + if (!_customLocs.containsKey(key)) + _customLocs.put(key, new ArrayList()); - try - { - name = s.getLine(0); - } - catch (Exception e) - { - Host.Announce("Invalid Sign Data: " + UtilWorld.locToStr(block.getLocation())); - } - - //Add - if (!_customLocs.containsKey(name)) - _customLocs.put(name, new ArrayList()); - - _customLocs.get(name).add(block.getRelative(BlockFace.DOWN).getLocation()); - - //Remove Blocks - block.setTypeId(0); - block.getRelative(BlockFace.DOWN).setTypeId(0); + _customLocs.get(key).add(block.getLocation()); + continue; } - } - //Spawns + Borders - if (block.getTypeId() == 147) - { + //Signs + if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) + { + if (block.getRelative(BlockFace.DOWN).getType() == Material.SPONGE) + { + Sign s = (Sign) block.getState(); + + String name = ""; + + try + { + name = s.getLine(0); + } + catch (Exception e) + { + Host.Announce("Invalid Sign Data: " + UtilWorld.locToStr(block.getLocation())); + } + + //Add + if (!_customLocs.containsKey(name)) + _customLocs.put(name, new ArrayList()); + + _customLocs.get(name).add(block.getRelative(BlockFace.DOWN).getLocation()); + + //Remove Blocks + block.setTypeId(0); + block.getRelative(BlockFace.DOWN).setTypeId(0); + } + } + + //Spawns + Borders + if (block.getTypeId() == 147) + { + Block wool = block.getRelative(BlockFace.DOWN); + if (wool == null) + { + continue; + } + + + if (wool.getType() == Material.WOOL) + { + if (wool.getData() == 0) + { + if (_cornerA == null) + { + _cornerA = wool.getLocation(); + Host.Announce("Corner A: " + UtilWorld.locToStrClean(_cornerA)); + } + + else if (_cornerB == null) + { + _cornerB = wool.getLocation(); + Host.Announce("Corner B: " + UtilWorld.locToStrClean(_cornerA)); + } + + else + { + Host.Announce("More than 2 Corner Markers:"); + Host.Announce("Corner A: " + UtilWorld.locToStrClean(_cornerA)); + Host.Announce("Corner B: " + UtilWorld.locToStrClean(_cornerB)); + Host.Announce("Excess: " + UtilWorld.locToStrClean(wool.getLocation())); + } + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 1) + { + if (!_teamLocs.containsKey("Orange")) + _teamLocs.put("Orange", new ArrayList()); + + _teamLocs.get("Orange").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 2) + { + if (!_teamLocs.containsKey("Magenta")) + _teamLocs.put("Magenta", new ArrayList()); + + _teamLocs.get("Magenta").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 3) + { + if (!_teamLocs.containsKey("Sky")) + _teamLocs.put("Sky", new ArrayList()); + + _teamLocs.get("Sky").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 4) + { + if (!_teamLocs.containsKey("Yellow")) + _teamLocs.put("Yellow", new ArrayList()); + + _teamLocs.get("Yellow").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 5) + { + if (!_teamLocs.containsKey("Lime")) + _teamLocs.put("Lime", new ArrayList()); + + _teamLocs.get("Lime").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 6) + { + if (!_teamLocs.containsKey("Pink")) + _teamLocs.put("Pink", new ArrayList()); + + _teamLocs.get("Pink").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 7) + { + if (!_teamLocs.containsKey("Gray")) + _teamLocs.put("Gray", new ArrayList()); + + _teamLocs.get("Gray").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 8) + { + if (!_teamLocs.containsKey("LGray")) + _teamLocs.put("LGray", new ArrayList()); + + _teamLocs.get("LGray").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 9) + { + if (!_teamLocs.containsKey("Cyan")) + _teamLocs.put("Cyan", new ArrayList()); + + _teamLocs.get("Cyan").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 10) + { + if (!_teamLocs.containsKey("Purple")) + _teamLocs.put("Purple", new ArrayList()); + + _teamLocs.get("Purple").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 11) + { + if (!_teamLocs.containsKey("DBlue")) + _teamLocs.put("DBlue", new ArrayList()); + + _teamLocs.get("DBlue").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 12) + { + if (!_teamLocs.containsKey("Brown")) + _teamLocs.put("Brown", new ArrayList()); + + _teamLocs.get("Brown").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 13) + { + if (!_teamLocs.containsKey("Green")) + _teamLocs.put("Green", new ArrayList()); + + _teamLocs.get("Green").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 14) + { + if (!_teamLocs.containsKey("Red")) + _teamLocs.put("Red", new ArrayList()); + + _teamLocs.get("Red").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + + if (wool.getData() == 15) + { + if (!_teamLocs.containsKey("Black")) + _teamLocs.put("Black", new ArrayList()); + + _teamLocs.get("Black").add(wool.getLocation()); + + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); + } + } + } + + if (block.getTypeId() != 148) + continue; + Block wool = block.getRelative(BlockFace.DOWN); if (wool == null) continue; - if (wool.getType() == Material.WOOL) - { - if (wool.getData() == 0) - { - if (_cornerA == null) _cornerA = wool.getLocation(); - else if (_cornerB == null) _cornerB = wool.getLocation(); - else - { - Host.Announce("More than 2 Corner Markers:"); - Host.Announce("Corner A: " + _cornerA); - Host.Announce("Corner B: " + _cornerB); - Host.Announce("Excess: " + UtilWorld.locToStrClean(wool.getLocation())); - } + if (wool.getType() != Material.WOOL) + continue; - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } + Wool woolData = new Wool(wool.getType(), wool.getData()); - if (wool.getData() == 1) - { - if (!_teamLocs.containsKey("Orange")) - _teamLocs.put("Orange", new ArrayList()); + String dataType = woolData.getColor().name(); - _teamLocs.get("Orange").add(wool.getLocation()); + if (!_dataLocs.containsKey(dataType)) + _dataLocs.put(dataType, new ArrayList()); - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } + _dataLocs.get(dataType).add(wool.getLocation()); - if (wool.getData() == 2) - { - if (!_teamLocs.containsKey("Magenta")) - _teamLocs.put("Magenta", new ArrayList()); - - _teamLocs.get("Magenta").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 3) - { - if (!_teamLocs.containsKey("Sky")) - _teamLocs.put("Sky", new ArrayList()); - - _teamLocs.get("Sky").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 4) - { - if (!_teamLocs.containsKey("Yellow")) - _teamLocs.put("Yellow", new ArrayList()); - - _teamLocs.get("Yellow").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 5) - { - if (!_teamLocs.containsKey("Lime")) - _teamLocs.put("Lime", new ArrayList()); - - _teamLocs.get("Lime").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 6) - { - if (!_teamLocs.containsKey("Pink")) - _teamLocs.put("Pink", new ArrayList()); - - _teamLocs.get("Pink").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 7) - { - if (!_teamLocs.containsKey("Gray")) - _teamLocs.put("Gray", new ArrayList()); - - _teamLocs.get("Gray").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 8) - { - if (!_teamLocs.containsKey("LGray")) - _teamLocs.put("LGray", new ArrayList()); - - _teamLocs.get("LGray").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 9) - { - if (!_teamLocs.containsKey("Cyan")) - _teamLocs.put("Cyan", new ArrayList()); - - _teamLocs.get("Cyan").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 10) - { - if (!_teamLocs.containsKey("Purple")) - _teamLocs.put("Purple", new ArrayList()); - - _teamLocs.get("Purple").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 11) - { - if (!_teamLocs.containsKey("DBlue")) - _teamLocs.put("DBlue", new ArrayList()); - - _teamLocs.get("DBlue").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 12) - { - if (!_teamLocs.containsKey("Brown")) - _teamLocs.put("Brown", new ArrayList()); - - _teamLocs.get("Brown").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 13) - { - if (!_teamLocs.containsKey("Green")) - _teamLocs.put("Green", new ArrayList()); - - _teamLocs.get("Green").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 14) - { - if (!_teamLocs.containsKey("Red")) - _teamLocs.put("Red", new ArrayList()); - - _teamLocs.get("Red").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - - if (wool.getData() == 15) - { - if (!_teamLocs.containsKey("Black")) - _teamLocs.put("Black", new ArrayList()); - - _teamLocs.get("Black").add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); - } - } + //Remove Blocks + block.setTypeId(0); + wool.setTypeId(0); } - - if (block.getTypeId() != 148) - continue; - - Block wool = block.getRelative(BlockFace.DOWN); - if (wool == null) - continue; - - if (wool.getType() != Material.WOOL) - continue; - - Wool woolData = new Wool(wool.getType(), wool.getData()); - - String dataType = woolData.getColor().name(); - - if (!_dataLocs.containsKey(dataType)) - _dataLocs.put(dataType, new ArrayList()); - - _dataLocs.get(dataType).add(wool.getLocation()); - - //Remove Blocks - block.setTypeId(0); - wool.setTypeId(0); + + _y = 0; } - - y++; - - //Finalize - if (y > 255) - { - if (_cornerA == null || _cornerB == null) - { - Host.Announce("Missing Corner Locations!"); - Host.Announce("Defaulted to -256 to +256"); - - _cornerA = new Location(_world, -256, 0, -256); - _cornerB = new Location(_world, 256, 0, 256); - } - - //Save - try - { - FileWriter fstream = new FileWriter(_world.getName() + File.separator + "WorldConfig.dat"); - BufferedWriter out = new BufferedWriter(fstream); - - out.write("MAP_NAME:"); - out.write("\n"); - out.write("MAP_AUTHOR:"); - out.write("\n"); - out.write("\n"); - out.write("MIN_X:"+Math.min(_cornerA.getBlockX(), _cornerB.getBlockX())); - out.write("\n"); - out.write("MAX_X:"+Math.max(_cornerA.getBlockX(), _cornerB.getBlockX())); - out.write("\n"); - out.write("MIN_Z:"+Math.min(_cornerA.getBlockZ(), _cornerB.getBlockZ())); - out.write("\n"); - out.write("MAX_Z:"+Math.max(_cornerA.getBlockZ(), _cornerB.getBlockZ())); - out.write("\n"); - out.write("\n"); - if (_cornerA.getBlockY() == _cornerB.getBlockY()) - { - out.write("MIN_Y:0"); - out.write("\n"); - out.write("MAX_Y:256"); - } - else - { - out.write("MIN_Y:"+Math.min(_cornerA.getBlockY(), _cornerB.getBlockY())); - out.write("\n"); - out.write("MAX_Y:"+Math.max(_cornerA.getBlockY(), _cornerB.getBlockY())); - } - - //Teams - for (String team : _teamLocs.keySet()) - { - out.write("\n"); - out.write("\n"); - out.write("TEAM_NAME:" + team); - out.write("\n"); - out.write("TEAM_SPAWNS:" + LocationsToString(_teamLocs.get(team))); - } - - //Data - for (String data : _dataLocs.keySet()) - { - out.write("\n"); - out.write("\n"); - out.write("DATA_NAME:" + data); - out.write("\n"); - out.write("DATA_LOCS:" + LocationsToString(_dataLocs.get(data))); - } - - //Custom - for (String data : _customLocs.keySet()) - { - out.write("\n"); - out.write("\n"); - out.write("CUSTOM_NAME:" + data); - out.write("\n"); - out.write("CUSTOM_LOCS:" + LocationsToString(_customLocs.get(data))); - } - - out.close(); - } - catch (Exception e) - { - Host.Announce("Error: File Write Error"); - } - - Host.Announce("WorldConfig.dat Saved."); + + _z = -_size; } - return false; + //Finalize + + if (_cornerA == null || _cornerB == null) + { + Host.Announce("Missing Corner Locations! Defaulted to -256 to +256."); + + _cornerA = new Location(_world, -256, 0, -256); + _cornerB = new Location(_world, 256, 0, 256); + } + + //Save + try + { + FileWriter fstream = new FileWriter(_world.getName() + File.separator + "WorldConfig.dat"); + BufferedWriter out = new BufferedWriter(fstream); + + out.write("MAP_NAME:"); + out.write("\n"); + out.write("MAP_AUTHOR:"); + out.write("\n"); + out.write("\n"); + out.write("MIN_X:"+Math.min(_cornerA.getBlockX(), _cornerB.getBlockX())); + out.write("\n"); + out.write("MAX_X:"+Math.max(_cornerA.getBlockX(), _cornerB.getBlockX())); + out.write("\n"); + out.write("MIN_Z:"+Math.min(_cornerA.getBlockZ(), _cornerB.getBlockZ())); + out.write("\n"); + out.write("MAX_Z:"+Math.max(_cornerA.getBlockZ(), _cornerB.getBlockZ())); + out.write("\n"); + out.write("\n"); + if (_cornerA.getBlockY() == _cornerB.getBlockY()) + { + out.write("MIN_Y:0"); + out.write("\n"); + out.write("MAX_Y:256"); + } + else + { + out.write("MIN_Y:"+Math.min(_cornerA.getBlockY(), _cornerB.getBlockY())); + out.write("\n"); + out.write("MAX_Y:"+Math.max(_cornerA.getBlockY(), _cornerB.getBlockY())); + } + + //Teams + for (String team : _teamLocs.keySet()) + { + out.write("\n"); + out.write("\n"); + out.write("TEAM_NAME:" + team); + out.write("\n"); + out.write("TEAM_SPAWNS:" + LocationsToString(_teamLocs.get(team))); + } + + //Data + for (String data : _dataLocs.keySet()) + { + out.write("\n"); + out.write("\n"); + out.write("DATA_NAME:" + data); + out.write("\n"); + out.write("DATA_LOCS:" + LocationsToString(_dataLocs.get(data))); + } + + //Custom + for (String data : _customLocs.keySet()) + { + out.write("\n"); + out.write("\n"); + out.write("CUSTOM_NAME:" + data); + out.write("\n"); + out.write("CUSTOM_LOCS:" + LocationsToString(_customLocs.get(data))); + } + + out.close(); + } + catch (Exception e) + { + Host.Announce("Error: File Write Error"); + } + + Host.Announce("WorldConfig.dat Saved."); + + return true; } public String LocationsToString(ArrayList locs) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java index 4e6f1ce9b..54cb0f355 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/WorldManager.java @@ -26,7 +26,7 @@ public class WorldManager public String prepMapParse(World world) { //Unload World - MapUtil.UnloadWorld(_plugin, world); + MapUtil.UnloadWorld(_plugin, world, true); //Delete Non-Map Files String[] folders = new File(world.getName()).list(); @@ -94,5 +94,8 @@ public class WorldManager { e.printStackTrace(); } + + //Delete Parse Map + FileUtils.deleteQuietly(new File(world.getName())); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java index b824f0733..e910626e6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/bridge/Bridge.java @@ -336,6 +336,25 @@ public class Bridge extends TeamGame implements OreObsfucation } } } + + @EventHandler + public void ChestDeny(BlockBreakEvent event) + { + if (_bridgesDown) + return; + + if (event.getBlock().getType() != Material.CHEST) + return; + + for (Location loc : WorldData.GetCustomLocs("54")) + { + if (loc.getBlock().equals(event.getBlock())) + { + event.setCancelled(true); + return; + } + } + } private void ParseOre(ArrayList teamOre) {