MapParser refactoring/changes

This commit is contained in:
Shaun Bennett 2014-08-16 15:50:33 -05:00
parent 4193ee53ea
commit eac0f9fd6a
22 changed files with 1255 additions and 520 deletions

View File

@ -9,6 +9,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Mineplex.Core.Common" />
<orderEntry type="library" name="craftbukkit" level="project" />
<orderEntry type="library" name="commons-io" level="project" />
</component>
</module>

View File

@ -47,7 +47,8 @@ public enum GameType
Tug("Tug of Wool"),
TurfWars("Turf Wars"),
UHC("Ultra Hardcore"),
ZombieSurvival("Zombie Survival");
ZombieSurvival("Zombie Survival"),
None("None");
String _name;
String _lobbyName;
@ -73,4 +74,18 @@ public enum GameType
{
return _lobbyName;
}
public static GameType match(String string)
{
GameType gameType = null;
string = string.toLowerCase();
for (GameType type : values())
{
if (type.name().toLowerCase().startsWith(string) || type.GetName().toLowerCase().startsWith(string))
{
gameType = type;
}
}
return gameType;
}
}

View File

@ -15,7 +15,7 @@ public class MapData
{
public String MapFolder;
public String GameType = "null";
public GameType GameType = null;
public String MapName = "null";
public String MapCreator = "null";
@ -66,7 +66,7 @@ public class MapData
}
else if (tokens[0].equalsIgnoreCase("GAME_TYPE"))
{
GameType = tokens[1];
GameType = GameType.valueOf(tokens[1] == null ? "Null" : tokens[1]);
}
else if (tokens[0].equalsIgnoreCase("WHITE_LIST"))
{
@ -134,4 +134,9 @@ public class MapData
{
return BuildList.contains(player.getName()) || WhiteList.contains(player.getName()) || player.isOp();
}
public boolean CanRename(Player player)
{
return true;
}
}

View File

