diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index a21b1d1..001a8e7 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -177,11 +177,7 @@ public class War extends JavaPlugin { return this.commandHandler.handle(sender, cmd, commandLabel, args); if (sender instanceof Player) { - if (command.equals("teams")) { - this.performTeams(player); - } else if (command.equals("join") && this.canPlayWar(player)) { - this.performJoin(player, arguments); - } else if (command.equals("leave")) { + if (command.equals("leave")) { this.performLeave(player); } else if (command.equals("team")) { this.performTeam(player, arguments); @@ -829,83 +825,6 @@ public class War extends JavaPlugin { } } - public void performJoin(Player player, String[] arguments) { - if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) || (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) { - this.badMsg(player, "Usage: /join ." + " Teams are warzone specific." + " You must be inside a warzone or zone lobby to join a team." + " Use as an alternative to walking through the team gate."); - } else { - // drop from old team if any - Team previousTeam = this.getPlayerTeam(player.getName()); - if (previousTeam != null) { - Warzone zone = this.getPlayerTeamWarzone(player.getName()); - if (!previousTeam.removePlayer(player.getName())) { - this.logWarn("Could not remove player " + player.getName() + " from team " + previousTeam.getName()); - } - if (zone.isFlagThief(player.getName())) { - Team victim = zone.getVictimTeamForThief(player.getName()); - victim.getFlagVolume().resetBlocks(); - victim.initializeTeamFlag(); - zone.removeThief(player.getName()); - for (Team t : zone.getTeams()) { - t.teamcast("Team " + victim.getName() + " flag was returned."); - } - } - previousTeam.resetSign(); - } - - // join new team - String name = arguments[0]; - TeamKind kind = TeamKinds.teamKindFromString(arguments[0]); - Warzone warzone = this.warzone(player.getLocation()); - ZoneLobby lobby = this.lobby(player.getLocation()); - if (warzone == null && lobby != null) { - warzone = lobby.getZone(); - } else { - lobby = warzone.getLobby(); - } - if (warzone.isDisabled()) { - this.badMsg(player, "This warzone is disabled."); - } else { - List teams = warzone.getTeams(); - boolean foundTeam = false; - for (Team team : teams) { - if (team.getName().startsWith(name) || team.getKind() == kind) { - if (!warzone.hasPlayerInventory(player.getName())) { - warzone.keepPlayerInventory(player); - this.msg(player, "Your inventory is in storage until you /leave."); - } - if (team.getPlayers().size() < warzone.getTeamCap()) { - team.addPlayer(player); - team.resetSign(); - warzone.respawnPlayer(team, player); - if (this.warHub != null) { - this.warHub.resetZoneSign(warzone); - } - foundTeam = true; - } else { - this.badMsg(player, "Team " + team.getName() + " is full."); - foundTeam = true; - } - } - } - if (foundTeam) { - for (Team team : teams) { - team.teamcast("" + player.getName() + " joined " + team.getName()); - } - } else { - this.badMsg(player, "No such team. Try /teams."); - } - } - } - } - - public void performTeams(Player player) { - if (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) { - this.badMsg(player, "Usage: /teams. " + "Must be in a warzone or zone lobby (try /war, /zones and /zone)."); - } else { - this.msg(player, "" + this.playerListener.getAllTeamsMsg(player)); - } - } - private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) { try { Map namedParams = new HashMap(); diff --git a/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java b/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java index 11a294e..0cad49d 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java +++ b/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java @@ -36,6 +36,12 @@ public class WarCommandHandler { else if (command.equals("zone") || command.equals("warzone")) { commandObj = new WarzoneCommand(this, sender, arguments); } + else if (command.equals("teams")) { + commandObj = new TeamsCommand(this, sender, arguments); + } + else if (command.equals("join")) { + commandObj = new JoinCommand(this, sender, arguments); + } else { // we are not responsible for this command return true; diff --git a/war/src/main/java/bukkit/tommytony/war/command/JoinCommand.java b/war/src/main/java/bukkit/tommytony/war/command/JoinCommand.java index 15d36c9..891ade3 100644 --- a/war/src/main/java/bukkit/tommytony/war/command/JoinCommand.java +++ b/war/src/main/java/bukkit/tommytony/war/command/JoinCommand.java @@ -22,12 +22,16 @@ public class JoinCommand extends AbstractWarzoneCommand { if (!(this.sender instanceof Player)) return true; Player player = (Player) this.sender; + if (!War.war.canPlayWar(player)) { + //War.war.badMsg(player, "Cannot play war."); + return true; + } if (this.args.length < 1) { return false; } Warzone zone = this.getWarzoneFromLocation(player); if (zone == null) { - // throw error + War.war.badMsg(player, "No such warzone."); return true; } // drop from old team if any