Champs Balance Update
Map Parser Update
This commit is contained in:
parent
ce8560bdbf
commit
62f6ea815d
@ -1,53 +1,50 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
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;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.fusesource.jansi.Ansi.Color;
|
||||
|
||||
public class MapParser extends JavaPlugin implements Listener
|
||||
{
|
||||
private WorldManager _worldManager;
|
||||
|
||||
private Parse _curParse = null;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
_worldManager = new WorldManager(this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,11 +54,44 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Command(PlayerCommandPreprocessEvent event)
|
||||
public void PlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getMessage().toLowerCase().startsWith("/copyschematics"))
|
||||
player.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
|
||||
|
||||
DisplayHelp(player);
|
||||
}
|
||||
|
||||
public void DisplayHelp(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
|
||||
UtilPlayer.message(player, F.value("/hub", "Return to hub world"));
|
||||
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"));
|
||||
}
|
||||
|
||||
@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!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMessage().toLowerCase().startsWith("/help"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
DisplayHelp(caller);
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/copyschematics"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -70,510 +100,219 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
FileUtils.copyDirectory(new File(".." + File.separator + "Build-1" + File.separator + "plugins" + File.separator + "WorldEdit" + File.separator + "schematics"),
|
||||
new File("plugins" + File.separator + "WorldEdit" + File.separator + "schematics"));
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Schematics Copied."));
|
||||
UtilPlayer.message(caller, F.main("Parser", "Schematics Copied."));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Schematics Copy Failed! Contact Jonalon."));
|
||||
UtilPlayer.message(caller, F.main("Parser", "Schematics Copy Failed! Contact Jonalon."));
|
||||
}
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/createmap"))
|
||||
else if (event.getMessage().toLowerCase().startsWith("/create"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Creating World: " + F.elem(args[0])));
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(args[0]);
|
||||
UtilPlayer.message(caller, F.main("Parser", "Creating World: " + F.elem(worldName)));
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(worldName);
|
||||
worldCreator.environment(Environment.NORMAL);
|
||||
worldCreator.type(WorldType.FLAT);
|
||||
worldCreator.generateStructures(false);
|
||||
|
||||
World world = Bukkit.getServer().createWorld(worldCreator);
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Teleporting to World: " + F.elem(args[0])));
|
||||
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
|
||||
|
||||
event.getPlayer().teleport(new Location(world, 0, 100, 0));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/loadmap"))
|
||||
else if (event.getMessage().toLowerCase().startsWith("/delete"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Loading World: " + F.elem(args[0])));
|
||||
String worldName = "map_" + args[0];
|
||||
|
||||
World world = _worldManager.loadPendingParse(event.getPlayer(), args[0]);
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Teleporting to World: " + F.elem(args[0])));
|
||||
|
||||
event.getPlayer().teleport(new Location(world, 0, 100, 0));
|
||||
if (!DoesMapExist(worldName))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "World does not exist: " + F.elem(worldName)));
|
||||
return;
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/listmaps"))
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//Delete
|
||||
FileUtils.deleteQuietly(new File(worldName));
|
||||
|
||||
Inform(caller, "Deleted World: " + F.elem(args[0]));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/hub"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(player, F.main("Parser", "Listing Worlds;"));
|
||||
event.getPlayer().teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/map"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
_worldManager.listPendingParses(event.getPlayer());
|
||||
String[] args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "Map Doesn't Exist!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Error (This should not occur!)
|
||||
if (world == null)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Parser", "Null World Error: " + F.elem(worldName)));
|
||||
return;
|
||||
}
|
||||
|
||||
//Teleport
|
||||
UtilPlayer.message(caller, F.main("Parser", "Teleporting to World: " + F.elem(worldName)));
|
||||
|
||||
event.getPlayer().teleport(new Location(world, 0, 100, 0));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/list"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(caller, F.main("Parser", "Listing Maps;"));
|
||||
|
||||
File mapsFolder = new File(".");
|
||||
for (File file : mapsFolder.listFiles())
|
||||
{
|
||||
if (!file.isDirectory())
|
||||
continue;
|
||||
|
||||
if (!file.getName().toLowerCase().startsWith("map_"))
|
||||
continue;
|
||||
|
||||
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(" ");
|
||||
|
||||
String gameType = args[0];
|
||||
|
||||
try
|
||||
{
|
||||
GameType type = GameType.valueOf(gameType);
|
||||
GameType.valueOf(gameType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Invalid gametype!");
|
||||
event.getPlayer().sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Available games:");
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Valid Game Types;"));
|
||||
|
||||
String gameTypes = "";
|
||||
|
||||
for (GameType game : GameType.values())
|
||||
{
|
||||
event.getPlayer().sendMessage(game.toString());
|
||||
gameTypes += game.toString() + " ";
|
||||
}
|
||||
|
||||
event.getPlayer().sendMessage(gameTypes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = event.getMessage().replace(gameType, "").toLowerCase();
|
||||
|
||||
World world = player.getWorld();
|
||||
World world = caller.getWorld();
|
||||
|
||||
// TODO teleport player to main world
|
||||
player.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
|
||||
//Teleport Players Out
|
||||
for (Player worldPlayer : world.getPlayers())
|
||||
{
|
||||
worldPlayer.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "World " + F.elem(world.getName()) + " is preparing to be parsed."));
|
||||
}
|
||||
|
||||
//Unload World > Copy
|
||||
String worldName = _worldManager.prepMapParse(world);
|
||||
|
||||
World parseableWorld = Bukkit.getWorld(worldName);
|
||||
|
||||
Parse(event.getPlayer(), parseableWorld, msg.split(" "));
|
||||
|
||||
_worldManager.finalizeParsedWorld(gameType, parseableWorld);
|
||||
}
|
||||
}
|
||||
|
||||
public void Parse(Player caller, World world, String[] args)
|
||||
if (worldName == null)
|
||||
{
|
||||
HashSet<Integer> dataId = new HashSet<Integer>();
|
||||
|
||||
for (String arg : args)
|
||||
{
|
||||
if (arg.equals("/parse"))
|
||||
continue;
|
||||
|
||||
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 + " of " + (1200*1200*256));
|
||||
|
||||
Block block = world.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 + 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();
|
||||
else if (cornerB == null) cornerB = wool.getLocation();
|
||||
else
|
||||
{
|
||||
caller.sendMessage("More than 2 Corner Markers:");
|
||||
caller.sendMessage("Corner A: " + cornerA);
|
||||
caller.sendMessage("Corner B: " + cornerB);
|
||||
caller.sendMessage("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)
|
||||
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!");
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Could not prepare world for parsing!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Save
|
||||
try
|
||||
{
|
||||
FileWriter fstream = new FileWriter(world.getName() + File.separator + "WorldConfig.dat");
|
||||
BufferedWriter out = new BufferedWriter(fstream);
|
||||
//World to be Parsed
|
||||
World parseableWorld = Bukkit.getWorld(worldName);
|
||||
|
||||
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");
|
||||
//Parse the World
|
||||
Parse(event.getPlayer(), parseableWorld, msg.split(" "), parseLoc);
|
||||
|
||||
//Finalize and Save to Zip
|
||||
_worldManager.finalizeParsedWorld(gameType, parseableWorld);
|
||||
}
|
||||
else
|
||||
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
|
||||
{
|
||||
out.write("MIN_Y:"+Math.min(cornerA.getBlockY(), cornerB.getBlockY()));
|
||||
out.write("\n");
|
||||
out.write("MAX_Y:"+Math.max(cornerA.getBlockY(), cornerB.getBlockY()));
|
||||
event.setCancelled(true);
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Listing Active Worlds;"));
|
||||
|
||||
for (World world : this.getServer().getWorlds())
|
||||
{
|
||||
event.getPlayer().sendMessage(world.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Teams
|
||||
for (String team : TeamLocs.keySet())
|
||||
public void Parse(Player caller, World world, String[] args, Location loc)
|
||||
{
|
||||
out.write("\n");
|
||||
out.write("\n");
|
||||
out.write("TEAM_NAME:" + team);
|
||||
out.write("\n");
|
||||
out.write("TEAM_SPAWNS:" + LocationsToString(TeamLocs.get(team)));
|
||||
_curParse = new Parse(this, world, args, caller, loc);
|
||||
}
|
||||
|
||||
//Data
|
||||
for (String data : DataLocs.keySet())
|
||||
@EventHandler
|
||||
public void ParseUpdate(TickEvent event)
|
||||
{
|
||||
out.write("\n");
|
||||
out.write("\n");
|
||||
out.write("DATA_NAME:" + data);
|
||||
out.write("\n");
|
||||
out.write("DATA_LOCS:" + LocationsToString(DataLocs.get(data)));
|
||||
}
|
||||
if (_curParse == null)
|
||||
return;
|
||||
|
||||
//Custom
|
||||
for (String data : CustomLocs.keySet())
|
||||
if (_curParse.Update())
|
||||
{
|
||||
out.write("\n");
|
||||
out.write("\n");
|
||||
out.write("CUSTOM_NAME:" + data);
|
||||
out.write("\n");
|
||||
out.write("CUSTOM_LOCS:" + LocationsToString(CustomLocs.get(data)));
|
||||
_curParse = null;
|
||||
|
||||
Announce("Parse Completed!");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -595,4 +334,47 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
if (!event.getPlayer().isOp())
|
||||
event.getPlayer().setOp(true);
|
||||
}
|
||||
|
||||
public void Announce(String msg)
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.sendMessage(C.cGold + msg);
|
||||
|
||||
System.out.println("[Announce] " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
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(".");
|
||||
for (File file : mapsFolder.listFiles())
|
||||
{
|
||||
if (!file.isDirectory())
|
||||
continue;
|
||||
|
||||
if (file.getName().equals(name))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public World GetMapWorld(String name)
|
||||
{
|
||||
for (World world : this.getServer().getWorlds())
|
||||
{
|
||||
if (world.getName().equals(name))
|
||||
return world;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
472
Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java
Normal file
472
Plugins/Mineplex.MapParser/src/mineplex/mapparser/Parse.java
Normal file
@ -0,0 +1,472 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
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.F;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
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 Parse
|
||||
{
|
||||
//Parse Data
|
||||
private MapParser Host;
|
||||
private World _world;
|
||||
private String[] _args;
|
||||
private Player _caller;
|
||||
private Location _callLoc;
|
||||
private int _size = 400;
|
||||
private int y = 0;
|
||||
|
||||
//World Data
|
||||
private HashSet<Integer> _dataId = new HashSet<Integer>();
|
||||
private HashMap<String, ArrayList<Location>> _teamLocs = new HashMap<String, ArrayList<Location>>();
|
||||
private HashMap<String, ArrayList<Location>> _dataLocs = new HashMap<String, ArrayList<Location>>();
|
||||
private HashMap<String, ArrayList<Location>> _customLocs = new HashMap<String, ArrayList<Location>>();
|
||||
|
||||
private Location _cornerA = null;
|
||||
private Location _cornerB = null;
|
||||
|
||||
private int _processed = 0;
|
||||
|
||||
public Parse(MapParser host, World world, String[] args, Player caller, Location loc)
|
||||
{
|
||||
Host = host;
|
||||
|
||||
_world = world;
|
||||
_args = args;
|
||||
_callLoc = loc;
|
||||
Host.Announce("Parse Called: " + F.elem(caller.getName()));
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
Host.Announce("Commencing Parse of World: " + F.elem(_world.getName()));
|
||||
|
||||
//Take BlockID Arguments
|
||||
for (String arg : _args)
|
||||
{
|
||||
if (arg.equals("/parse"))
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
_dataId.add(Integer.parseInt(arg));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_caller.sendMessage("Invalid Data ID: " + arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean Update()
|
||||
{
|
||||
for (int x=-_size ; x < _size ; x++)
|
||||
for (int z=-_size ; 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()))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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();
|
||||
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()));
|
||||
}
|
||||
|
||||
//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)
|
||||
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++;
|
||||
|
||||
//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.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class TickEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Ticker implements Runnable
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
|
||||
public Ticker(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_plugin.getServer().getScheduler().scheduleSyncRepeatingTask(_plugin, this, 0L, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_plugin.getServer().getPluginManager().callEvent(new TickEvent());
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
@ -13,53 +12,23 @@ import net.minecraft.util.org.apache.commons.io.FileUtils;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class WorldManager
|
||||
{
|
||||
private JavaPlugin _plugin;
|
||||
private File _pendingParseDirectory = new File("pendingParses");
|
||||
|
||||
public WorldManager(JavaPlugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
if (!_pendingParseDirectory.exists())
|
||||
_pendingParseDirectory.mkdirs();
|
||||
}
|
||||
|
||||
public void listPendingParses(Player player)
|
||||
{
|
||||
FilenameFilter statsFilter = new FilenameFilter()
|
||||
{
|
||||
public boolean accept(File paramFile, String paramString)
|
||||
{
|
||||
if (paramString.endsWith("zip"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for (File f : _pendingParseDirectory.listFiles(statsFilter))
|
||||
{
|
||||
player.sendMessage(f.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public World loadPendingParse(Player player, String name)
|
||||
{
|
||||
return WorldUtil.LoadWorld(new WorldCreator(_pendingParseDirectory + File.separator + name));
|
||||
}
|
||||
|
||||
public String prepMapParse(World world)
|
||||
{
|
||||
//Unload World
|
||||
MapUtil.UnloadWorld(_plugin, world);
|
||||
|
||||
//Delete Non-Map Files
|
||||
String[] folders = new File(world.getName()).list();
|
||||
for (String fileName : folders)
|
||||
{
|
||||
@ -75,12 +44,25 @@ public class WorldManager
|
||||
FileUtils.deleteQuietly(new File(world.getName() + File.separator + fileName));
|
||||
}
|
||||
|
||||
ZipUtil.ZipFolders(Paths.get("pendingParses").toAbsolutePath().toString(), world.getName() + ".zip", Arrays.asList(new String[] { world.getName() }), Arrays.asList(new String[] { }));
|
||||
//Copy for Parsing
|
||||
try
|
||||
{
|
||||
//Delete if already exists
|
||||
File destination = new File("parse_" + world.getName());
|
||||
if (destination.exists())
|
||||
FileUtils.deleteQuietly(destination);
|
||||
|
||||
ZipUtil.UnzipToDirectory("pendingParses" + File.separator + world.getName() + ".zip", world.getName() + "_current");
|
||||
WorldUtil.LoadWorld(new WorldCreator(world.getName() + "_current"));
|
||||
FileUtils.copyDirectory(new File(world.getName()), destination);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
return world.getName() + "_current";
|
||||
WorldUtil.LoadWorld(new WorldCreator("parse_" + world.getName()));
|
||||
|
||||
return "parse_" + world.getName();
|
||||
}
|
||||
|
||||
public void finalizeParsedWorld(String gameType, World world)
|
||||
|
@ -101,7 +101,7 @@ public class SilencingArrow extends SkillActive
|
||||
_arrows.add(event.getProjectile());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void Damage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.IsCancelled())
|
||||
|
@ -198,9 +198,6 @@ public class BlockToss extends SkillCharge implements IThrown
|
||||
Factory.Projectile().AddThrow(block, cur, this, -1, true, true, true,
|
||||
null, 0, 0, null, 0, UpdateType.FASTEST, 2.5d);
|
||||
|
||||
//Boost
|
||||
UtilAction.velocity(cur, cur.getLocation().getDirection().multiply(-1), 0.4, false, 0, 0, 1, false);
|
||||
|
||||
//Event
|
||||
UtilServer.getServer().getPluginManager().callEvent(new SkillEvent(cur, GetName(), ClassType.Brute));
|
||||
}
|
||||
|
@ -32,12 +32,13 @@ public class Bloodlust extends Skill
|
||||
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"When an enemy dies within #4#4 blocks,",
|
||||
"When an enemy dies within #8#2 blocks,",
|
||||
"you go into a Bloodlust, receiving",
|
||||
"Speed 1 and Strength 1 for #4#2 seconds.",
|
||||
"You also heal healing #2#1 health.",
|
||||
"",
|
||||
"Bloodlust can stack up to 3 times,",
|
||||
"boosting the level of Strength."
|
||||
"boosting the level of Speed by 1."
|
||||
});
|
||||
}
|
||||
|
||||
@ -79,8 +80,10 @@ public class Bloodlust extends Skill
|
||||
_time.put(cur, (System.currentTimeMillis() + (long)(dur*1000)));
|
||||
|
||||
//Condition
|
||||
Factory.Condition().Factory().Speed(GetName(), cur, event.GetEvent().getEntity(), dur, 0, false, true, true);
|
||||
Factory.Condition().Factory().Strength(GetName(), cur, event.GetEvent().getEntity(), dur, str, false, true, true);
|
||||
Factory.Condition().Factory().Speed(GetName(), cur, event.GetEvent().getEntity(), dur, str, false, true, true);
|
||||
Factory.Condition().Factory().Strength(GetName(), cur, event.GetEvent().getEntity(), dur, 0, false, true, true);
|
||||
|
||||
UtilPlayer.health(cur, 2 + level);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(cur, F.main(GetClassType().name(), "You entered " + F.skill(GetName(level)) + " at " + F.elem("Level " + (str+1)) + "."));
|
||||
|
@ -42,7 +42,7 @@ public class HoldPosition extends SkillActive
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"Hold your position, gaining",
|
||||
"Protection 4, Slow 3 and no",
|
||||
"Protection 3, Slow 3 and no",
|
||||
"knockback for #3#1 seconds."
|
||||
});
|
||||
}
|
||||
@ -66,7 +66,7 @@ public class HoldPosition extends SkillActive
|
||||
|
||||
//Action
|
||||
Factory.Condition().Factory().Slow(GetName(), player, player, duration, 2, false, true, false, true);
|
||||
Factory.Condition().Factory().Protection(GetName(), player, player, duration, 3, false, true, true);
|
||||
Factory.Condition().Factory().Protection(GetName(), player, player, duration, 2, false, true, true);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill(GetName(level)) + "."));
|
||||
|
@ -91,7 +91,7 @@ public class GlacialBlade extends SkillActive implements IThrown
|
||||
|
||||
//Damage
|
||||
Factory.Damage().NewDamageEvent(target, data.GetThrower(), null,
|
||||
DamageCause.CUSTOM, 4, true, true, false,
|
||||
DamageCause.CUSTOM, 4, false, true, false,
|
||||
UtilEnt.getName(data.GetThrower()), GetName());
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class Agility extends SkillActive
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"Sprint with great agility, gaining",
|
||||
"Speed I for #2#2 seconds. You are",
|
||||
"Speed I for #2#1 seconds. You are",
|
||||
"immune to damage while sprinting.",
|
||||
"",
|
||||
"Agility ends if you interact."
|
||||
|
@ -22,8 +22,7 @@ public class BarbedArrows extends Skill
|
||||
{
|
||||
"Your arrows are barbed, and give",
|
||||
"opponents Slow 1 for #2#1 seconds.",
|
||||
"If opponent is sprinting, they",
|
||||
"receive Slow 3 instead.",
|
||||
"Will cancel sprint on opponents.",
|
||||
"",
|
||||
"Duration scales with arrow velocity."
|
||||
});
|
||||
@ -54,16 +53,13 @@ public class BarbedArrows extends Skill
|
||||
Player damageePlayer = event.GetDamageePlayer();
|
||||
|
||||
//Action
|
||||
int str = 0;
|
||||
if (damageePlayer != null)
|
||||
if (damageePlayer.isSprinting())
|
||||
str = 3;
|
||||
damageePlayer.setSprinting(false);
|
||||
|
||||
//Damage
|
||||
event.AddMod(damager.getName(), GetName(), 0, false);
|
||||
|
||||
//Condition
|
||||
Factory.Condition().Factory().Slow(GetName(), damagee, damager, (projectile.getVelocity().length() / 3) * (2 + level), str, false, true, true, true);
|
||||
Factory.Condition().Factory().Slow(GetName(), damagee, damager, (projectile.getVelocity().length() / 3) * (2 + level), 0, false, true, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,7 +63,7 @@ public class HeavyArrows extends Skill
|
||||
{
|
||||
double vel = (event.getProjectile().getVelocity().length() * (0.1 + 0.1 * level));
|
||||
UtilAction.velocity(player, player.getLocation().getDirection().multiply(-1), vel,
|
||||
false, 0, 0.2, 0.8, true);
|
||||
false, 0, 0.2, 0.6, true);
|
||||
}
|
||||
|
||||
//Decrease Speed
|
||||
|
@ -40,14 +40,14 @@ public class Overcharge extends SkillChargeBow
|
||||
"",
|
||||
GetChargeString(),
|
||||
"",
|
||||
"Deals up to #1#1 bonus damage."
|
||||
"Deals up to #0#1 bonus damage."
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DoSkillCustom(Player player, float charge, Arrow arrow)
|
||||
{
|
||||
double damage = charge * (1 + 1 * getLevel(player));
|
||||
double damage = charge * (getLevel(player));
|
||||
_arrows.put(arrow, damage);
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,9 @@ public class VitalitySpores extends Skill
|
||||
|
||||
SetDesc(new String[]
|
||||
{
|
||||
"After #12#-2 seconds of not taking damage,",
|
||||
"After #14#-2 seconds of not taking damage,",
|
||||
"forest spores surround you, giving",
|
||||
"you Regeneration 1 for #3#2 seconds.",
|
||||
"you Regeneration 1 for #2#2 seconds.",
|
||||
"",
|
||||
"This remains until you take damage."
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ public class WolfsPounce extends SkillChargeSword
|
||||
"",
|
||||
"Colliding with another player",
|
||||
"mid-air deals #1#1 damage and",
|
||||
"Slow 2 for #2.5#0.5 seconds."
|
||||
"Slow 2 for 3 seconds."
|
||||
|
||||
});
|
||||
}
|
||||
@ -129,7 +129,7 @@ public class WolfsPounce extends SkillChargeSword
|
||||
damager.getName(), GetName());
|
||||
|
||||
//Conditions
|
||||
Factory.Condition().Factory().Slow(GetName(), damagee, damagee, 2.5 + 0.5 * level, 1, false, true, true, true);
|
||||
Factory.Condition().Factory().Slow(GetName(), damagee, damagee, 3, 1, false, true, true, true);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(damager, F.main(GetClassType().name(), "You hit " + F.name(UtilEnt.getName(damagee)) + " with " + F.skill(GetName(level)) + "."));
|
||||
|
@ -183,7 +183,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new Leap(this, "Leap", ClassType.Assassin, SkillType.Axe,
|
||||
1, 4,
|
||||
40, -2,
|
||||
11500, -1500, true,
|
||||
10500, -1500, true,
|
||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||
|
||||
@ -442,7 +442,7 @@ public class SkillFactory extends MiniPlugin implements ISkillFactory
|
||||
AddSkill(new WolfsFury(this, "Wolfs Fury", ClassType.Ranger, SkillType.Axe,
|
||||
1, 4,
|
||||
0, 0,
|
||||
20000, 2000, true,
|
||||
18000, 2000, true,
|
||||
new Material[] {Material.IRON_AXE, Material.GOLD_AXE, Material.DIAMOND_AXE},
|
||||
new Action[] {Action.RIGHT_CLICK_AIR, Action.RIGHT_CLICK_BLOCK}));
|
||||
|
||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -13,9 +15,11 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.ItemDespawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.elo.EloPlayer;
|
||||
import mineplex.core.elo.EloTeam;
|
||||
@ -402,4 +406,11 @@ public class Domination extends TeamGame
|
||||
GetStats(damagee).DamageTaken += event.GetDamage();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void UsableInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,14 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -365,4 +368,11 @@ public class TeamDeathmatch extends TeamGame
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void UsableInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (UtilBlock.usable(event.getClickedBlock()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ public class UHC extends TeamGame
|
||||
continue;
|
||||
|
||||
|
||||
UtilParticle.PlayParticle(player, ParticleType.EXPLODE, block.getLocation(), (float)Math.random(), (float)Math.random(), (float)Math.random(), 0, 1);
|
||||
UtilParticle.PlayParticle(player, ParticleType.LARGE_EXPLODE, block.getLocation(), (float)Math.random(), (float)Math.random(), (float)Math.random(), 0, 1);
|
||||
|
||||
player.playSound(block.getLocation(), Sound.FIZZ, 0.1f, 0.1f);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user