mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Added Leave-Command
This commit is contained in:
parent
42d4491b2e
commit
135d1856cc
@ -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) {
|
||||
try {
|
||||
Map<String, String> namedParams = new HashMap<String, String>();
|
||||
|
@ -42,6 +42,9 @@ public class WarCommandHandler {
|
||||
else if (command.equals("join")) {
|
||||
commandObj = new JoinCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("leave")) {
|
||||
commandObj = new LeaveCommand(this, sender, arguments);
|
||||
}
|
||||
else {
|
||||
// we are not responsible for this command
|
||||
return true;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user