mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 20:59:39 +01:00
Closes gh-96. Two new settings. Players can leave the spawn on when there is at least minplayers in at least minteams. E.g. with minplayer:1 and minteams:1 no one gets stuck in spawn; with minplayers:1 and minteams:2 you need at least one player on at least two separate teams (1+1=2 players total). Also, updating with savezone, zonecfg or warcfg now prompts you back to confirm your changes.
This commit is contained in:
parent
b62e8ffd53
commit
5abdf43986
@ -77,6 +77,8 @@ public class War extends JavaPlugin {
|
||||
private boolean defaultUnbreakableZoneBlocks = false;
|
||||
private boolean defaultNoCreatures = false;
|
||||
private boolean defaultGlassWalls = true;
|
||||
private int defaultMinPlayers = 1; // By default, 1 player on 1 team is enough for unlocking the cant-exit-spawn guard
|
||||
private int defaultMinTeams = 1;
|
||||
private FlagReturn defaultFlagReturn = FlagReturn.BOTH;
|
||||
private boolean defaultResetOnEmpty = false, defaultResetOnLoad = false, defaultResetOnUnload = false;
|
||||
private TeamSpawnStyle defaultSpawnStyle = TeamSpawnStyle.BIG;
|
||||
@ -233,7 +235,7 @@ public class War extends JavaPlugin {
|
||||
this.inventoryToLoadout(player.getInventory(), loadout);
|
||||
}
|
||||
|
||||
public boolean updateZoneFromNamedParams(Warzone warzone, CommandSender commandSender, String[] arguments) {
|
||||
public String updateZoneFromNamedParams(Warzone warzone, CommandSender commandSender, String[] arguments) {
|
||||
try {
|
||||
Map<String, String> namedParams = new HashMap<String, String>();
|
||||
for (String namedPair : arguments) {
|
||||
@ -242,37 +244,48 @@ public class War extends JavaPlugin {
|
||||
namedParams.put(pairSplit[0].toLowerCase(), pairSplit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder returnMessage = new StringBuilder();
|
||||
if (namedParams.containsKey("lifepool")) {
|
||||
warzone.setLifePool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
returnMessage.append(" lifepool set to " + warzone.getLifePool() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("monumentheal")) {
|
||||
warzone.setMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||
returnMessage.append(" monumentheal set to " + warzone.getMonumentHeal() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("teamsize")) {
|
||||
warzone.setTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
returnMessage.append(" teamsize set to " + warzone.getTeamCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("maxscore")) {
|
||||
warzone.setScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
returnMessage.append(" maxscore set to " + warzone.getScoreCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("ff")) {
|
||||
String onOff = namedParams.get("ff");
|
||||
warzone.setFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" ff set to " + String.valueOf(warzone.getFriendlyFire()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("autoassign")) {
|
||||
String onOff = namedParams.get("autoassign");
|
||||
warzone.setAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" autoassign set to " + String.valueOf(warzone.isAutoAssignOnly()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("flagpointsonly")) {
|
||||
String onOff = namedParams.get("flagpointsonly");
|
||||
warzone.setFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" flagpointsonly set to " + String.valueOf(warzone.isFlagPointsOnly()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("blockheads")) {
|
||||
String onOff = namedParams.get("blockheads");
|
||||
warzone.setBlockHeads(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" blockheads set to " + String.valueOf(warzone.isBlockHeads()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("spawnstyle")) {
|
||||
String spawnStyle = namedParams.get("spawnstyle");
|
||||
warzone.setSpawnStyle(TeamSpawnStyle.getStyleFromString(spawnStyle));
|
||||
returnMessage.append(" spawnstyle set to " + warzone.getSpawnStyle().toString() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("flagreturn")) {
|
||||
String flagReturn = namedParams.get("flagreturn").toLowerCase();
|
||||
@ -283,49 +296,77 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
warzone.setFlagReturn(FlagReturn.BOTH);
|
||||
}
|
||||
returnMessage.append(" flagreturn set to " + warzone.getFlagReturn().toString() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("unbreakable")) {
|
||||
String onOff = namedParams.get("unbreakable");
|
||||
warzone.setUnbreakableZoneBlocks(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" unbreakable set to " + String.valueOf(warzone.isUnbreakableZoneBlocks()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("disabled")) {
|
||||
String onOff = namedParams.get("disabled");
|
||||
warzone.setDisabled(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" disabled set to " + String.valueOf(warzone.isDisabled()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("nocreatures")) {
|
||||
String onOff = namedParams.get("nocreatures");
|
||||
warzone.setNoCreatures(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" nocreatures set to " + String.valueOf(warzone.isNoCreatures()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("glasswalls")) {
|
||||
String onOff = namedParams.get("glasswalls");
|
||||
warzone.setGlassWalls(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" glasswalls set to " + String.valueOf(warzone.isGlassWalls()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("minplayers")) {
|
||||
int val = Integer.parseInt(namedParams.get("minplayers"));
|
||||
if (val > warzone.getTeamCap()) {
|
||||
returnMessage.append(" minplayers can't be greater than teamsize.");
|
||||
} else {
|
||||
warzone.setMinPlayers(val);
|
||||
returnMessage.append(" minplayers set to " + warzone.getMinPlayers() + ".");
|
||||
}
|
||||
}
|
||||
if (namedParams.containsKey("minteams")) {
|
||||
int val = Integer.parseInt(namedParams.get("minteams"));
|
||||
if (val > warzone.getTeams().size()) {
|
||||
returnMessage.append(" minteams can't be higher than number of teams.");
|
||||
} else {
|
||||
warzone.setMinTeams(val);
|
||||
returnMessage.append(" minteams set to " + warzone.getMinTeams() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
if (namedParams.containsKey("resetonempty")) {
|
||||
String onOff = namedParams.get("resetonempty");
|
||||
warzone.setResetOnEmpty(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonempty set to " + String.valueOf(warzone.isResetOnEmpty()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("resetonload")) {
|
||||
String onOff = namedParams.get("resetonload");
|
||||
warzone.setResetOnLoad(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonload set to " + String.valueOf(warzone.isResetOnLoad()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("resetonunload")) {
|
||||
String onOff = namedParams.get("resetonunload");
|
||||
warzone.setResetOnUnload(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonunload set to " + String.valueOf(warzone.isResetOnUnload()) + ".");
|
||||
}
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
if (namedParams.containsKey("loadout")) {
|
||||
this.inventoryToLoadout(player, warzone.getLoadout());
|
||||
returnMessage.append(" respawn loadout updated.");
|
||||
}
|
||||
if (namedParams.containsKey("reward")) {
|
||||
this.inventoryToLoadout(player, warzone.getReward());
|
||||
returnMessage.append(" game end reward updated.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return returnMessage.toString();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
return "PARSE-ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,45 +379,64 @@ public class War extends JavaPlugin {
|
||||
namedParams.put(pairSplit[0].toLowerCase(), pairSplit[1]);
|
||||
}
|
||||
}
|
||||
if (namedParams.containsKey("lifepool")) {
|
||||
this.setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
}
|
||||
if (namedParams.containsKey("monumentheal")) {
|
||||
this.setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||
}
|
||||
if (namedParams.containsKey("teamsize")) {
|
||||
this.setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
}
|
||||
if (namedParams.containsKey("maxscore")) {
|
||||
this.setDefaultScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
}
|
||||
if (namedParams.containsKey("ff")) {
|
||||
String onOff = namedParams.get("ff");
|
||||
this.setDefaultFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if (namedParams.containsKey("autoassign")) {
|
||||
String onOff = namedParams.get("autoassign");
|
||||
this.setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if (namedParams.containsKey("flagpointsonly")) {
|
||||
String onOff = namedParams.get("flagpointsonly");
|
||||
this.setDefaultFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
|
||||
StringBuilder returnMessage = new StringBuilder();
|
||||
if (namedParams.containsKey("pvpinzonesonly")) {
|
||||
String onOff = namedParams.get("pvpinzonesonly");
|
||||
this.setPvpInZonesOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" flagpointsonly set to " + String.valueOf(war.isDefaultFlagPointsOnly()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("disablepvpmessage")) {
|
||||
String onOff = namedParams.get("disablepvpmessage");
|
||||
this.setDisablePvpMessage(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" disablepvpmessage set to " + String.valueOf(war.isDisablePvpMessage()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("buildinzonesonly")) {
|
||||
String onOff = namedParams.get("buildinzonesonly");
|
||||
this.setBuildInZonesOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" buildinzonesonly set to " + String.valueOf(war.isBuildInZonesOnly()) + ".");
|
||||
}
|
||||
|
||||
if (namedParams.containsKey("lifepool")) {
|
||||
this.setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
returnMessage.append(" lifepool set to " + war.getDefaultLifepool() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("monumentheal")) {
|
||||
this.setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||
returnMessage.append(" monumentheal set to " + war.getDefaultMonumentHeal() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("teamsize")) {
|
||||
this.setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
returnMessage.append(" teamsize set to " + war.getDefaultTeamCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("maxscore")) {
|
||||
this.setDefaultScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
returnMessage.append(" maxscore set to " + war.getDefaultScoreCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("ff")) {
|
||||
String onOff = namedParams.get("ff");
|
||||
this.setDefaultFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" ff set to " + String.valueOf(war.isDefaultFriendlyFire()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("autoassign")) {
|
||||
String onOff = namedParams.get("autoassign");
|
||||
this.setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" autoassign set to " + String.valueOf(war.isDefaultAutoAssignOnly()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("flagpointsonly")) {
|
||||
String onOff = namedParams.get("flagpointsonly");
|
||||
this.setDefaultFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" flagpointsonly set to " + String.valueOf(war.isDefaultFlagPointsOnly()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("blockheads")) {
|
||||
String onOff = namedParams.get("blockheads");
|
||||
this.setDefaultBlockHeads(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" blockheads set to " + String.valueOf(war.isDefaultBlockHeads()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("spawnstyle")) {
|
||||
String spawnStyle = namedParams.get("spawnstyle");
|
||||
this.setDefaultSpawnStyle(TeamSpawnStyle.getStyleFromString(spawnStyle));
|
||||
returnMessage.append(" spawnstyle set to " + war.getDefaultSpawnStyle().toString() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("flagreturn")) {
|
||||
String flagreturn = namedParams.get("flagreturn").toLowerCase();
|
||||
@ -387,46 +447,67 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
this.setDefaultFlagReturn(FlagReturn.BOTH);
|
||||
}
|
||||
returnMessage.append(" flagreturn set to " + war.getDefaultFlagReturn().toString() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("buildinzonesonly")) {
|
||||
String onOff = namedParams.get("buildinzonesonly");
|
||||
this.setBuildInZonesOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
|
||||
if (namedParams.containsKey("unbreakable")) {
|
||||
String onOff = namedParams.get("unbreakable");
|
||||
this.setDefaultUnbreakableZoneBlocks(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" unbreakable set to " + String.valueOf(war.isDefaultUnbreakableZoneBlocks()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("nocreatures")) {
|
||||
String onOff = namedParams.get("nocreatures");
|
||||
this.setDefaultNoCreatures(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" nocreatures set to " + String.valueOf(war.isDefaultNoCreatures()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("glasswalls")) {
|
||||
String onOff = namedParams.get("glasswalls");
|
||||
this.setDefaultGlassWalls(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" glasswalls set to " + String.valueOf(war.isDefaultGlassWalls()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("minplayers")) {
|
||||
int val = Integer.parseInt(namedParams.get("minplayers"));
|
||||
if (val > this.getDefaultTeamCap()) {
|
||||
returnMessage.append(" minplayers can't be greater than teamsize.");
|
||||
} else {
|
||||
this.setDefaultMinPlayers(val);
|
||||
returnMessage.append(" minplayers set to " + this.getDefaultMinPlayers() + ".");
|
||||
}
|
||||
}
|
||||
if (namedParams.containsKey("minteams")) {
|
||||
this.setDefaultMinTeams(Integer.parseInt(namedParams.get("minteams")));
|
||||
returnMessage.append(" minteams set to " + this.getDefaultMinTeams() + ".");
|
||||
}
|
||||
|
||||
if (namedParams.containsKey("resetonempty")) {
|
||||
String onOff = namedParams.get("resetonempty");
|
||||
this.setDefaultResetOnEmpty(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonempty set to " + String.valueOf(war.isDefaultResetOnEmpty()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("resetonload")) {
|
||||
String onOff = namedParams.get("resetonload");
|
||||
this.setDefaultResetOnLoad(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonload set to " + String.valueOf(war.isDefaultResetOnLoad()) + ".");
|
||||
}
|
||||
if (namedParams.containsKey("resetonunload")) {
|
||||
String onOff = namedParams.get("resetonunload");
|
||||
this.setDefaultResetOnUnload(onOff.equals("on") || onOff.equals("true"));
|
||||
returnMessage.append(" resetonunload set to " + String.valueOf(war.isDefaultResetOnUnload()) + ".");
|
||||
}
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
if (namedParams.containsKey("loadout")) {
|
||||
this.inventoryToLoadout(player, this.getDefaultLoadout());
|
||||
returnMessage.append(" respawn loadout updated.");
|
||||
}
|
||||
if (namedParams.containsKey("reward")) {
|
||||
this.inventoryToLoadout(player, this.getDefaultReward());
|
||||
returnMessage.append(" game end reward updated.");
|
||||
}
|
||||
if (namedParams.containsKey("rallypoint")) {
|
||||
this.setZoneRallyPoint(namedParams.get("rallypoint"), player);
|
||||
String zoneName = namedParams.get("rallypoint");
|
||||
this.setZoneRallyPoint(zoneName, player);
|
||||
returnMessage.append(" rallypoint set for zone " + zoneName + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,6 +533,8 @@ public class War extends JavaPlugin {
|
||||
+ " disabled:" + String.valueOf(zone.isDisabled())
|
||||
+ " nocreatures:" + String.valueOf(zone.isNoCreatures())
|
||||
+ " glasswalls:" + String.valueOf(zone.isGlassWalls())
|
||||
+ " minplayers:" + zone.getMinPlayers()
|
||||
+ " minteams:" + zone.getMinTeams()
|
||||
+ " resetonempty:" + String.valueOf(zone.isResetOnEmpty())
|
||||
+ " resetonload:" + String.valueOf(zone.isResetOnLoad())
|
||||
+ " resetonunload:" + String.valueOf(zone.isResetOnUnload());
|
||||
@ -476,6 +559,8 @@ public class War extends JavaPlugin {
|
||||
+ " unbreakable:" + String.valueOf(this.isDefaultUnbreakableZoneBlocks())
|
||||
+ " nocreatures:" + String.valueOf(this.isDefaultNoCreatures())
|
||||
+ " glasswalls:" + String.valueOf(this.isDefaultGlassWalls())
|
||||
+ " minplayers:" + this.getDefaultMinPlayers()
|
||||
+ " minteams:" + this.getDefaultMinTeams()
|
||||
+ " resetonempty:" + String.valueOf(this.isDefaultResetOnEmpty())
|
||||
+ " resetonload:" + String.valueOf(this.isDefaultResetOnLoad())
|
||||
+ " resetonunload:" + String.valueOf(this.isDefaultResetOnUnload());
|
||||
@ -926,4 +1011,20 @@ public class War extends JavaPlugin {
|
||||
public boolean isDefaultFlagPointsOnly() {
|
||||
return this.defaultFlagPointsOnly;
|
||||
}
|
||||
|
||||
public void setDefaultMinPlayers(int defaultMinPlayers) {
|
||||
this.defaultMinPlayers = defaultMinPlayers;
|
||||
}
|
||||
|
||||
public int getDefaultMinPlayers() {
|
||||
return defaultMinPlayers;
|
||||
}
|
||||
|
||||
public void setDefaultMinTeams(int defaultMinTeams) {
|
||||
this.defaultMinTeams = defaultMinTeams;
|
||||
}
|
||||
|
||||
public int getDefaultMinTeams() {
|
||||
return defaultMinTeams;
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if (!War.war.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
||||
|
||||
@ -308,7 +309,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
War.war.getWarHub().resetZoneSign(zone);
|
||||
}
|
||||
zone.keepPlayerInventory(player);
|
||||
War.war.msg(player, "Your inventory is in storage until you use '/war leave'.");
|
||||
War.war.msg(player, "Your inventory is in storage until exit with '/war leave'.");
|
||||
zone.respawnPlayer(event, team, player);
|
||||
for (Team t : zone.getTeams()) {
|
||||
t.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
||||
@ -365,6 +366,12 @@ public class WarPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerWarzone.isEnoughPlayers() && !playerTeam.getSpawnVolume().contains(playerLoc)) {
|
||||
War.war.badMsg(player, "Can't leave spawn until there's a minimum of " + playerWarzone.getMinPlayers() +" player(s) on at least " + playerWarzone.getMinTeams() + " team(s).");
|
||||
event.setTo(playerTeam.getTeamSpawn());
|
||||
return;
|
||||
}
|
||||
|
||||
// Monuments
|
||||
if (playerTeam != null && playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam) && player.getHealth() < 20 && player.getHealth() > 0 // don't heal the dead
|
||||
&& this.random.nextInt(77) == 3) { // one chance out of many of getting healed
|
||||
@ -423,7 +430,6 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
|
||||
event.setTo(playerWarzone.getTeleport());
|
||||
// player.teleport(playerWarzone.getTeleport());
|
||||
} else {
|
||||
// added a point
|
||||
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||
@ -446,7 +452,6 @@ public class WarPlayerListener extends PlayerListener {
|
||||
// player is not in any team, but inside warzone boundaries, get him out
|
||||
Warzone zone = Warzone.getZoneByLocation(playerLoc);
|
||||
event.setTo(zone.getTeleport());
|
||||
// player.teleport(zone.getTeleport());
|
||||
War.war.badMsg(player, "You can't be inside a warzone without a team.");
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public class SaveZoneCommand extends AbstractZoneMakerCommand {
|
||||
int savedBlocks = zone.saveState(true);
|
||||
|
||||
// changed settings: must reinitialize with new settings
|
||||
War.war.updateZoneFromNamedParams(zone, commandSender, this.args);
|
||||
String namedParamResult = War.war.updateZoneFromNamedParams(zone, commandSender, this.args);
|
||||
WarzoneMapper.save(zone, true);
|
||||
if (this.args.length > 0) {
|
||||
// the config may have changed, requiring a reset for spawn styles etc.
|
||||
@ -80,7 +80,7 @@ public class SaveZoneCommand extends AbstractZoneMakerCommand {
|
||||
War.war.getWarHub().initialize();
|
||||
}
|
||||
|
||||
this.msg("Warzone " + zone.getName() + " initial state changed. Saved " + savedBlocks + " blocks.");
|
||||
this.msg("Warzone " + zone.getName() + " initial state changed. Saved " + savedBlocks + " blocks." + namedParamResult);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
||||
}
|
||||
|
||||
// We have a warzone and indexed-from-0 arguments, let's update
|
||||
if (War.war.updateZoneFromNamedParams(zone, player, this.args)) {
|
||||
String namedParamReturn = War.war.updateZoneFromNamedParams(zone, player, this.args);
|
||||
if (!namedParamReturn.equals("") && !namedParamReturn.equals("PARSE-ERROR")) {
|
||||
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
|
||||
WarzoneMapper.save(zone, false);
|
||||
zone.getVolume().resetBlocks();
|
||||
@ -97,17 +98,20 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
||||
zone.initializeZone(); // bring back team spawns etc
|
||||
|
||||
if (wantsToPrint) {
|
||||
this.msg("Warzone config saved. Zone reset. " + War.war.printConfig(zone));
|
||||
this.msg("Warzone config saved. Zone reset." + namedParamReturn + " " + War.war.printConfig(zone));
|
||||
} else {
|
||||
this.msg("Warzone config saved. Zone reset.");
|
||||
this.msg("Warzone config saved. Zone reset." + namedParamReturn);
|
||||
}
|
||||
|
||||
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled
|
||||
War.war.getWarHub().getVolume().resetBlocks();
|
||||
War.war.getWarHub().initialize();
|
||||
}
|
||||
} else if (namedParamReturn.equals("PARSE-ERROR")) {
|
||||
this.badMsg("Failed to read named parameter(s).");
|
||||
} else {
|
||||
this.badMsg("Failed to read named parameters.");
|
||||
// empty return means no param was parsed - print command usage
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -61,6 +61,8 @@ public class Warzone {
|
||||
private boolean disabled = false;
|
||||
private boolean noCreatures = false;
|
||||
private boolean glassWalls = true;
|
||||
private int minPlayers = 1;
|
||||
private int minTeams = 1;
|
||||
|
||||
private boolean resetOnEmpty = false;
|
||||
private boolean resetOnLoad = false;
|
||||
@ -86,6 +88,8 @@ public class Warzone {
|
||||
this.setUnbreakableZoneBlocks(War.war.isDefaultUnbreakableZoneBlocks());
|
||||
this.setNoCreatures(War.war.isDefaultNoCreatures());
|
||||
this.setGlassWalls(War.war.isDefaultGlassWalls());
|
||||
this.setMinPlayers(War.war.getDefaultMinPlayers());
|
||||
this.setMinTeams(War.war.getDefaultMinTeams());
|
||||
this.setResetOnEmpty(War.war.isDefaultResetOnEmpty());
|
||||
this.setResetOnLoad(War.war.isDefaultResetOnLoad());
|
||||
this.setResetOnUnload(War.war.isDefaultResetOnUnload());
|
||||
@ -1058,6 +1062,19 @@ public class Warzone {
|
||||
this.getVolume().finalize();
|
||||
}
|
||||
|
||||
public boolean isEnoughPlayers() {
|
||||
int teamsWithEnough = 0;
|
||||
for (Team team : teams) {
|
||||
if (team.getPlayers().size() >= this.getMinPlayers()) {
|
||||
teamsWithEnough++;
|
||||
}
|
||||
}
|
||||
if (teamsWithEnough >= this.getMinTeams()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setResetOnLoad(boolean resetOnLoad) {
|
||||
this.resetOnLoad = resetOnLoad;
|
||||
}
|
||||
@ -1097,4 +1114,20 @@ public class Warzone {
|
||||
public boolean isFlagPointsOnly() {
|
||||
return this.flagPointsOnly;
|
||||
}
|
||||
|
||||
public void setMinPlayers(int minPlayers) {
|
||||
this.minPlayers = minPlayers;
|
||||
}
|
||||
|
||||
public int getMinPlayers() {
|
||||
return minPlayers;
|
||||
}
|
||||
|
||||
public void setMinTeams(int minTeams) {
|
||||
this.minTeams = minTeams;
|
||||
}
|
||||
|
||||
public int getMinTeams() {
|
||||
return minTeams;
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,9 @@ public class WarMapper {
|
||||
// defaultMonumentHeal
|
||||
War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
|
||||
|
||||
// defaultMonumentHeal
|
||||
War.war.setDefaultMonumentHeal(warConfig.getInt("defaultMonumentHeal"));
|
||||
|
||||
// defaultFriendlyFire
|
||||
War.war.setDefaultFriendlyFire(warConfig.getBoolean("defaultFriendlyFire"));
|
||||
|
||||
@ -154,6 +157,12 @@ public class WarMapper {
|
||||
// defaultGlassWalls
|
||||
War.war.setDefaultGlassWalls(warConfig.getBoolean("defaultGlassWalls"));
|
||||
|
||||
// defaultMinPlayers
|
||||
War.war.setDefaultMinPlayers(warConfig.getInt("defaultMinPlayers"));
|
||||
|
||||
// defaultMinTeams
|
||||
War.war.setDefaultMinTeams(warConfig.getInt("defaultMinTeams"));
|
||||
|
||||
// defaultResetOnEmpty
|
||||
War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
|
||||
|
||||
@ -269,6 +278,12 @@ public class WarMapper {
|
||||
// defaultGlassWalls
|
||||
warConfig.setBoolean("defaultGlassWalls", War.war.isDefaultGlassWalls());
|
||||
|
||||
// defaultMinPlayers
|
||||
warConfig.setInt("defaultMinPlayers", War.war.getDefaultMinPlayers());
|
||||
|
||||
// defaultMinTeams
|
||||
warConfig.setInt("defaultMinTeams", War.war.getDefaultMinTeams());
|
||||
|
||||
// defaultResetOnEmpty
|
||||
warConfig.setBoolean("defaultResetOnEmpty", War.war.isDefaultResetOnEmpty());
|
||||
|
||||
|
@ -200,6 +200,11 @@ public class WarzoneMapper {
|
||||
// glassWalls
|
||||
warzone.setGlassWalls(warzoneConfig.getBoolean("glassWalls"));
|
||||
|
||||
// minPlayers
|
||||
warzone.setMinPlayers(warzoneConfig.getInt("minPlayers"));
|
||||
|
||||
// minTeams
|
||||
warzone.setMinTeams(warzoneConfig.getInt("minTeams"));
|
||||
|
||||
// resetOnEmpty
|
||||
warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty"));
|
||||
@ -222,9 +227,6 @@ public class WarzoneMapper {
|
||||
warzone.setRallyPoint(rallyPoint);
|
||||
}
|
||||
|
||||
// dropLootOnDeath
|
||||
// warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath"));
|
||||
|
||||
// monuments
|
||||
String monumentsStr = warzoneConfig.getString("monuments");
|
||||
if (monumentsStr != null && !monumentsStr.equals("")) {
|
||||
@ -407,6 +409,12 @@ public class WarzoneMapper {
|
||||
// glassWalls
|
||||
warzoneConfig.setBoolean("glassWalls", warzone.isGlassWalls());
|
||||
|
||||
// minPlayers
|
||||
warzoneConfig.setInt("minPlayers", warzone.getMinPlayers());
|
||||
|
||||
// minTeams
|
||||
warzoneConfig.setInt("minTeams", warzone.getMinTeams());
|
||||
|
||||
// resetOnEmpty
|
||||
warzoneConfig.setBoolean("resetOnEmpty", warzone.isResetOnEmpty());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user