Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
97422e237f
@ -2,17 +2,21 @@ package mineplex.mapparser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import net.minecraft.util.org.apache.commons.io.FileUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
@ -23,9 +27,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class MapParser extends JavaPlugin implements Listener
|
||||
@ -34,6 +42,8 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
private Parse _curParse = null;
|
||||
|
||||
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
@ -60,6 +70,8 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
player.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
|
||||
|
||||
ResetInventory(event.getPlayer());
|
||||
|
||||
DisplayHelp(player);
|
||||
}
|
||||
|
||||
@ -67,21 +79,30 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
|
||||
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
|
||||
UtilPlayer.message(player, " ");
|
||||
UtilPlayer.message(player, F.value("/create <name>", "Creates a new map"));
|
||||
UtilPlayer.message(player, F.value("/delete <name>", "Deletes an existing map"));
|
||||
UtilPlayer.message(player, F.value("/map <name>", "Teleport to a map"));
|
||||
UtilPlayer.message(player, F.value("/list", "List maps"));
|
||||
UtilPlayer.message(player, F.value("/copyschematics", "Loads Schematics from Build-1"));
|
||||
UtilPlayer.message(player, F.value("/parse", "Parse your current map!"));
|
||||
UtilPlayer.message(player, " ");
|
||||
UtilPlayer.message(player, F.value("/join <name>", "Toggle join for player on map"));
|
||||
UtilPlayer.message(player, F.value("/build <name>", "Toggle build for player on map"));
|
||||
UtilPlayer.message(player, " ");
|
||||
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));
|
||||
UtilPlayer.message(player, F.value("/author <name>", "Set author for current map"));
|
||||
UtilPlayer.message(player, F.value("/gametype <type", "Set gametype for current map"));
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Command(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player caller = event.getPlayer();
|
||||
|
||||
|
||||
if (_curParse != null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parse", "Cannot use commands during map parse!"));
|
||||
UtilPlayer.message(caller, F.main("Parse", "Cannot use commands during Map Parse!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -112,17 +133,23 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
else if (event.getMessage().toLowerCase().startsWith("/create"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/create <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
if (DoesMapExist(worldName))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Map name is already in use!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Announce("Creating World: " + F.elem(worldName));
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(worldName);
|
||||
@ -135,19 +162,24 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
|
||||
|
||||
event.getPlayer().teleport(new Location(world, 0, 100, 0));
|
||||
|
||||
//Give Access
|
||||
GetData(world.getName()).WhiteList.add(event.getPlayer().getName());
|
||||
GetData(world.getName()).BuildList.add(event.getPlayer().getName());
|
||||
GetData(world.getName()).Write();
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/delete"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/delete <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
if (!DoesMapExist(worldName))
|
||||
@ -156,6 +188,12 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GetData(worldName).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetMapWorld(worldName) != null)
|
||||
{
|
||||
World world = GetMapWorld(worldName);
|
||||
@ -177,20 +215,26 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/save <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
if (GetMapWorld(worldName) != null)
|
||||
{
|
||||
World world = GetMapWorld(worldName);
|
||||
|
||||
if (!GetData(worldName).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Teleport Out
|
||||
for (Player other : world.getPlayers())
|
||||
other.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
|
||||
@ -216,14 +260,14 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (args.length < 1)
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
World world = GetMapWorld(worldName);
|
||||
@ -246,6 +290,13 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
UtilPlayer.message(caller, F.main("Parser", "Null World Error: " + F.elem(worldName)));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(world.getName()).CanJoin(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Join-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Teleport
|
||||
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
|
||||
@ -269,49 +320,23 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
caller.sendMessage(file.getName());
|
||||
}
|
||||
|
||||
//_worldManager.listPendingParses(event.getPlayer());
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/parse"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
Location parseLoc = event.getPlayer().getLocation();
|
||||
|
||||
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
|
||||
{
|
||||
GameType.valueOf(gameType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Valid Game Types;"));
|
||||
|
||||
String gameTypes = "";
|
||||
|
||||
for (GameType game : GameType.values())
|
||||
{
|
||||
gameTypes += game.toString() + " ";
|
||||
}
|
||||
|
||||
event.getPlayer().sendMessage(gameTypes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = event.getMessage().replace(gameType, "").toLowerCase();
|
||||
|
||||
|
||||
World world = caller.getWorld();
|
||||
|
||||
MapData data = GetData(caller.getWorld().getName());
|
||||
|
||||
if (data.MapName.equals("null") || data.MapCreator.equals("null") || data.GameType.equals("null"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Map Name/Author/GameType are not set!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Teleport Players Out
|
||||
for (Player worldPlayer : world.getPlayers())
|
||||
{
|
||||
@ -328,10 +353,8 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
//event.getPlayer().teleport(new Location(parseableWorld, 0, 30 ,0));
|
||||
|
||||
//Parse the World
|
||||
_curParse = new Parse(this, parseableWorld, msg.split(" "), parseLoc, gameType, "Default", "Default");
|
||||
_curParse = new Parse(this, parseableWorld, event.getMessage().split(" "), parseLoc, GetData(parseLoc.getWorld().getName()));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
|
||||
{
|
||||
@ -344,6 +367,221 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
event.getPlayer().sendMessage(world.getName());
|
||||
}
|
||||
}
|
||||
|
||||
//XXX Set Map Data
|
||||
else if (event.getMessage().toLowerCase().startsWith("/name"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/name <MapName>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
|
||||
|
||||
if (event.getPlayer().getWorld().getName().equals("world"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set name for Lobby."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
MapData data = GetData(event.getPlayer().getWorld().getName());
|
||||
|
||||
data.MapName = input;
|
||||
data.Write();
|
||||
|
||||
Announce("Map Name for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(input) + ".");
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/author"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/author <MapAuthor>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
|
||||
|
||||
if (event.getPlayer().getWorld().getName().equals("world"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set author for Lobby."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
MapData data = GetData(event.getPlayer().getWorld().getName());
|
||||
|
||||
data.MapCreator = input;
|
||||
data.Write();
|
||||
|
||||
Announce("Map Author for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(input) + ".");
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/gametype"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/gametype <GameType>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
if (event.getPlayer().getWorld().getName().equals("world"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot set GameType for Lobby."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Check Gametype
|
||||
try
|
||||
{
|
||||
GameType.valueOf(args[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Valid Game Types;"));
|
||||
|
||||
String gameTypes = "";
|
||||
|
||||
for (GameType game : GameType.values())
|
||||
{
|
||||
gameTypes += game.toString() + " ";
|
||||
}
|
||||
|
||||
event.getPlayer().sendMessage(gameTypes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MapData data = GetData(event.getPlayer().getWorld().getName());
|
||||
|
||||
data.GameType = args[0];
|
||||
data.Write();
|
||||
|
||||
Announce("GameType for " + F.elem(event.getPlayer().getWorld().getName()) + " set to " + F.elem(args[0]) + ".");
|
||||
}
|
||||
|
||||
else if (event.getMessage().toLowerCase().startsWith("/join"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/join <Name>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ")[0];
|
||||
|
||||
if (event.getPlayer().getWorld().getName().equals("world"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot change Join-List for Lobby."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = UtilPlayer.searchOnline(event.getPlayer(), input, true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
MapData data = GetData(event.getPlayer().getWorld().getName());
|
||||
|
||||
if (data.WhiteList.contains(player.getName()))
|
||||
{
|
||||
data.WhiteList.remove(player.getName());
|
||||
data.Write();
|
||||
|
||||
Announce("Join-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(false) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.WhiteList.add(player.getName());
|
||||
data.Write();
|
||||
|
||||
Announce("Join-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(true) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (event.getMessage().toLowerCase().startsWith("/build"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
if (event.getMessage().split(" ").length < 2)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/build <Name>")));
|
||||
return;
|
||||
}
|
||||
|
||||
String input = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ")[0];
|
||||
|
||||
if (event.getPlayer().getWorld().getName().equals("world"))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Cannot change Build-List for Lobby."));
|
||||
return;
|
||||
}
|
||||
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = UtilPlayer.searchOnline(event.getPlayer(), input, true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
MapData data = GetData(event.getPlayer().getWorld().getName());
|
||||
|
||||
if (data.BuildList.contains(player.getName()))
|
||||
{
|
||||
data.BuildList.remove(player.getName());
|
||||
data.Write();
|
||||
|
||||
Announce("Build-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(false) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
data.BuildList.add(player.getName());
|
||||
data.Write();
|
||||
|
||||
Announce("Build-List for " + F.elem(event.getPlayer().getWorld().getName()) + " (" + player.getName() + " = " + F.tf(true) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -360,7 +598,7 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
try
|
||||
{
|
||||
_worldManager.finalizeParsedWorld(_curParse.getGameType(), _curParse.getWorld());
|
||||
_worldManager.finalizeParsedWorld(_curParse.getWorld());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -387,9 +625,6 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||
event.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
|
||||
if (!event.getPlayer().isOp())
|
||||
event.getPlayer().setOp(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -449,4 +684,92 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MapData GetData(String mapName)
|
||||
{
|
||||
if (_mapData.containsKey(mapName))
|
||||
return _mapData.get(mapName);
|
||||
|
||||
MapData data = new MapData(mapName);
|
||||
|
||||
_mapData.put(mapName, data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public void ResetInventory(Player player)
|
||||
{
|
||||
UtilInv.Clear(player);
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_SPADE));
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
|
||||
player.getInventory().addItem(new ItemStack(Material.STONE_AXE));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Chat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String world = C.cDGreen + C.Bold + event.getPlayer().getWorld().getName();
|
||||
|
||||
String name = C.cYellow + event.getPlayer().getName();
|
||||
if (GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
name = C.cGreen + event.getPlayer().getName();
|
||||
|
||||
String grayName = C.cBlue + event.getPlayer().getName();
|
||||
String grayWorld = C.cBlue + C.Bold + event.getPlayer().getWorld().getName();
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.getWorld().equals(event.getPlayer().getWorld()))
|
||||
{
|
||||
player.sendMessage(world + ChatColor.RESET + " " + name + ChatColor.RESET + " " + event.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(grayWorld + ChatColor.RESET + " " + grayName + ChatColor.RESET + " " + C.cGray + event.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System.out.println(world + ChatColor.RESET + " " + name + ChatColor.RESET + " " + event.getMessage());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InteractCancel(PlayerInteractEvent event)
|
||||
{
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void WorldeditCancel(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("//"))
|
||||
{
|
||||
//Permission
|
||||
if (!GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "You do not have Build-Access for this Map."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Join(PlayerJoinEvent event)
|
||||
{
|
||||
event.setJoinMessage(F.sys("Player Join", event.getPlayer().getName()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Join(PlayerQuitEvent event)
|
||||
{
|
||||
event.setQuitMessage(F.sys("Player Quit", event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,7 @@ public class Parse
|
||||
private int _z = 0;
|
||||
|
||||
//Map Data
|
||||
private String _gameType;
|
||||
private String _mapName;
|
||||
private String _mapCreator;
|
||||
private MapData _mapData;
|
||||
|
||||
//World Data
|
||||
private HashSet<Integer> _dataId = new HashSet<Integer>();
|
||||
@ -50,7 +48,7 @@ public class Parse
|
||||
|
||||
private int _processed = 0;
|
||||
|
||||
public Parse(MapParser host, World world, String[] args, Location loc, String gameType, String mapName, String mapCreator)
|
||||
public Parse(MapParser host, World world, String[] args, Location loc, MapData data)
|
||||
{
|
||||
Host = host;
|
||||
|
||||
@ -58,9 +56,7 @@ public class Parse
|
||||
_args = args;
|
||||
_callLoc = new Location(world, loc.getX(), loc.getY(), loc.getZ());
|
||||
|
||||
_gameType = gameType;
|
||||
_mapName = mapName;
|
||||
_mapCreator = mapCreator;
|
||||
_mapData = data;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
@ -175,7 +171,7 @@ public class Parse
|
||||
else if (_cornerB == null)
|
||||
{
|
||||
_cornerB = wool.getLocation();
|
||||
Host.Announce("Corner B: " + UtilWorld.locToStrClean(_cornerA));
|
||||
Host.Announce("Corner B: " + UtilWorld.locToStrClean(_cornerB));
|
||||
}
|
||||
|
||||
else
|
||||
@ -419,9 +415,9 @@ public class Parse
|
||||
FileWriter fstream = new FileWriter(_world.getName() + File.separator + "WorldConfig.dat");
|
||||
BufferedWriter out = new BufferedWriter(fstream);
|
||||
|
||||
out.write("MAP_NAME:"+_mapName);
|
||||
out.write("MAP_NAME:"+_mapData.MapName);
|
||||
out.write("\n");
|
||||
out.write("MAP_AUTHOR:"+_mapCreator);
|
||||
out.write("MAP_AUTHOR:"+_mapData.MapCreator);
|
||||
out.write("\n");
|
||||
out.write("\n");
|
||||
out.write("MIN_X:"+Math.min(_cornerA.getBlockX(), _cornerB.getBlockX()));
|
||||
@ -512,7 +508,7 @@ public class Parse
|
||||
|
||||
public String getGameType()
|
||||
{
|
||||
return _gameType;
|
||||
return _mapData.GameType;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
|
@ -18,17 +18,17 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class WorldManager
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
private MapParser Host;
|
||||
|
||||
public WorldManager(JavaPlugin plugin)
|
||||
public WorldManager(MapParser plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
Host = plugin;
|
||||
}
|
||||
|
||||
public World prepMapParse(World world)
|
||||
{
|
||||
//Unload World
|
||||
MapUtil.UnloadWorld(_plugin, world, true);
|
||||
MapUtil.UnloadWorld(Host, world, true);
|
||||
|
||||
//Delete Non-Map Files
|
||||
String[] folders = new File(world.getName()).list();
|
||||
@ -42,6 +42,9 @@ public class WorldManager
|
||||
|
||||
if (fileName.equalsIgnoreCase("WorldConfig.dat"))
|
||||
continue;
|
||||
|
||||
if (fileName.equalsIgnoreCase("Map.dat"))
|
||||
continue;
|
||||
|
||||
FileUtils.deleteQuietly(new File(world.getName() + File.separator + fileName));
|
||||
}
|
||||
@ -65,9 +68,9 @@ public class WorldManager
|
||||
return Bukkit.createWorld(new WorldCreator("parse_" + world.getName()));
|
||||
}
|
||||
|
||||
public void finalizeParsedWorld(String gameType, World world)
|
||||
public void finalizeParsedWorld(World world)
|
||||
{
|
||||
MapUtil.UnloadWorld(_plugin, world, true);
|
||||
MapUtil.UnloadWorld(Host, world, true);
|
||||
|
||||
ArrayList<String> fileList = new ArrayList<String>();
|
||||
ArrayList<String> dirList = new ArrayList<String>();
|
||||
@ -96,12 +99,16 @@ public class WorldManager
|
||||
FileUtils.deleteQuietly(new File(world.getName() + File.separator + file.getName()));
|
||||
}
|
||||
|
||||
MapData data = Host.GetData(world.getName().substring(6));
|
||||
|
||||
String fileName = data.GameType + "_" + data.MapName + ".zip";
|
||||
GameType gameType = GameType.valueOf(data.GameType);
|
||||
|
||||
ZipUtil.ZipFolders(Paths.get(world.getName()).toAbsolutePath().toString(), world.getName() + ".zip", dirList, fileList);
|
||||
ZipUtil.ZipFolders(Paths.get(world.getName()).toAbsolutePath().toString(), fileName, dirList, fileList);
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyFile(new File(world.getName() + ".zip"), new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType + File.separator + world.getName() + ".zip"));
|
||||
FileUtils.copyFile(new File(fileName), new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType.GetName() + File.separator + fileName));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -217,7 +217,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new GameCommand(this));
|
||||
AddCommand(new ParseCommand(this));
|
||||
AddCommand(new WriteCommand(this));
|
||||
}
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
package nautilus.game.arcade.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.world.WorldParser;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public class ParseCommand extends CommandBase<ArcadeManager>
|
||||
{
|
||||
public ParseCommand(ArcadeManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "parse");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
caller.sendMessage("Parsing World");
|
||||
WorldParser parser = new WorldParser();
|
||||
parser.Parse(caller, args);
|
||||
}
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.*;
|
||||
import nautilus.game.arcade.events.*;
|
||||
import nautilus.game.arcade.game.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
|
||||
import nautilus.game.arcade.game.games.sneakyassassins.powerups.*;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.*;
|
||||
@ -70,6 +72,7 @@ public class SneakyAssassins extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerAttackWithSword(EntityDamageByEntityEvent event)
|
||||
{
|
||||
@ -91,4 +94,26 @@ public class SneakyAssassins extends SoloGame
|
||||
|
||||
event.setDamage(damage);
|
||||
}
|
||||
*/
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerAttackWithSword(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
if (damager == null)
|
||||
return;
|
||||
|
||||
if (!IsAlive(damager))
|
||||
return;
|
||||
|
||||
if (damager.getItemInHand() == null)
|
||||
return;
|
||||
|
||||
Double damage = SWORD_DAMAGE.get(damager.getItemInHand().getType());
|
||||
|
||||
if (damage == null)
|
||||
return;
|
||||
|
||||
event.AddMod(GetName(), "Sword Damage", damage - event.GetDamage(), false);
|
||||
}
|
||||
}
|
||||
|
@ -1,439 +0,0 @@
|
||||
package nautilus.game.arcade.world;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
public class WorldParser
|
||||
{
|
||||
public void Parse(Player caller, String[] args)
|
||||
{
|
||||
HashSet<Integer> dataId = new HashSet<Integer>();
|
||||
|
||||
if (args != null)
|
||||
for (String arg : args)
|
||||
{
|
||||
try
|
||||
{
|
||||
dataId.add(Integer.parseInt(arg));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
caller.sendMessage("Invalid Data ID: " + arg);
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, ArrayList<Location>> TeamLocs = new HashMap<String, ArrayList<Location>>();
|
||||
HashMap<String, ArrayList<Location>> DataLocs = new HashMap<String, ArrayList<Location>>();
|
||||
HashMap<String, ArrayList<Location>> CustomLocs = new HashMap<String, ArrayList<Location>>();
|
||||
|
||||
Location cornerA = null;
|
||||
Location cornerB = null;
|
||||
|
||||
int processed = 0;
|
||||
|
||||
caller.sendMessage("Scanning for Blocks...");
|
||||
for (int x=-600 ; x < 600 ; x++)
|
||||
for (int z=-600 ; z < 600 ; z++)
|
||||
for (int y=0 ; y < 256 ; y++)
|
||||
{
|
||||
processed++;
|
||||
if (processed % 20000000 == 0)
|
||||
caller.sendMessage("Processed: " + processed);
|
||||
|
||||
Block block = caller.getWorld().getBlockAt(caller.getLocation().getBlockX()+x, caller.getLocation().getBlockY()+y, caller.getLocation().getBlockZ()+z);
|
||||
|
||||
//ID DATA
|
||||
if (dataId.contains(block.getTypeId()))
|
||||
{
|
||||
String key = ""+block.getTypeId();
|
||||
|
||||
if (!CustomLocs.containsKey(key))
|
||||
CustomLocs.put(key, new ArrayList<Location>());
|
||||
|
||||
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)
|
||||
{
|
||||
Sign s = (Sign) block.getState();
|
||||
|
||||
String name = "";
|
||||
|
||||
try
|
||||
{
|
||||
name = s.getLine(0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
caller.sendMessage("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
|
||||
if (block.getTypeId() == 147)
|
||||
{
|
||||
Block wool = block.getRelative(BlockFace.DOWN);
|
||||
if (wool == null)
|
||||
continue;
|
||||
|
||||
if (wool.getType() == Material.WOOL)
|
||||
{
|
||||
if (wool.getData() == 14) //RED > Spawn
|
||||
{
|
||||
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() == 4) //RED > Spawn
|
||||
{
|
||||
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() == 13) //RED > Spawn
|
||||
{
|
||||
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() == 11) //RED > Spawn
|
||||
{
|
||||
if (!TeamLocs.containsKey("Blue"))
|
||||
TeamLocs.put("Blue", new ArrayList<Location>());
|
||||
|
||||
TeamLocs.get("Blue").add(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() == 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() == 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 (wool.getData() == 0) //WHITE > Corner
|
||||
{
|
||||
if (cornerA == null) cornerA = wool.getLocation();
|
||||
else if (cornerB == null) cornerB = wool.getLocation();
|
||||
else caller.sendMessage("More than 2 Corner Locations found!");
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
if (cornerA == null || cornerB == null)
|
||||
{
|
||||
caller.sendMessage("Missing Corner Locations!");
|
||||
return;
|
||||
}
|
||||
|
||||
//Save
|
||||
try
|
||||
{
|
||||
FileWriter fstream = new FileWriter(caller.getWorld().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)
|
||||
{
|
||||
caller.sendMessage("Error: File Write Error");
|
||||
}
|
||||
|
||||
|
||||
caller.sendMessage("World Data Saved.");
|
||||
}
|
||||
|
||||
public String LocationsToString(ArrayList<Location> locs)
|
||||
{
|
||||
String out = "";
|
||||
|
||||
for (Location loc : locs)
|
||||
out += loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ":";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public String LocationSignsToString(HashMap<Location, String> locs)
|
||||
{
|
||||
String out = "";
|
||||
|
||||
for (Location loc : locs.keySet())
|
||||
out += locs.get(loc) + "@" + loc.getBlockX() + "," + loc.getBlockY() + "," + loc.getBlockZ() + ":";
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user