Code cleanup for spawn location, remove JoinCommand

This commit is contained in:
Shaun Bennett 2014-08-16 16:01:00 -05:00
parent 18e1265afd
commit e286a45de8
10 changed files with 16 additions and 77 deletions

View File

@ -47,6 +47,7 @@ public class MapParser extends JavaPlugin implements Listener
private Parse _curParse = null;
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
private Location _spawnLocation;
@Override
public void onEnable()
@ -56,6 +57,7 @@ public class MapParser extends JavaPlugin implements Listener
getServer().getPluginManager().registerEvents(this, this);
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
_spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0);
//Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
@ -67,7 +69,6 @@ public class MapParser extends JavaPlugin implements Listener
_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));
@ -88,7 +89,7 @@ public class MapParser extends JavaPlugin implements Listener
{
Player player = event.getPlayer();
player.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
player.teleport(getSpawnLocation());
ResetInventory(event.getPlayer());
@ -380,6 +381,11 @@ public class MapParser extends JavaPlugin implements Listener
return data;
}
public Location getSpawnLocation()
{
return _spawnLocation;
}
public void ResetInventory(Player player)
{
UtilInv.Clear(player);

View File

@ -62,11 +62,10 @@ public class CreateCommand extends BaseCommand
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(new Location(world, 0, 100, 0));
player.teleport(getPlugin().getSpawnLocation());
//Give Access
MapData mapData = getPlugin().GetData(worldName);
mapData.WhiteList.add(player.getName());
mapData.BuildList.add(player.getName());
mapData.GameType = gameType;
mapData.Write();

View File

@ -64,7 +64,7 @@ public class DeleteCommand extends BaseCommand
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
other.teleport(getPlugin().getSpawnLocation());
//Unload World
//Things break if this isn't set to true for saving the world

View File

@ -68,7 +68,7 @@ public class GameTypeCommand extends BaseCommand
// Rename world
for (Player other : world.getPlayers())
{
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
other.teleport(getPlugin().getSpawnLocation());
message(player, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);

View File

@ -18,7 +18,7 @@ public class HubCommand extends BaseCommand
@Override
public boolean execute(Player player, String alias, String[] args)
{
player.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
player.teleport(getPlugin().getSpawnLocation());
return true;
}
}

View File

@ -1,66 +0,0 @@
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

@ -103,7 +103,7 @@ public class MapCommand extends BaseCommand
//Teleport
message(player, "Teleporting to World: " + F.elem(worldName));
player.teleport(new Location(world, 0, 100, 0));
player.teleport(getPlugin().getSpawnLocation());
MapData data = getPlugin().GetData(worldName);

View File

@ -39,7 +39,7 @@ public class ParseCommand extends BaseCommand
//Teleport Players Out
for (Player worldPlayer : world.getPlayers())
{
worldPlayer.teleport(new Location(Bukkit.getWorlds().get(0), 0, 100, 0));
worldPlayer.teleport(getPlugin().getSpawnLocation());
message(player, "World " + F.elem(world.getName()) + " is preparing to be parsed.");
}

View File

@ -47,7 +47,7 @@ public class RenameCommand extends BaseCommand
for (Player other : world.getPlayers())
{
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
other.teleport(getPlugin().getSpawnLocation());
message(other, "Unloading world for rename...");
}
MapUtil.UnloadWorld(getPlugin(), world, true);

View File

@ -61,7 +61,7 @@ public class SaveCommand extends BaseCommand
//Teleport Out
for (Player other : world.getPlayers())
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
other.teleport(getPlugin().getSpawnLocation());
//Unload World
MapUtil.UnloadWorld(getPlugin(), world, true);