mirror of
https://github.com/taoneill/war.git
synced 2024-11-30 14:13:23 +01:00
Adding SetZoneCommand
This commit is contained in:
parent
d59dfd09e1
commit
a0c8e1eb7e
@ -178,9 +178,7 @@ public class War extends JavaPlugin {
|
|||||||
/*
|
/*
|
||||||
if (this.isZoneMaker(player)) {
|
if (this.isZoneMaker(player)) {
|
||||||
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
|
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
|
||||||
if (command.equals("setzone")) {
|
if (command.equals("setzonelobby")) {
|
||||||
this.performSetZone(player, arguments);
|
|
||||||
} else if (command.equals("setzonelobby")) {
|
|
||||||
this.performSetZoneLobby(player, arguments);
|
this.performSetZoneLobby(player, arguments);
|
||||||
} else if (command.equals("savezone")) {
|
} else if (command.equals("savezone")) {
|
||||||
this.performSaveZone(player, arguments);
|
this.performSaveZone(player, arguments);
|
||||||
@ -448,30 +446,6 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performSetZone(Player player, String[] arguments) {
|
|
||||||
if (arguments.length < 2 || arguments.length > 2 || (arguments.length == 2 && (!arguments[1].equals("southeast") && !arguments[1].equals("northwest") && !arguments[1].equals("se") && !arguments[1].equals("nw") && !arguments[1].equals("corner1") && !arguments[1].equals("corner2") && !arguments[1].equals("c1") && !arguments[1].equals("c2") && !arguments[1].equals("pos1") && !arguments[1].equals("pos2") && !arguments[1].equals("wand")))) {
|
|
||||||
if (arguments.length == 1) {
|
|
||||||
// we only have a zone name, default to wand mode
|
|
||||||
this.addWandBearer(player, arguments[0]);
|
|
||||||
} else {
|
|
||||||
this.badMsg(player, "Usage: =<Classic mode>= /setzone <warzone-name> <'northwest'/'southeast'/'nw'/'se'> (NW defaults to top block, SE to bottom). " + "=<Wand Cuboid mode>= /setzone <warzone-name> wand (gives you a wooden sword to right and left click, drop to disable). " + "=<Wandless Cuboid mode>= /setzone <warzone-name> <'corner1'/'corner2'/'c1'/'c2'/'pos1'/'pos2'> (block where you're standing). " + "Set one corner, then the next. Defines the outline of the warzone, which will be reset at the start of every battle. " + "Saves the zone blocks if the outline is valid.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ZoneSetter setter = new ZoneSetter(player, arguments[0]);
|
|
||||||
if (arguments[1].equals("northwest") || arguments[1].equals("nw")) {
|
|
||||||
setter.placeNorthwest();
|
|
||||||
} else if (arguments[1].equals("southeast") || arguments[1].equals("se")) {
|
|
||||||
setter.placeSoutheast();
|
|
||||||
} else if (arguments[1].equals("corner1") || arguments[1].equals("c1") || arguments[1].equals("pos1")) {
|
|
||||||
setter.placeCorner1();
|
|
||||||
} else if (arguments[1].equals("corner2") || arguments[1].equals("c2") || arguments[1].equals("pos2")) {
|
|
||||||
setter.placeCorner2();
|
|
||||||
} else if (arguments[1].equals("wand")) {
|
|
||||||
this.addWandBearer(player, arguments[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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>();
|
||||||
|
@ -52,6 +52,9 @@ public class WarCommandHandler {
|
|||||||
else if (command.equals("team")) {
|
else if (command.equals("team")) {
|
||||||
commandObj = new TeamCommand(this, sender, arguments);
|
commandObj = new TeamCommand(this, sender, arguments);
|
||||||
}
|
}
|
||||||
|
else if (command.equals("setzone")) {
|
||||||
|
commandObj = new SetZoneCommand(this, sender, arguments);
|
||||||
|
}
|
||||||
else if (command.equals("deletezone")) {
|
else if (command.equals("deletezone")) {
|
||||||
commandObj = new DeleteZoneCommand(this, sender, arguments);
|
commandObj = new DeleteZoneCommand(this, sender, arguments);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package bukkit.tommytony.war.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.tommytony.war.ZoneSetter;
|
||||||
|
|
||||||
|
import bukkit.tommytony.war.War;
|
||||||
|
import bukkit.tommytony.war.WarCommandHandler;
|
||||||
|
|
||||||
|
public class SetZoneCommand extends AbstractZoneMakerCommand {
|
||||||
|
|
||||||
|
public SetZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException {
|
||||||
|
super(handler, sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handle() {
|
||||||
|
if (!(this.sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) this.sender;
|
||||||
|
|
||||||
|
if (this.args.length == 0) {
|
||||||
|
return false;
|
||||||
|
} else if (this.args.length > 2) {
|
||||||
|
return false;
|
||||||
|
} else if (this.args.length == 1) {
|
||||||
|
War.war.addWandBearer(player, this.args[0]);
|
||||||
|
} else if (this.args.length == 2) {
|
||||||
|
if (!this.args[1].equals("southeast") && !this.args[1].equals("northwest") && !this.args[1].equals("se") && !this.args[1].equals("nw") && !this.args[1].equals("corner1") && !this.args[1].equals("corner2") && !this.args[1].equals("c1") && !this.args[1].equals("c2") && !this.args[1].equals("pos1") && !this.args[1].equals("pos2") && !this.args[1].equals("wand")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZoneSetter setter = new ZoneSetter(player, this.args[0]);
|
||||||
|
if (this.args[1].equals("northwest") || this.args[1].equals("nw")) {
|
||||||
|
setter.placeNorthwest();
|
||||||
|
} else if (this.args[1].equals("southeast") || this.args[1].equals("se")) {
|
||||||
|
setter.placeSoutheast();
|
||||||
|
} else if (this.args[1].equals("corner1") || this.args[1].equals("c1") || this.args[1].equals("pos1")) {
|
||||||
|
setter.placeCorner1();
|
||||||
|
} else if (this.args[1].equals("corner2") || this.args[1].equals("c2") || this.args[1].equals("pos2")) {
|
||||||
|
setter.placeCorner2();
|
||||||
|
} else if (this.args[1].equals("wand")) {
|
||||||
|
War.war.addWandBearer(player, this.args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user