Adding DeletemonumentCommand

This commit is contained in:
Tim Düsterhus 2011-07-27 22:19:05 +02:00
parent 4a26f437ba
commit 2c8498fec4
2 changed files with 54 additions and 0 deletions

View File

@ -61,6 +61,9 @@ public class WarCommandHandler {
else if (command.equals("nextbattle")) {
commandObj = new NextbattleCommand(this, sender, arguments);
}
else if (command.equals("deletemonument")) {
commandObj = new DeletemonumentCommand(this, sender, arguments);
}
else if (command.equals("setwarhub")) {
commandObj = new SetwarhubCommand(this, sender, arguments);
}

View File

@ -0,0 +1,51 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.Monument;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneMapper;
import bukkit.tommytony.war.WarCommandHandler;
public class DeletemonumentCommand extends AbstractZoneMakerCommand {
public DeletemonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
Warzone zone;
if (this.args.length == 1) {
zone = Warzone.getZoneByName(this.args[0]);
this.args[0] = this.args[1];
} else {
if (!(this.sender instanceof Player)) {
return false;
}
zone = Warzone.getZoneByLocation((Player) this.sender);
if (zone == null) {
ZoneLobby lobby = ZoneLobby.getLobbyByLocation((Player) this.sender);
if (lobby == null) return false;
zone = lobby.getZone();
}
}
if (zone == null) {
return false;
}
Monument monument = zone.getMonument(this.args[0]);
if (monument != null) {
monument.getVolume().resetBlocks();
zone.getMonuments().remove(monument);
WarzoneMapper.save(zone, false);
this.msg("Monument " + monument.getName() + " removed.");
} else {
this.msg("No such monument.");
}
return true;
}
}