mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +01:00
Adding Setwarhub command
This commit is contained in:
parent
bb300cf372
commit
4a26f437ba
@ -196,8 +196,6 @@ public class War extends JavaPlugin {
|
||||
this.performSetMonument(player, arguments);
|
||||
} else if (command.equals("deletemonument")) {
|
||||
this.performDeleteMonument(player, arguments);
|
||||
} else if (command.equals("setwarhub")) {
|
||||
this.performSetWarhub(player);
|
||||
} else if (command.equals("setwarconfig") || command.equals("warcfg")) {
|
||||
this.performSetWarConfig(player, arguments);
|
||||
} else if (command.equals("zonemaker") || command.equals("zm")) {
|
||||
@ -309,31 +307,6 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void performSetWarhub(Player player) {
|
||||
if (this.warzones.size() > 0) {
|
||||
if (this.warHub != null) {
|
||||
// reset existing hub
|
||||
this.warHub.getVolume().resetBlocks();
|
||||
this.warHub.setLocation(player.getLocation());
|
||||
this.warHub.initialize();
|
||||
this.msg(player, "War hub moved.");
|
||||
} else {
|
||||
this.warHub = new WarHub(player.getLocation());
|
||||
this.warHub.initialize();
|
||||
for (Warzone zone : this.warzones) {
|
||||
if (zone.getLobby() != null) {
|
||||
zone.getLobby().getVolume().resetBlocks();
|
||||
zone.getLobby().initialize();
|
||||
}
|
||||
}
|
||||
this.msg(player, "War hub created.");
|
||||
}
|
||||
WarMapper.save();
|
||||
} else {
|
||||
this.badMsg(player, "No warzones yet.");
|
||||
}
|
||||
}
|
||||
|
||||
public void performDeleteMonument(Player player, String[] arguments) {
|
||||
if (arguments.length < 1 || (!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||
this.badMsg(player, "Usage: /deletemonument <name>." + " Deletes the monument. " + "Must be in a warzone or lobby (try /warzones and /warzone). ");
|
||||
|
@ -61,6 +61,9 @@ public class WarCommandHandler {
|
||||
else if (command.equals("nextbattle")) {
|
||||
commandObj = new NextbattleCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("setwarhub")) {
|
||||
commandObj = new SetwarhubCommand(this, sender, arguments);
|
||||
}
|
||||
else if (command.equals("deletewarhub")) {
|
||||
commandObj = new DeletewarhubCommand(this, sender, arguments);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public class LeaveCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
package bukkit.tommytony.war.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tommytony.war.WarHub;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.mappers.WarMapper;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
import bukkit.tommytony.war.WarCommandHandler;
|
||||
|
||||
public class SetwarhubCommand extends AbstractZoneMakerCommand {
|
||||
public SetwarhubCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
Player player = (Player) this.sender;
|
||||
|
||||
if (War.war.getWarzones().size() > 0) {
|
||||
if (War.war.getWarHub() != null) {
|
||||
// reset existing hub
|
||||
War.war.getWarHub().getVolume().resetBlocks();
|
||||
War.war.getWarHub().setLocation(player.getLocation());
|
||||
War.war.getWarHub().initialize();
|
||||
this.msg("War hub moved.");
|
||||
} else {
|
||||
War.war.setWarHub(new WarHub(player.getLocation()));
|
||||
War.war.getWarHub().initialize();
|
||||
for (Warzone zone : War.war.getWarzones()) {
|
||||
if (zone.getLobby() != null) {
|
||||
zone.getLobby().getVolume().resetBlocks();
|
||||
zone.getLobby().initialize();
|
||||
}
|
||||
}
|
||||
this.msg("War hub created.");
|
||||
}
|
||||
WarMapper.save();
|
||||
} else {
|
||||
this.msg("No warzones yet.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ public class TeamCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
|
@ -13,6 +13,7 @@ public class TeamsCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
Warzone zone;
|
||||
if (this.args.length == 1) {
|
||||
|
@ -13,6 +13,7 @@ public class WarhubCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
||||
|
@ -13,6 +13,7 @@ public class WarzoneCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
// ignore it when no player
|
||||
if (!(this.sender instanceof Player)) return true;
|
||||
|
@ -19,6 +19,7 @@ public class WarzonesCommand extends AbstractWarCommand {
|
||||
super(handler, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle() {
|
||||
String warzonesMessage = "Warzones: ";
|
||||
if (War.war.getWarzones().isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user