@ -2,7 +2,11 @@ package mineplex.mapparser;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -10,17 +14,13 @@ 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 mineplex.mapparser.command.*;
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.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -45,8 +45,8 @@ public class MapParser extends JavaPlugin implements Listener
private WorldManager _worldManager;
private Parse _curParse = null;
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
@Override
public void onEnable()
@ -59,6 +59,22 @@ public class MapParser extends JavaPlugin implements Listener
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
_commands.add(new AuthorCommand(this));
_commands.add(new BuildCommand(this));
_commands.add(new CopySchematicsCommand(this));
_commands.add(new CreateCommand(this));
_commands.add(new DeleteCommand(this));
_commands.add(new GameTypeCommand(this));
_commands.add(new HubCommand(this));
_commands.add(new JoinCommand(this));
_commands.add(new ListCommand(this));
_commands.add(new MapCommand(this));
_commands.add(new NameCommand(this));
_commands.add(new ParseCommand(this));
_commands.add(new RenameCommand(this));
_commands.add(new SaveCommand(this));
_commands.add(new WorldsCommand(this));
}
@Override
@ -82,11 +98,12 @@ public class MapParser extends JavaPlugin implements Listener
public void DisplayHelp(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Listing Commands;"));
UtilPlayer.message(player, F.value("Parameters", "Parameters: <?> = Required, [?] = Optional"));
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("/create <name> [gametype]", "Creates a new map"));
UtilPlayer.message(player, F.value("/delete <name> [gametype]", "Deletes an existing map"));
UtilPlayer.message(player, F.value("/map <name> [gametype]", "Teleport to a map"));
UtilPlayer.message(player, F.value("/list", "List maps"));
UtilPlayer.message(player, F.value("/parse", "Parse your current map!"));
UtilPlayer.message(player, " ");
@ -95,7 +112,7 @@ public class MapParser extends JavaPlugin implements Listener
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"));
UtilPlayer.message(player, F.value("/gametype <type>", "Set gametype for current map"));
UtilPlayer.message(player, " ");
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
@ -104,508 +121,57 @@ public class MapParser extends JavaPlugin implements Listener
@EventHandler
public void Command(PlayerCommandPreprocessEvent event)
{
Player caller = event.getPlayer();
Player player = event.getPlayer();
String[] parts = event.getMessage().split(" ");
String commandLabel = parts[0].substring(1);
String[] args = new String[parts.length - 1];
System.arraycopy(parts, 1, args, 0, parts.length - 1);
if (_curParse != null)
{
UtilPlayer.message(caller, F.main("Parse", "Cannot use commands during Map Parse!"));
UtilPlayer.message(player, F.main("Parser", "Cannot use commands during Map Parse!"));
return;
}
if (event.getMessage().toLowerCase().startsWith("/help"))
{
event.setCancelled(true);
DisplayHelp(caller);
DisplayHelp(player);
}
else if (event.getMessage().toLowerCase().startsWith("/copyschematics"))
{
event.setCancelled(true);
try
{
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(caller, F.main("Parser", "Schematics Copied."));
}
catch (IOException e)
{
e.printStackTrace();
UtilPlayer.message(caller, F.main("Parser", "Schematics Copy Failed! Contact Jonalon."));
}
}
else if (event.getMessage().toLowerCase().startsWith("/create"))
{
event.setCancelled(true);
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);
worldCreator.environment(Environment.NORMAL);
worldCreator.type(WorldType.FLAT);
worldCreator.generateStructures(false);
World world = Bukkit.getServer().createWorld(worldCreator);
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"))
for (BaseCommand command : _commands)
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
for (String alias : command.getAliases())
{
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))
{
UtilPlayer.message(caller, F.main("Parser", "Map does not exist: " + F.elem(worldName)));
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);
//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));
Announce("Deleted World: " + F.elem(args[0]));
}
else if (event.getMessage().toLowerCase().startsWith("/save"))
{
event.setCancelled(true);
if (event.getMessage().split(" ").length < 2)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/save <MapName>")));
return;
}
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()))
if (alias.equalsIgnoreCase(commandLabel))
{
UtilPlayer.message(caller, F.main("Parser", "You do not have Build-Access on this Map."));
if (!command.execute(player, commandLabel, args))
{
UtilPlayer.message(player, F.main("Parser", "Invalid Input. " + command.getUsage()));
}
event.setCancelled(true);
return;
}
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
//Unload World
MapUtil.UnloadWorld(this, world, true);
}
else
{
UtilPlayer.message(caller, F.main("Parser", "World is not loaded: " + F.elem(worldName)));
return;
}
Announce("Saved World: " + F.elem(args[0]));
}
else if (event.getMessage().toLowerCase().startsWith("/hub"))
{
event.setCancelled(true);
event.getPlayer().teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
}
else if (event.getMessage().toLowerCase().startsWith("/map"))
{
event.setCancelled(true);
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);
if (world == null)
{
if (DoesMapExist(worldName))
{
world = Bukkit.createWorld(new WorldCreator(worldName));
}
else
{
UtilPlayer.message(caller, F.main("Parser", "Map Not Found: " + F.elem(worldName)));
return;
}
}
//Error (This should not occur!)
if (world == null)
{
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)));
event.getPlayer().teleport(new Location(world, 0, 100, 0));
MapData data = GetData(worldName);
UtilPlayer.message(event.getPlayer(), F.value("Map Name", data.MapName));
UtilPlayer.message(event.getPlayer(), F.value("Author", data.MapCreator));
UtilPlayer.message(event.getPlayer(), F.value("Game Type", data.GameType));
}
else if (event.getMessage().toLowerCase().startsWith("/list"))
{
event.setCancelled(true);
UtilPlayer.message(caller, F.main("Parser", "Listing Maps;"));
String maps = "";
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File(".");
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (!file.getName().toLowerCase().startsWith("map_"))
continue;
maps += color + file.getName().substring(4) + " ";
if (color == ChatColor.YELLOW)
color = ChatColor.GOLD;
else
color = ChatColor.YELLOW;
}
event.getPlayer().sendMessage(maps);
}
else if (event.getMessage().toLowerCase().startsWith("/parse"))
{
event.setCancelled(true);
Location parseLoc = event.getPlayer().getLocation();
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())
{
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
World parseableWorld = _worldManager.prepMapParse(world);
if (parseableWorld == null)
{
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Could not prepare world for parsing!"));
return;
}
//Parse the World
_curParse = new Parse(this, parseableWorld, event.getMessage().split(" "), parseLoc, GetData(parseLoc.getWorld().getName()));
}
else if (event.getMessage().toLowerCase().startsWith("/worlds"))
{
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Parser", "Listing Active Worlds;"));
for (World world : this.getServer().getWorlds())
{
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) + ")");
}
}
}
}
public void sendValidGameTypes(Player player)
{
UtilPlayer.message(player, F.main("Parser", "Valid Game Types;"));
String gameTypes = "";
for (GameType game : GameType.values())
{
gameTypes += game.toString() + " ";
}
player.sendMessage(gameTypes);
}
@EventHandler
public void ParseUpdate(TickEvent event)
{
@ -688,7 +254,7 @@ public class MapParser extends JavaPlugin implements Listener
if (world.getName().startsWith("parse_"))
continue;
if (!world.getName().startsWith("map_"))
if (!world.getName().startsWith("map"))
continue;
if (world.getPlayers().isEmpty())
@ -709,31 +275,98 @@ public class MapParser extends JavaPlugin implements Listener
}
}
public boolean DoesMapExist(String name)
public boolean DoesMapExist(String mapName, GameType gameType)
{
File mapsFolder = new File(".");
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (file.getName().equals(name))
return true;
}
return DoesMapExist(getWorldString(mapName, gameType));
}
public boolean DoesMapExist(String worldName)
{
File file = new File(worldName);
if (file.exists() && file.isDirectory())
return true;
return false;
}
public World GetMapWorld(String name)
public String getShortWorldName(String worldName)
{
int lastIndexOfSeperator = worldName.lastIndexOf('/');
if (lastIndexOfSeperator != -1)
return worldName.substring(lastIndexOfSeperator + 1);
return worldName;
}
public World GetMapWorld(String mapName, GameType gameType)
{
return GetMapWorld(getWorldString(mapName, gameType));
}
public World GetMapWorld(String worldName)
{
for (World world : this.getServer().getWorlds())
{
if (world.getName().equals(name))
if (world.getName().equals(worldName))
return world;
}
return null;
}
public String getWorldString(String worldName, GameType type)
{
return "map" + "/" + type.GetName() + "/" + worldName;
}
public List<String> getMapsByName(String name)
{
name = name.toLowerCase();
List<String> maps = new LinkedList<String>();
boolean matchesExact = false;
for (GameType type : GameType.values())
{
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File("map" + File.separator + type.GetName());
if (!mapsFolder.exists())
continue;
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
if (!file.getName().toLowerCase().contains(name))
continue;
if (file.getName().equalsIgnoreCase(name))
matchesExact = true;
maps.add(getWorldString(file.getName(), type));
}
}
if (matchesExact)
{
Iterator<String> it = maps.iterator();
while (it.hasNext())
{
String mapString = it.next();
if (!mapString.toLowerCase().endsWith(name))
{
it.remove();
}
}
}
return maps;
}
public MapData GetData(String mapName)
{
@ -756,13 +389,25 @@ public class MapParser extends JavaPlugin implements Listener
player.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
player.getInventory().addItem(new ItemStack(Material.STONE_AXE));
}
public WorldManager getWorldManager()
{
return _worldManager;
}
public void setCurrentParse(Parse parse)
{
_curParse = parse;
}
@EventHandler
public void Chat(AsyncPlayerChatEvent event)
{
event.setCancelled(true);
String world = C.cDGreen + C.Bold + event.getPlayer().getWorld().getName();
String world = C.cDGreen + C.Bold + getShortWorldName(event.getPlayer().getWorld().getName());
String name = C.cYellow + event.getPlayer().getName();
if (GetData(event.getPlayer().getWorld().getName()).CanBuild(event.getPlayer()))

View File

@ -71,9 +71,6 @@ public class Parse
//Take BlockID Arguments
for (String arg : _args)
{
if (arg.equals("/parse"))
continue;
try
{
_dataId.add(Integer.parseInt(arg));
@ -509,7 +506,7 @@ public class Parse
return out;
}
public String getGameType()
public GameType getGameType()
{
return _mapData.GameType;
}

View File

@ -102,7 +102,7 @@ public class WorldManager
MapData data = Host.GetData(world.getName().substring(6));
String fileName = data.GameType + "_" + data.MapName + ".zip";
GameType gameType = GameType.valueOf(data.GameType);
GameType gameType = data.GameType;
ZipUtil.ZipFolders(Paths.get(world.getName()).toAbsolutePath().toString(), fileName, dirList, fileList);

View File

@ -0,0 +1,59 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class AuthorCommand extends BaseCommand
{
public AuthorCommand(MapParser plugin)
{
super(plugin, "author");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/author <MapAuthor>"));
return true;
}
String authorName = "";
for (String arg : args)
authorName += arg + " ";
authorName = authorName.trim();
if (world.getName().equals("world"))
{
message(player, "Cannot set author for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
MapData data = getPlugin().GetData(world.getName());
data.MapCreator = authorName;
data.Write();
getPlugin().Announce("Map Author for " + F.elem(world.getName()) + " set to " + F.elem(authorName) + ".");
return true;
}
}

View File

@ -0,0 +1,64 @@
package mineplex.mapparser.command;
import java.util.Arrays;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public abstract class BaseCommand
{
private MapParser _plugin;
private List<String> _aliases;
private String _description = "Null";
private String _usage = "Undefined";
public BaseCommand(MapParser plugin, String... aliases)
{
_plugin = plugin;
_aliases = Arrays.asList(aliases);
}
public abstract boolean execute(Player player, String alias, String[] args);
public String getDescription()
{
return _description;
}
protected void setDescription(String description)
{
_description = description;
}
public String getUsage()
{
return _usage;
}
protected void setUsage(String usage)
{
_usage = usage;
}
public List<String> getAliases()
{
return _aliases;
}
protected MapParser getPlugin()
{
return _plugin;
}
protected void message(Player player, String message)
{
UtilPlayer.message(player, F.main("Parser", message));
}
}

View File

@ -0,0 +1,68 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class BuildCommand extends BaseCommand
{
public BuildCommand(MapParser plugin)
{
super(plugin, "build");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length != 1)
{
message(player, "Invalid Input. " + F.elem("/build <Name>"));
return true;
}
World world = player.getWorld();
if (world.getName().equals("world"))
{
message(player, "Cannot change Build-List for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
Player other = UtilPlayer.searchOnline(player, args[0], true);
if (player != null)
{
MapData data = getPlugin().GetData(world.getName());
if (data.BuildList.contains(other.getName()))
{
data.BuildList.remove(other.getName());
data.Write();
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(false) + ")");
}
else
{
data.BuildList.add(other.getName());
data.Write();
getPlugin().Announce("Build-List for " + F.elem(world.getName()) + " (" + other.getName() + " = " + F.tf(true) + ")");
}
}
return true;
}
}

View File

@ -0,0 +1,40 @@
package mineplex.mapparser.command;
import java.io.File;
import java.io.IOException;
import org.bukkit.entity.Player;
import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils;
/**
* Created by Shaun on 8/16/2014.
*/
public class CopySchematicsCommand extends BaseCommand
{
public CopySchematicsCommand(MapParser plugin)
{
super(plugin, "copyschematics");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
try
{
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"));
message(player, "Schematics Copied.");
}
catch (IOException e)
{
e.printStackTrace();
message(player, "Schematics Copy Failed! Contact Jonalon.");
}
return true;
}
}

View File

@ -0,0 +1,76 @@
package mineplex.mapparser.command;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class CreateCommand extends BaseCommand
{
public CreateCommand(MapParser plugin)
{
super(plugin, "create");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 2)
{
message(player, "Invalid Input. " + F.elem("/create <MapName>"));
return true;
}
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
String worldName = "map/" + gameType.GetName() + "/" + args[0];
if (getPlugin().DoesMapExist(worldName))
{
message(player, "Map name is already in use!");
return true;
}
getPlugin().Announce("Creating World: " + F.elem(worldName));
WorldCreator worldCreator = new WorldCreator(worldName);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.type(WorldType.FLAT);
worldCreator.generateStructures(false);
World world = Bukkit.getServer().createWorld(worldCreator);
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(new Location(world, 0, 100, 0));
//Give Access
MapData mapData = getPlugin().GetData(worldName);
mapData.WhiteList.add(player.getName());
mapData.BuildList.add(player.getName());
mapData.GameType = gameType;
mapData.Write();
return true;
}
}

View File

@ -0,0 +1,84 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
import org.apache.commons.io.FileUtils;
/**
* Created by Shaun on 8/16/2014.
*/
public class DeleteCommand extends BaseCommand
{
public DeleteCommand(MapParser plugin)
{
super(plugin, "delete");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 2)
{
message(player, "Invalid Input. " + F.elem("/delete <MapName> [GameType]"));
return true;
}
String mapName = args[0];
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
final String worldName = getPlugin().getWorldString(mapName, gameType);
if (!getPlugin().DoesMapExist(worldName))
{
message(player, "Map does not exist: " + F.elem(worldName));
return true;
}
if (!getPlugin().GetData(worldName).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
if (getPlugin().GetMapWorld(worldName) != null)
{
World world = getPlugin().GetMapWorld(worldName);
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
//Unload World
//Things break if this isn't set to true for saving the world
MapUtil.UnloadWorld(getPlugin(), world, true);
}
//Delete
boolean deleted = FileUtils.deleteQuietly(new File(worldName));
if (deleted)
getPlugin().Announce("Deleted World: " + F.elem(worldName));
else
getPlugin().Announce("Failed to delete World: " + F.elem(worldName));
return false;
}
}

View File

@ -0,0 +1,96 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class GameTypeCommand extends BaseCommand
{
public GameTypeCommand(MapParser plugin)
{
super(plugin, "gametype");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length != 1)
{
message(player, "Invalid Input. " + F.elem("/gametype <GameType>"));
return true;
}
if (world.getName().equals("world"))
{
message(player, "Cannot set GameType for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
//Check Gametype
GameType type = null;
try
{
type = GameType.valueOf(args[0]);
}
catch (Exception ex)
{
getPlugin().sendValidGameTypes(player);
return true;
}
if (getPlugin().DoesMapExist(getPlugin().getShortWorldName(world.getName()), type))
{
message(player, "A world with the same name already exists for the new gametype: " + type.GetName());
return true;
}
// Rename world
for (Player other : world.getPlayers())
{
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
message(player, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
File typeFolder = new File("map/" + type.GetName());
if (!typeFolder.exists())
typeFolder.mkdir();
File mapFolder = new File(world.getName());
String newName = "map/" + type.GetName() + "/" + getPlugin().getShortWorldName(world.getName());
File newFolder = new File(newName);
mapFolder.renameTo(newFolder);
message(player, "Map " + world.getName() + " renamed to " + newName);
MapData data = getPlugin().GetData(newName);
data.GameType = type;
data.Write();
getPlugin().Announce("GameType for " + F.elem(newName) + " set to " + F.elem(args[0]) + ".");
return true;
}
}

View File

@ -0,0 +1,24 @@
package mineplex.mapparser.command;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class HubCommand extends BaseCommand
{
public HubCommand(MapParser plugin)
{
super(plugin, "hub");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
player.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
return true;
}
}

View File

@ -0,0 +1,66 @@
package mineplex.mapparser.command;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class JoinCommand extends BaseCommand
{
public JoinCommand(MapParser plugin)
{
super(plugin, "join");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length != 1)
{
message(player, "Invalid Input. " + F.elem("/join <Name>"));
return true;
}
if (player.getWorld().getName().equals("world"))
{
message(player, "Cannot change Join-List for Lobby.");
return true;
}
//Permission
if (!getPlugin().GetData(player.getWorld().getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
Player other = UtilPlayer.searchOnline(player, args[0], true);
if (other != null)
{
MapData data = getPlugin().GetData(player.getWorld().getName());
if (data.WhiteList.contains(other.getName()))
{
data.WhiteList.remove(other.getName());
data.Write();
getPlugin().Announce("Join-List for " + F.elem(player.getWorld().getName()) + " (" + other.getName() + " = " + F.tf(false) + ")");
}
else
{
data.WhiteList.add(player.getName());
data.Write();
getPlugin().Announce("Join-List for " + F.elem(player.getWorld().getName()) + " (" + other.getName() + " = " + F.tf(true) + ")");
}
}
return true;
}
}

View File

@ -0,0 +1,84 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class ListCommand extends BaseCommand
{
public ListCommand(MapParser plugin)
{
super(plugin, "list");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length == 0)
{
UtilPlayer.message(player, F.main("Parser", "Listing Maps;"));
for (GameType gameType : GameType.values())
{
listMaps(player, gameType);
}
}
else if (args.length == 1)
{
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[0]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
}
UtilPlayer.message(player, F.main("Parser", "Listing Maps for gametype " + F.elem(gameType.GetName())));
listMaps(player, gameType);
}
return true;
}
private void listMaps(Player player, GameType gameType)
{
String maps = "";
ChatColor color = ChatColor.YELLOW;
File mapsFolder = new File("map" + File.separator + gameType.GetName());
if (!mapsFolder.exists())
return;
for (File file : mapsFolder.listFiles())
{
if (!file.isDirectory())
continue;
maps += color + file.getName() + " ";
if (color == ChatColor.YELLOW)
color = ChatColor.GOLD;
else
color = ChatColor.YELLOW;
}
// Print line of maps for specific gametype
if (maps.length() > 0)
{
maps = F.elem(gameType.name()) + "> " + maps;
player.sendMessage(maps);
}
}
}

View File

@ -0,0 +1,115 @@
package mineplex.mapparser.command;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.GameType;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class MapCommand extends BaseCommand
{
public MapCommand(MapParser plugin)
{
super(plugin, "map");
setDescription("Teleport to a map");
setUsage("/map <name> [gametype]");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 1)
{
//UtilPlayer.message(event.getPlayer(), F.main("Parser", "Invalid Input. " + F.elem("/map <MapName> [GameType]")));
return false;
}
String worldName = null;
// Look up maps without a specific game type
if (args.length == 1)
{
List<String> possibleMaps = getPlugin().getMapsByName(args[0]);
if (possibleMaps.size() == 0)
{
message(player, "No maps found with the name: " + F.elem(args[0]));
}
else if (possibleMaps.size() > 1)
{
message(player, "Found more than one possible match:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
return true;
}
worldName = possibleMaps.get(0);
}
else // Get map with specified name and gametype
{
GameType gameType = null;
try
{
gameType = GameType.valueOf(args[1]);
}
catch (Exception e)
{
getPlugin().sendValidGameTypes(player);
return true;
}
worldName = getPlugin().getWorldString(args[0], gameType);
}
World world = getPlugin().GetMapWorld(worldName);
if (world == null)
{
if (getPlugin().DoesMapExist(worldName))
{
world = Bukkit.createWorld(new WorldCreator(worldName));
}
else
{
message(player, "Map Not Found: " + F.elem(worldName));
return true;
}
}
//Error (This should not occur!)
if (world == null)
{
message(player, "Null World Error: " + F.elem(worldName));
return true;
}
//Permission
if (!getPlugin().GetData(world.getName()).CanJoin(player))
{
message(player, "You do not have Join-Access on this Map.");
return true;
}
//Teleport
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(new Location(world, 0, 100, 0));
MapData data = getPlugin().GetData(worldName);
UtilPlayer.message(player, F.value("Map Name", data.MapName));
UtilPlayer.message(player, F.value("Author", data.MapCreator));
UtilPlayer.message(player, F.value("Game Type", data.GameType.GetName()));
return false;
}
}

View File

@ -0,0 +1,61 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class NameCommand extends BaseCommand
{
public NameCommand(MapParser plugin)
{
super(plugin, "name");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/name <MapName>"));
return true;
}
if (world.equals("world"))
{
message(player, "Cannot set name for Lobby.");
return true;
}
String mapName = "";
for(String arg : args)
mapName += arg + " ";
mapName = mapName.trim();
//Permission
if (!getPlugin().GetData(world.getName()).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
MapData data = getPlugin().GetData(world.getName());
data.MapName = mapName;
data.Write();
getPlugin().Announce("Map Name for " + F.elem(world.getName()) + " set to " + F.elem(mapName) + ".");
return true;
}
}

View File

@ -0,0 +1,60 @@
package mineplex.mapparser.command;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
import mineplex.mapparser.Parse;
/**
* Created by Shaun on 8/15/2014.
*/
public class ParseCommand extends BaseCommand
{
public ParseCommand(MapParser plugin)
{
super(plugin, "parse");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
Location parseLoc = player.getLocation();
World world = parseLoc.getWorld();
MapData data = getPlugin().GetData(world.getName());
if (data.MapName.equals("null") || data.MapCreator.equals("null") || data.GameType.equals("null"))
{
message(player, "Map Name/Author/GameType are not set!");
return true;
}
//Teleport Players Out
for (Player worldPlayer : world.getPlayers())
{
worldPlayer.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
message(player, "World " + F.elem(world.getName()) + " is preparing to be parsed.");
}
//Unload World > Copy
World parseableWorld = getPlugin().getWorldManager().prepMapParse(world);
if (parseableWorld == null)
{
message(player, "Could not prepare world for parsing!");
return true;
}
//Parse the World
getPlugin().setCurrentParse(new Parse(getPlugin(), parseableWorld, args, parseLoc, getPlugin().GetData(parseLoc.getWorld().getName())));
return true;
}
}

View File

@ -0,0 +1,65 @@
package mineplex.mapparser.command;
import java.io.File;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.mapparser.MapData;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class RenameCommand extends BaseCommand
{
public RenameCommand(MapParser plugin)
{
super(plugin, "rename");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
World world = player.getWorld();
MapData data = getPlugin().GetData(world.getName());
if (data == null)
{
message(player, "Map not found: " + F.elem(args[0]));
return true;
}
else if (!data.CanRename(player))
{
message(player, "You do not have access to rename this map");
return true;
}
else if (args.length != 1)
{
message(player, "Usage: /rename <new name>");
return true;
}
String newName = args[0];
for (Player other : world.getPlayers())
{
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
message(other, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);
message(player, "World unloaded!");
File mapFolder = new File(world.getName());
File newFolder = new File("map" + File.separator + data.GameType.GetName() + File.separator + newName);
mapFolder.renameTo(newFolder);
message(player, "Map " + world.getName() + " renamed to " + newFolder.getName());
return true;
}
}

View File

@ -0,0 +1,79 @@
package mineplex.mapparser.command;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/16/2014.
*/
public class SaveCommand extends BaseCommand
{
public SaveCommand(MapParser plugin)
{
super(plugin, "save");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
if (args.length < 1)
{
message(player, "Invalid Input. " + F.elem("/save <MapName>"));
return true;
}
String name = args[0];
List<String> possibleMaps = getPlugin().getMapsByName(name);
if (possibleMaps.size() > 1)
{
message(player, "More than one map found:");
for (String s : possibleMaps)
UtilPlayer.message(player, s);
return true;
}
else if (possibleMaps.size() == 0)
{
message(player, "No maps found with the name: " + F.elem(name));
return true;
}
String worldName = possibleMaps.get(0);
World world = getPlugin().GetMapWorld(worldName);
if (world != null)
{
if (!getPlugin().GetData(worldName).CanBuild(player))
{
message(player, "You do not have Build-Access on this Map.");
return true;
}
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
//Unload World
MapUtil.UnloadWorld(getPlugin(), world, true);
}
else
{
message(player, "World is not loaded: " + F.elem(worldName));
return true;
}
getPlugin().Announce("Saved World: " + F.elem(args[0]));
return false;
}
}

View File

@ -0,0 +1,31 @@
package mineplex.mapparser.command;
import org.bukkit.World;
import org.bukkit.entity.Player;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.mapparser.MapParser;
/**
* Created by Shaun on 8/15/2014.
*/
public class WorldsCommand extends BaseCommand
{
public WorldsCommand(MapParser plugin)
{
super(plugin, "worlds");
}
@Override
public boolean execute(Player player, String alias, String[] args)
{
message(player, "Listing Active Worlds;");
for (World world : getPlugin().getServer().getWorlds())
{
player.sendMessage(world.getName());
}
return true;
}
}