mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Adding SetZoneLobbyCommand
This commit is contained in:
parent
ef75e5a323
commit
00e8349b40
@ -11,7 +11,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -178,9 +177,7 @@ public class War extends JavaPlugin {
|
||||
/*
|
||||
if (this.isZoneMaker(player)) {
|
||||
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
|
||||
if (command.equals("setzonelobby")) {
|
||||
this.performSetZoneLobby(player, arguments);
|
||||
} else if (command.equals("savezone")) {
|
||||
if (command.equals("savezone")) {
|
||||
this.performSaveZone(player, arguments);
|
||||
} else if (command.equals("setzoneconfig") || command.equals("zonecfg")) {
|
||||
this.performSetZoneConfig(player, arguments);
|
||||
@ -291,86 +288,6 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void performSetZoneLobby(Player player, String[] arguments) {
|
||||
String usageStr = "Usage: When inside a warzone - /setzonelobby <north/n/east/e/south/s/west/w>." + "Attaches the lobby to the specified zone wall. When outside a warzone - /setzonelobby <zonename>. " + "Moves the lobby to your current position.";
|
||||
if (arguments.length < 1 || arguments.length > 1) {
|
||||
this.badMsg(player, usageStr);
|
||||
} else if (this.inAnyWarzone(player.getLocation()) || this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
// Inside a warzone: use the classic n/s/e/w mode
|
||||
if (!arguments[0].equals("north") && !arguments[0].equals("n") && !arguments[0].equals("east") && !arguments[0].equals("e") && !arguments[0].equals("south") && !arguments[0].equals("s") && !arguments[0].equals("west") && !arguments[0].equals("w")) {
|
||||
this.badMsg(player, usageStr);
|
||||
return;
|
||||
}
|
||||
Warzone warzone = Warzone.getZoneByLocation(player);
|
||||
ZoneLobby lobby = ZoneLobby.getLobbyByLocation(player);
|
||||
if (warzone == null && lobby != null) {
|
||||
warzone = lobby.getZone();
|
||||
} else {
|
||||
lobby = warzone.getLobby();
|
||||
}
|
||||
BlockFace wall = BlockFace.WEST;
|
||||
String wallStr = "";
|
||||
if (arguments[0].equals("north") || arguments[0].equals("n")) {
|
||||
wall = BlockFace.NORTH;
|
||||
wallStr = "north";
|
||||
} else if (arguments[0].equals("east") || arguments[0].equals("e")) {
|
||||
wall = BlockFace.EAST;
|
||||
wallStr = "east";
|
||||
} else if (arguments[0].equals("south") || arguments[0].equals("s")) {
|
||||
wall = BlockFace.SOUTH;
|
||||
wallStr = "south";
|
||||
} else if (arguments[0].equals("west") || arguments[0].equals("w")) {
|
||||
wall = BlockFace.WEST;
|
||||
wallStr = "west";
|
||||
}
|
||||
if (lobby != null) {
|
||||
// reset existing lobby
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.setWall(wall);
|
||||
lobby.initialize();
|
||||
this.msg(player, "Warzone lobby moved to " + wallStr + " side of zone.");
|
||||
} else {
|
||||
// new lobby
|
||||
lobby = new ZoneLobby(warzone, wall);
|
||||
warzone.setLobby(lobby);
|
||||
lobby.initialize();
|
||||
if (this.warHub != null) { // warhub has to change
|
||||
this.warHub.getVolume().resetBlocks();
|
||||
this.warHub.initialize();
|
||||
}
|
||||
this.msg(player, "Warzone lobby created on " + wallStr + "side of zone.");
|
||||
}
|
||||
WarzoneMapper.save(warzone, false);
|
||||
} else {
|
||||
// Not in a warzone: set the lobby position to where the player is standing
|
||||
Warzone warzone = Warzone.getZoneByName(arguments[0]);
|
||||
if (warzone == null) {
|
||||
this.badMsg(player, "No warzone matches " + arguments[0] + ".");
|
||||
} else {
|
||||
// Move the warzone lobby
|
||||
ZoneLobby lobby = warzone.getLobby();
|
||||
if (lobby != null) {
|
||||
// reset existing lobby
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.setLocation(player.getLocation());
|
||||
lobby.initialize();
|
||||
this.msg(player, "Warzone lobby moved to your location.");
|
||||
} else {
|
||||
// new lobby
|
||||
lobby = new ZoneLobby(warzone, player.getLocation());
|
||||
warzone.setLobby(lobby);
|
||||
lobby.initialize();
|
||||
if (this.warHub != null) { // warhub has to change
|
||||
this.warHub.getVolume().resetBlocks();
|
||||
this.warHub.initialize();
|
||||
}
|
||||
this.msg(player, "Warzone lobby moved to your location.");
|
||||
}
|
||||
WarzoneMapper.save(warzone, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateZoneFromNamedParams(Warzone warzone, Player player, String[] arguments) {
|
||||
try {
|
||||
Map<String, String> namedParams = new HashMap<String, String>();
|
||||
|
@ -36,68 +36,49 @@ public class WarCommandHandler {
|
||||
try {
|
||||
if (command.equals("zones") || command.equals("warzones")) {
|
||||
commandObj = new WarzonesCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("zone") || command.equals("warzone")) {
|
||||
} else if (command.equals("zone") || command.equals("warzone")) {
|
||||
commandObj = new WarzoneCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("teams")) {
|
||||
} else if (command.equals("teams")) {
|
||||
commandObj = new TeamsCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("join")) {
|
||||
} else if (command.equals("join")) {
|
||||
commandObj = new JoinCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("leave")) {
|
||||
} else if (command.equals("leave")) {
|
||||
commandObj = new LeaveCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("team")) {
|
||||
} else if (command.equals("team")) {
|
||||
commandObj = new TeamCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setzone")) {
|
||||
} 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);
|
||||
}
|
||||
else if (command.equals("resetzone")) {
|
||||
} else if (command.equals("setzonelobby")) {
|
||||
commandObj = new SetZoneLobbyCommand(this, sender, arguments);
|
||||
} else if (command.equals("resetzone")) {
|
||||
commandObj = new ResetZoneCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("nextbattle")) {
|
||||
} else if (command.equals("nextbattle")) {
|
||||
commandObj = new NextBattleCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setteam")) {
|
||||
} else if (command.equals("setteam")) {
|
||||
commandObj = new SetTeamCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("deleteteam")) {
|
||||
} else if (command.equals("deleteteam")) {
|
||||
commandObj = new DeleteTeamCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("teamflag")) {
|
||||
} else if (command.equals("teamflag")) {
|
||||
commandObj = new SetTeamFlagCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setmonument")) {
|
||||
} else if (command.equals("setmonument")) {
|
||||
commandObj = new SetMonumentCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("deletemonument")) {
|
||||
} else if (command.equals("deletemonument")) {
|
||||
commandObj = new DeleteMonumentCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setwarhub")) {
|
||||
} else if (command.equals("setwarhub")) {
|
||||
commandObj = new SetWarHubCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("deletewarhub")) {
|
||||
} else if (command.equals("deletewarhub")) {
|
||||
commandObj = new DeleteWarhubCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("loadwar")) {
|
||||
} else if (command.equals("loadwar")) {
|
||||
commandObj = new LoadWarCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("unloadwar")) {
|
||||
} else if (command.equals("unloadwar")) {
|
||||
commandObj = new UnloadWarCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setwarconfig") || command.equals("warcfg")) {
|
||||
} else if (command.equals("setwarconfig") || command.equals("warcfg")) {
|
||||
commandObj = new SetWarConfigCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("zonemaker") || command.equals("zm")) {
|
||||
} else if (command.equals("zonemaker") || command.equals("zm")) {
|
||||
commandObj = new ZoneMakerCommand(this, sender, arguments);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// we are not responsible for this command
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,111 @@
|
||||
package bukkit.tommytony.war.command;
|
||||
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.ZoneLobby;
|
||||
import com.tommytony.war.mappers.WarzoneMapper;
|
||||
|
||||
import bukkit.tommytony.war.NoZoneMakerException;
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
public class SetZoneLobbyCommand extends AbstractZoneMakerCommand {
|
||||
|
||||
public SetZoneLobbyCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
if (!(this.sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
if (this.args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) this.sender;
|
||||
Warzone 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) {
|
||||
Warzone givenWarzone = Warzone.getZoneByName(this.args[0]);
|
||||
if (givenWarzone == null) {
|
||||
return false;
|
||||
} else {
|
||||
// Move the warzone lobby
|
||||
ZoneLobby lobby = givenWarzone.getLobby();
|
||||
if (lobby != null) {
|
||||
// reset existing lobby
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.setLocation(player.getLocation());
|
||||
lobby.initialize();
|
||||
this.msg("Warzone lobby moved to your location.");
|
||||
} else {
|
||||
// new lobby
|
||||
lobby = new ZoneLobby(givenWarzone, player.getLocation());
|
||||
givenWarzone.setLobby(lobby);
|
||||
lobby.initialize();
|
||||
if (War.war.getWarHub() != null) { // warhub has to change
|
||||
War.war.getWarHub().getVolume().resetBlocks();
|
||||
War.war.getWarHub().initialize();
|
||||
}
|
||||
this.msg("Warzone lobby moved to your location.");
|
||||
}
|
||||
WarzoneMapper.save(givenWarzone, false);
|
||||
}
|
||||
} else {
|
||||
// Inside a warzone: use the classic n/s/e/w mode
|
||||
if (!this.args[0].equals("north") && !this.args[0].equals("n") && !this.args[0].equals("east") && !this.args[0].equals("e") && !this.args[0].equals("south") && !this.args[0].equals("s") && !this.args[0].equals("west") && !this.args[0].equals("w")) {
|
||||
return false;
|
||||
}
|
||||
ZoneLobby lobby = zone.getLobby();
|
||||
|
||||
BlockFace wall = BlockFace.WEST;
|
||||
String wallStr = "";
|
||||
if (this.args[0].equals("north") || this.args[0].equals("n")) {
|
||||
wall = BlockFace.NORTH;
|
||||
wallStr = "north";
|
||||
} else if (this.args[0].equals("east") || this.args[0].equals("e")) {
|
||||
wall = BlockFace.EAST;
|
||||
wallStr = "east";
|
||||
} else if (this.args[0].equals("south") || this.args[0].equals("s")) {
|
||||
wall = BlockFace.SOUTH;
|
||||
wallStr = "south";
|
||||
} else if (this.args[0].equals("west") || this.args[0].equals("w")) {
|
||||
wall = BlockFace.WEST;
|
||||
wallStr = "west";
|
||||
}
|
||||
|
||||
if (lobby != null) {
|
||||
// reset existing lobby
|
||||
lobby.getVolume().resetBlocks();
|
||||
lobby.setWall(wall);
|
||||
lobby.initialize();
|
||||
this.msg("Warzone lobby moved to " + wallStr + " side of zone.");
|
||||
} else {
|
||||
// new lobby
|
||||
lobby = new ZoneLobby(zone, wall);
|
||||
zone.setLobby(lobby);
|
||||
lobby.initialize();
|
||||
if (War.war.getWarHub() != null) { // warhub has to change
|
||||
War.war.getWarHub().getVolume().resetBlocks();
|
||||
War.war.getWarHub().initialize();
|
||||
}
|
||||
this.msg("Warzone lobby created on " + wallStr + "side of zone.");
|
||||
}
|
||||
WarzoneMapper.save(zone, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -73,5 +73,4 @@ public class ZoneMakerCommand extends AbstractWarCommand {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user