Added Leave-Command

This commit is contained in:
Tim Düsterhus 2011-07-17 18:47:09 +02:00
parent 42d4491b2e
commit 135d1856cc
3 changed files with 31 additions and 9 deletions

View File

@ -816,15 +816,6 @@ public class War extends JavaPlugin {
} }
} }
public void performLeave(Player player) {
if (!this.inAnyWarzone(player.getLocation()) || this.getPlayerTeam(player.getName()) == null) {
this.badMsg(player, "Usage: /leave. " + "Must be in a team already.");
} else {
Warzone zone = this.getPlayerTeamWarzone(player.getName());
zone.handlePlayerLeave(player, zone.getTeleport(), true);
}
}
private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) { private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) {
try { try {
Map<String, String> namedParams = new HashMap<String, String>(); Map<String, String> namedParams = new HashMap<String, String>();

View File

@ -42,6 +42,9 @@ public class WarCommandHandler {
else if (command.equals("join")) { else if (command.equals("join")) {
commandObj = new JoinCommand(this, sender, arguments); commandObj = new JoinCommand(this, sender, arguments);
} }
else if (command.equals("leave")) {
commandObj = new LeaveCommand(this, sender, arguments);
}
else { else {
// we are not responsible for this command // we are not responsible for this command
return true; return true;

View File

@ -0,0 +1,28 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.War;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Warzone;
public class LeaveCommand extends AbstractWarzoneCommand {
public LeaveCommand(WarCommandHandler handler, CommandSender sender, String[] args) {
super(handler, sender, args);
}
public boolean handle() {
if (!(this.sender instanceof Player)) return true;
Player player = (Player) this.sender;
if (!War.war.inAnyWarzone(player.getLocation()) || War.war.getPlayerTeam(player.getName()) == null) {
return false;
}
Warzone zone = War.war.getPlayerTeamWarzone(player.getName());
zone.handlePlayerLeave(player, zone.getTeleport(), true);
return true;
}
}