Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
6ae35f1b37
@ -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())
|
||||
{
|
||||
|
@ -115,9 +115,15 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/create <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -136,11 +142,17 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/delete <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
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 +171,40 @@ 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(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/save <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
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"))
|
||||
{
|
||||
@ -173,21 +218,24 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -232,6 +280,12 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/parse <GameType>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String gameType = args[0];
|
||||
|
||||
try
|
||||
@ -277,11 +331,10 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
//World to be Parsed
|
||||
World parseableWorld = Bukkit.getWorld(worldName);
|
||||
|
||||
//Parse the World
|
||||
Parse(event.getPlayer(), parseableWorld, msg.split(" "), parseLoc);
|
||||
//event.getPlayer().teleport(new Location(parseableWorld, 0, 30 ,0));
|
||||
|
||||
//Finalize and Save to Zip
|
||||
_worldManager.finalizeParsedWorld(gameType, parseableWorld);
|
||||
//Parse the World
|
||||
_curParse = new Parse(this, parseableWorld, msg.split(" "), parseLoc, gameType, "Default", "Default");
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
|
||||
{
|
||||
@ -295,11 +348,6 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Parse(Player caller, World world, String[] args, Location loc)
|
||||
{
|
||||
_curParse = new Parse(this, world, args, caller, loc);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ParseUpdate(TickEvent event)
|
||||
@ -309,6 +357,8 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
if (_curParse.Update())
|
||||
{
|
||||
_worldManager.finalizeParsedWorld(_curParse.getGameType(), _curParse.getWorld());
|
||||
|
||||
_curParse = null;
|
||||
|
||||
Announce("Parse Completed!");
|
||||
@ -335,6 +385,28 @@ 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.getName().startsWith("parse_"))
|
||||
continue;
|
||||
|
||||
if (!world.getName().startsWith("map_"))
|
||||
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 +417,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(".");
|
||||
|
@ -8,6 +8,8 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -25,10 +27,17 @@ 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 _size = 50;
|
||||
private int _x = 0;
|
||||
private int _y = 0;
|
||||
private int _z = 0;
|
||||
|
||||
//Map Data
|
||||
private String _gameType;
|
||||
private String _mapName;
|
||||
private String _mapCreator;
|
||||
|
||||
//World Data
|
||||
private HashSet<Integer> _dataId = new HashSet<Integer>();
|
||||
@ -41,14 +50,17 @@ 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, String gameType, String mapName, String mapCreator)
|
||||
{
|
||||
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());
|
||||
|
||||
_gameType = gameType;
|
||||
_mapName = mapName;
|
||||
_mapCreator = mapCreator;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
@ -69,385 +81,413 @@ 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<Location>());
|
||||
_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;
|
||||
}
|
||||
|
||||
//Signs
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
if (block.getRelative(BlockFace.DOWN).getType() == Material.SPONGE)
|
||||
Block block = _world.getBlockAt(_callLoc.getBlockX()+_x, _y, _callLoc.getBlockZ()+_z);
|
||||
|
||||
//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<Location>());
|
||||
|
||||
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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
String dataType = woolData.getColor().name();
|
||||
|
||||
_teamLocs.get("Orange").add(wool.getLocation());
|
||||
if (!_dataLocs.containsKey(dataType))
|
||||
_dataLocs.put(dataType, new ArrayList<Location>());
|
||||
|
||||
//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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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<Location>());
|
||||
|
||||
_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:"+_mapName);
|
||||
out.write("\n");
|
||||
out.write("MAP_AUTHOR:"+_mapCreator);
|
||||
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");
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Host.Announce("WorldConfig.dat Saved.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String LocationsToString(ArrayList<Location> locs)
|
||||
@ -469,4 +509,14 @@ public class Parse
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public String getGameType()
|
||||
{
|
||||
return _gameType;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return _world;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.mapparser;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
@ -10,6 +11,7 @@ import mineplex.core.common.util.WorldUtil;
|
||||
import mineplex.core.common.util.ZipUtil;
|
||||
import net.minecraft.util.org.apache.commons.io.FileUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -26,7 +28,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();
|
||||
@ -50,7 +52,7 @@ public class WorldManager
|
||||
//Delete if already exists
|
||||
File destination = new File("parse_" + world.getName());
|
||||
if (destination.exists())
|
||||
FileUtils.deleteQuietly(destination);
|
||||
FileUtils.deleteDirectory(destination);
|
||||
|
||||
FileUtils.copyDirectory(new File(world.getName()), destination);
|
||||
}
|
||||
@ -60,31 +62,46 @@ public class WorldManager
|
||||
return null;
|
||||
}
|
||||
|
||||
WorldUtil.LoadWorld(new WorldCreator("parse_" + world.getName()));
|
||||
Bukkit.createWorld(new WorldCreator("parse_" + world.getName()));
|
||||
|
||||
return "parse_" + world.getName();
|
||||
}
|
||||
|
||||
public void finalizeParsedWorld(String gameType, World world)
|
||||
{
|
||||
MapUtil.UnloadWorld(_plugin, world);
|
||||
MapUtil.UnloadWorld(_plugin, world, true);
|
||||
|
||||
String[] folders = new File(world.getName()).list();
|
||||
for (String fileName : folders)
|
||||
ArrayList<String> fileList = new ArrayList<String>();
|
||||
ArrayList<String> dirList = new ArrayList<String>();
|
||||
|
||||
File[] files = new File(world.getName()).listFiles();
|
||||
for (File file : files)
|
||||
{
|
||||
if (fileName.equalsIgnoreCase("level.dat"))
|
||||
if (file.getName().equalsIgnoreCase("level.dat"))
|
||||
{
|
||||
fileList.add(file.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fileName.equalsIgnoreCase("region"))
|
||||
if (file.getName().equalsIgnoreCase("region"))
|
||||
{
|
||||
dirList.add(file.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fileName.equalsIgnoreCase("WorldConfig.dat"))
|
||||
if (file.getName().equalsIgnoreCase("WorldConfig.dat"))
|
||||
{
|
||||
fileList.add(file.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
FileUtils.deleteQuietly(new File(world.getName() + File.separator + fileName));
|
||||
FileUtils.deleteQuietly(new File(world.getName() + File.separator + file.getName()));
|
||||
}
|
||||
|
||||
ZipUtil.ZipFolders(Paths.get("").toAbsolutePath().toString(), world.getName() + ".zip", Arrays.asList(new String[] { world.getName() }), Arrays.asList(new String[] { }));
|
||||
//System.out.println("Path A: " + Paths.get("").toAbsolutePath().toString());
|
||||
//System.out.println("Path B: " + Paths.get("").toAbsolutePath().toString() + File.separator + world.getName() + File.separator);
|
||||
|
||||
ZipUtil.ZipFolders(Paths.get("").toAbsolutePath().toString(), world.getName() + ".zip", dirList, fileList);
|
||||
|
||||
try
|
||||
{
|
||||
@ -94,5 +111,8 @@ public class WorldManager
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//Delete Parse Map
|
||||
FileUtils.deleteQuietly(new File(world.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -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<Location> teamOre)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user