Adding Nextbattle command

This commit is contained in:
Tim Düsterhus 2011-07-27 22:05:56 +02:00
parent 45716af6b8
commit bb300cf372
3 changed files with 49 additions and 19 deletions

View File

@ -177,12 +177,8 @@ public class War extends JavaPlugin {
/*if (sender instanceof Player) {
if (this.isZoneMaker(player)) {
// Mod commands : /nextbattle
if (command.equals("nextbattle")) {
this.performNextBattle(player);
}
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
else if (command.equals("setzone")) {
if (command.equals("setzone")) {
this.performSetZone(player, arguments);
} else if (command.equals("setzonelobby")) {
this.performSetZoneLobby(player, arguments);
@ -644,20 +640,6 @@ public class War extends JavaPlugin {
}
}
public void performNextBattle(Player player) {
if (!this.inAnyWarzone(player.getLocation())) {
this.badMsg(player, "Usage: /nextbattle. Resets the zone blocks and all teams' life pools. Must be in warzone.");
} else {
Warzone warzone = Warzone.getZoneByLocation(player);
warzone.clearFlagThieves();
for (Team team : warzone.getTeams()) {
team.teamcast("The battle was interrupted. " + warzone.getTeamInformation() + " Resetting warzone " + warzone.getName() + " and life pools...");
}
warzone.getVolume().resetBlocksAsJob();
warzone.initializeZoneAsJob();
}
}
private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) {
try {
Map<String, String> namedParams = new HashMap<String, String>();

View File

@ -58,6 +58,9 @@ public class WarCommandHandler {
else if (command.equals("resetzone")) {
commandObj = new ResetzoneCommand(this, sender, arguments);
}
else if (command.equals("nextbattle")) {
commandObj = new NextbattleCommand(this, sender, arguments);
}
else if (command.equals("deletewarhub")) {
commandObj = new DeletewarhubCommand(this, sender, arguments);
}

View File

@ -0,0 +1,45 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import bukkit.tommytony.war.WarCommandHandler;
public class NextbattleCommand extends AbstractZoneMakerCommand {
public NextbattleCommand(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]);
} 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;
}
zone.clearFlagThieves();
for (Team team : zone.getTeams()) {
team.teamcast("The battle was interrupted. " + zone.getTeamInformation() + " Resetting warzone " + zone.getName() + " and life pools...");
}
zone.getVolume().resetBlocksAsJob();
zone.initializeZoneAsJob();
return true;
}
}