Code cleanup for spawn location, remove JoinCommand
This commit is contained in:
parent
18e1265afd
commit
e286a45de8
@ -47,6 +47,7 @@ public class MapParser extends JavaPlugin implements Listener
|
|||||||
private Parse _curParse = null;
|
private Parse _curParse = null;
|
||||||
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
|
private HashMap<String, MapData> _mapData = new HashMap<String, MapData>();
|
||||||
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
|
private List<BaseCommand> _commands = new ArrayList<BaseCommand>();
|
||||||
|
private Location _spawnLocation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
@ -56,6 +57,7 @@ public class MapParser extends JavaPlugin implements Listener
|
|||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
|
getServer().getWorlds().get(0).setSpawnLocation(0, 106, 0);
|
||||||
|
_spawnLocation = new Location(getServer().getWorlds().get(0), 0, 106, 0);
|
||||||
|
|
||||||
//Updates
|
//Updates
|
||||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ticker(this), 1, 1);
|
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 DeleteCommand(this));
|
||||||
_commands.add(new GameTypeCommand(this));
|
_commands.add(new GameTypeCommand(this));
|
||||||
_commands.add(new HubCommand(this));
|
_commands.add(new HubCommand(this));
|
||||||
_commands.add(new JoinCommand(this));
|
|
||||||
_commands.add(new ListCommand(this));
|
_commands.add(new ListCommand(this));
|
||||||
_commands.add(new MapCommand(this));
|
_commands.add(new MapCommand(this));
|
||||||
_commands.add(new NameCommand(this));
|
_commands.add(new NameCommand(this));
|
||||||
@ -88,7 +89,7 @@ public class MapParser extends JavaPlugin implements Listener
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
player.teleport(new Location(getServer().getWorlds().get(0), 0, 106, 0));
|
player.teleport(getSpawnLocation());
|
||||||
|
|
||||||
ResetInventory(event.getPlayer());
|
ResetInventory(event.getPlayer());
|
||||||
|
|
||||||
@ -379,6 +380,11 @@ public class MapParser extends JavaPlugin implements Listener
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getSpawnLocation()
|
||||||
|
{
|
||||||
|
return _spawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
public void ResetInventory(Player player)
|
public void ResetInventory(Player player)
|
||||||
{
|
{
|
||||||
|
@ -62,11 +62,10 @@ public class CreateCommand extends BaseCommand
|
|||||||
|
|
||||||
message(player, "Teleporting to World: " + F.elem(worldName));
|
message(player, "Teleporting to World: " + F.elem(worldName));
|
||||||
|
|
||||||
player.teleport(new Location(world, 0, 100, 0));
|
player.teleport(getPlugin().getSpawnLocation());
|
||||||
|
|
||||||
//Give Access
|
//Give Access
|
||||||
MapData mapData = getPlugin().GetData(worldName);
|
MapData mapData = getPlugin().GetData(worldName);
|
||||||
mapData.WhiteList.add(player.getName());
|
|
||||||
mapData.BuildList.add(player.getName());
|
mapData.BuildList.add(player.getName());
|
||||||
mapData.GameType = gameType;
|
mapData.GameType = gameType;
|
||||||
mapData.Write();
|
mapData.Write();
|
||||||
|
@ -64,7 +64,7 @@ public class DeleteCommand extends BaseCommand
|
|||||||
|
|
||||||
//Teleport Out
|
//Teleport Out
|
||||||
for (Player other : world.getPlayers())
|
for (Player other : world.getPlayers())
|
||||||
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
|
other.teleport(getPlugin().getSpawnLocation());
|
||||||
|
|
||||||
//Unload World
|
//Unload World
|
||||||
//Things break if this isn't set to true for saving the world
|
//Things break if this isn't set to true for saving the world
|
||||||
|
@ -68,7 +68,7 @@ public class GameTypeCommand extends BaseCommand
|
|||||||
// Rename world
|
// Rename world
|
||||||
for (Player other : world.getPlayers())
|
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...");
|
message(player, "Unloading world for rename...");
|
||||||
}
|
}
|
||||||
MapUtil.UnloadWorld(getPlugin(), world, true);
|
MapUtil.UnloadWorld(getPlugin(), world, true);
|
||||||
|
@ -18,7 +18,7 @@ public class HubCommand extends BaseCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(Player player, String alias, String[] args)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -103,7 +103,7 @@ public class MapCommand extends BaseCommand
|
|||||||
//Teleport
|
//Teleport
|
||||||
message(player, "Teleporting to World: " + F.elem(worldName));
|
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);
|
MapData data = getPlugin().GetData(worldName);
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class ParseCommand extends BaseCommand
|
|||||||
//Teleport Players Out
|
//Teleport Players Out
|
||||||
for (Player worldPlayer : world.getPlayers())
|
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.");
|
message(player, "World " + F.elem(world.getName()) + " is preparing to be parsed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class RenameCommand extends BaseCommand
|
|||||||
|
|
||||||
for (Player other : world.getPlayers())
|
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...");
|
message(other, "Unloading world for rename...");
|
||||||
}
|
}
|
||||||
MapUtil.UnloadWorld(getPlugin(), world, true);
|
MapUtil.UnloadWorld(getPlugin(), world, true);
|
||||||
|
@ -61,7 +61,7 @@ public class SaveCommand extends BaseCommand
|
|||||||
|
|
||||||
//Teleport Out
|
//Teleport Out
|
||||||
for (Player other : world.getPlayers())
|
for (Player other : world.getPlayers())
|
||||||
other.teleport(new Location(getPlugin().getServer().getWorlds().get(0), 0, 106, 0));
|
other.teleport(getPlugin().getSpawnLocation());
|
||||||
|
|
||||||
//Unload World
|
//Unload World
|
||||||
MapUtil.UnloadWorld(getPlugin(), world, true);
|
MapUtil.UnloadWorld(getPlugin(), world, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user