Closes gh-304. Adds "flagmustbehome" setting for warzones.

- Fixed a mistake where changing "pvpinzonesonly" would display "flagpointsonly changed to..." (and the respective value)
- [gh-304] Added a setting for the plugin to not show the "No Building" message ("disablebuildmessage", like "disablepvpmessage", defaults to false). Untested.
- Added a setting for warzones to allow flag capture when the flag is not home ("flagmustbehome", defaults to true)
This commit is contained in:
chris 2011-12-01 19:47:29 +01:00
parent 95308c8bc9
commit 9f828fe790
6 changed files with 73 additions and 7 deletions

View File

@ -63,6 +63,7 @@ public class War extends JavaPlugin {
private boolean pvpInZonesOnly = false; private boolean pvpInZonesOnly = false;
private boolean disablePvpMessage = false; private boolean disablePvpMessage = false;
private boolean buildInZonesOnly = false; private boolean buildInZonesOnly = false;
private boolean disableBuildMessage = false;
private boolean tntInZonesOnly = false; private boolean tntInZonesOnly = false;
private int maxZones = 12; private int maxZones = 12;
private final List<String> deadlyAdjectives = new ArrayList<String>(); private final List<String> deadlyAdjectives = new ArrayList<String>();
@ -79,6 +80,7 @@ public class War extends JavaPlugin {
private boolean defaultFriendlyFire = false; private boolean defaultFriendlyFire = false;
private boolean defaultAutoAssignOnly = false; private boolean defaultAutoAssignOnly = false;
private boolean defaultFlagPointsOnly = false; private boolean defaultFlagPointsOnly = false;
private boolean defaultFlagMustBeHome = true;
private boolean defaultUnbreakableZoneBlocks = false; private boolean defaultUnbreakableZoneBlocks = false;
private boolean defaultNoCreatures = false; private boolean defaultNoCreatures = false;
private boolean defaultGlassWalls = true; private boolean defaultGlassWalls = true;
@ -328,6 +330,11 @@ public class War extends JavaPlugin {
warzone.setFlagPointsOnly(onOff.equals("on") || onOff.equals("true")); warzone.setFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" flagpointsonly set to " + String.valueOf(warzone.isFlagPointsOnly()) + "."); returnMessage.append(" flagpointsonly set to " + String.valueOf(warzone.isFlagPointsOnly()) + ".");
} }
if (namedParams.containsKey("flagmustbehome")) {
String onOff = namedParams.get("flagmustbehome");
warzone.setFlagMustBeHome(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" flagmustbehome set to " + String.valueOf(warzone.isFlagMustBeHome()) + ".");
}
if (namedParams.containsKey("blockheads")) { if (namedParams.containsKey("blockheads")) {
String onOff = namedParams.get("blockheads"); String onOff = namedParams.get("blockheads");
warzone.setBlockHeads(onOff.equals("on") || onOff.equals("true")); warzone.setBlockHeads(onOff.equals("on") || onOff.equals("true"));
@ -489,13 +496,18 @@ public class War extends JavaPlugin {
if (namedParams.containsKey("pvpinzonesonly")) { if (namedParams.containsKey("pvpinzonesonly")) {
String onOff = namedParams.get("pvpinzonesonly"); String onOff = namedParams.get("pvpinzonesonly");
this.setPvpInZonesOnly(onOff.equals("on") || onOff.equals("true")); this.setPvpInZonesOnly(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" flagpointsonly set to " + String.valueOf(war.isDefaultFlagPointsOnly()) + "."); returnMessage.append(" pvpinzonesonly set to " + String.valueOf(war.isPvpInZonesOnly()) + ".");
} }
if (namedParams.containsKey("disablepvpmessage")) { if (namedParams.containsKey("disablepvpmessage")) {
String onOff = namedParams.get("disablepvpmessage"); String onOff = namedParams.get("disablepvpmessage");
this.setDisablePvpMessage(onOff.equals("on") || onOff.equals("true")); this.setDisablePvpMessage(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" disablepvpmessage set to " + String.valueOf(war.isDisablePvpMessage()) + "."); returnMessage.append(" disablepvpmessage set to " + String.valueOf(war.isDisablePvpMessage()) + ".");
} }
if (namedParams.containsKey("disablebuildmessage")) {
String onOff = namedParams.get("disablebuildmessage");
this.setDisableBuildMessage(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" disablebuildmessage set to " + String.valueOf(war.isDisableBuildMessage()) + ".");
}
if (namedParams.containsKey("buildinzonesonly")) { if (namedParams.containsKey("buildinzonesonly")) {
String onOff = namedParams.get("buildinzonesonly"); String onOff = namedParams.get("buildinzonesonly");
this.setBuildInZonesOnly(onOff.equals("on") || onOff.equals("true")); this.setBuildInZonesOnly(onOff.equals("on") || onOff.equals("true"));
@ -542,6 +554,11 @@ public class War extends JavaPlugin {
this.setDefaultFlagPointsOnly(onOff.equals("on") || onOff.equals("true")); this.setDefaultFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" flagpointsonly set to " + String.valueOf(war.isDefaultFlagPointsOnly()) + "."); returnMessage.append(" flagpointsonly set to " + String.valueOf(war.isDefaultFlagPointsOnly()) + ".");
} }
if (namedParams.containsKey("flagmustbehome")) {
String onOff = namedParams.get("flagmustbehome");
this.setDefaultFlagMustBeHome(onOff.equals("on") || onOff.equals("true"));
returnMessage.append(" flagmustbehome set to " + String.valueOf(war.isDefaultFlagMustBeHome()) + ".");
}
if (namedParams.containsKey("blockheads")) { if (namedParams.containsKey("blockheads")) {
String onOff = namedParams.get("blockheads"); String onOff = namedParams.get("blockheads");
this.setDefaultBlockHeads(onOff.equals("on") || onOff.equals("true")); this.setDefaultBlockHeads(onOff.equals("on") || onOff.equals("true"));
@ -697,6 +714,7 @@ public class War extends JavaPlugin {
+ " ff:" + color + String.valueOf(zone.getFriendlyFire()) + normal + " ff:" + color + String.valueOf(zone.getFriendlyFire()) + normal
+ " autoassign:" + color + String.valueOf(zone.isAutoAssignOnly()) + normal + " autoassign:" + color + String.valueOf(zone.isAutoAssignOnly()) + normal
+ " flagpointsonly:" + color + String.valueOf(zone.isFlagPointsOnly()) + normal + " flagpointsonly:" + color + String.valueOf(zone.isFlagPointsOnly()) + normal
+ " flagmustbehome:" + color + String.valueOf(zone.isFlagMustBeHome()) + normal
+ " blockheads:" + color + String.valueOf(zone.isBlockHeads()) + normal + " blockheads:" + color + String.valueOf(zone.isBlockHeads()) + normal
+ " spawnstyle:" + color + zone.getSpawnStyle() + normal + " spawnstyle:" + color + zone.getSpawnStyle() + normal
+ " flagreturn:" + color + zone.getFlagReturn() + normal + " flagreturn:" + color + zone.getFlagReturn() + normal
@ -731,6 +749,7 @@ public class War extends JavaPlugin {
return "War config -" return "War config -"
+ " pvpinzonesonly:" + global + String.valueOf(this.isPvpInZonesOnly()) + normal + " pvpinzonesonly:" + global + String.valueOf(this.isPvpInZonesOnly()) + normal
+ " disablepvpmessage:" + global + String.valueOf(this.isDisablePvpMessage()) + normal + " disablepvpmessage:" + global + String.valueOf(this.isDisablePvpMessage()) + normal
+ " disablebuildmessage:" + global + String.valueOf(this.isDisableBuildMessage()) + normal
+ " buildinzonesonly:" + global + String.valueOf(this.isBuildInZonesOnly()) + normal + " buildinzonesonly:" + global + String.valueOf(this.isBuildInZonesOnly()) + normal
+ " tntinzonesonly:" + global + String.valueOf(this.isTntInZonesOnly()) + normal + " tntinzonesonly:" + global + String.valueOf(this.isTntInZonesOnly()) + normal
+ " maxzones:" + global + this.getMaxZones() + normal + " maxzones:" + global + this.getMaxZones() + normal
@ -741,6 +760,7 @@ public class War extends JavaPlugin {
+ " ff:" + color + String.valueOf(this.isDefaultFriendlyFire()) + normal + " ff:" + color + String.valueOf(this.isDefaultFriendlyFire()) + normal
+ " autoassign:" + color + String.valueOf(this.isDefaultAutoAssignOnly()) + normal + " autoassign:" + color + String.valueOf(this.isDefaultAutoAssignOnly()) + normal
+ " flagpointsonly:" + color + String.valueOf(this.isDefaultFlagPointsOnly()) + normal + " flagpointsonly:" + color + String.valueOf(this.isDefaultFlagPointsOnly()) + normal
+ " flagmustbehome:" + color + String.valueOf(this.isDefaultFlagMustBeHome()) + normal
+ " blockheads:" + color + String.valueOf(this.isDefaultBlockHeads()) + normal + " blockheads:" + color + String.valueOf(this.isDefaultBlockHeads()) + normal
+ " spawnstyle:" + color + this.getDefaultSpawnStyle() + normal + " spawnstyle:" + color + this.getDefaultSpawnStyle() + normal
+ " flagreturn:" + color + this.getDefaultFlagReturn() + normal + " flagreturn:" + color + this.getDefaultFlagReturn() + normal
@ -1102,6 +1122,14 @@ public class War extends JavaPlugin {
this.disablePvpMessage = disablePvpMessage; this.disablePvpMessage = disablePvpMessage;
} }
public boolean isDisableBuildMessage() {
return this.disableBuildMessage;
}
public void setDisableBuildMessage(boolean disableBuildMessage) {
this.disableBuildMessage = disableBuildMessage;
}
public boolean isBuildInZonesOnly() { public boolean isBuildInZonesOnly() {
return this.buildInZonesOnly; return this.buildInZonesOnly;
} }
@ -1246,6 +1274,14 @@ public class War extends JavaPlugin {
return this.defaultFlagPointsOnly; return this.defaultFlagPointsOnly;
} }
public void setDefaultFlagMustBeHome(boolean defaultFlagMustBeHome) {
this.defaultFlagMustBeHome = defaultFlagMustBeHome;
}
public boolean isDefaultFlagMustBeHome() {
return this.defaultFlagMustBeHome;
}
public void setDefaultMinPlayers(int defaultMinPlayers) { public void setDefaultMinPlayers(int defaultMinPlayers) {
this.defaultMinPlayers = defaultMinPlayers; this.defaultMinPlayers = defaultMinPlayers;
} }

View File

@ -86,7 +86,7 @@ public class WarBlockListener extends BlockListener {
} }
// buildInZonesOnly // buildInZonesOnly
if (zone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player)) { if (zone == null && War.war.isBuildInZonesOnly() && !War.war.canBuildOutsideZone(player) && !War.war.isDisableBuildMessage()) {
War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside."); War.war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -481,7 +481,7 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
if (playerWarzone.isTeamFlagStolen(playerTeam)) { if (playerWarzone.isTeamFlagStolen(playerTeam) && playerWarzone.isFlagMustBeHome()) {
War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned."); War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
} else { } else {
synchronized (playerWarzone) { synchronized (playerWarzone) {

13
war/src/main/java/com/tommytony/war/Warzone.java Normal file → Executable file
View File

@ -61,6 +61,7 @@ public class Warzone {
private ZoneLobby lobby; private ZoneLobby lobby;
private boolean autoAssignOnly = false; private boolean autoAssignOnly = false;
private boolean flagPointsOnly = false; private boolean flagPointsOnly = false;
private boolean flagMustBeHome = true;
private boolean blockHeads = true; private boolean blockHeads = true;
private boolean unbreakableZoneBlocks = false; private boolean unbreakableZoneBlocks = false;
private boolean disabled = false; private boolean disabled = false;
@ -83,6 +84,7 @@ public class Warzone {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Warzone(World world, String name) { public Warzone(World world, String name) {
War.war.log("DERP",Level.INFO);
this.world = world; this.world = world;
this.name = name; this.name = name;
this.friendlyFire = War.war.isDefaultFriendlyFire(); this.friendlyFire = War.war.isDefaultFriendlyFire();
@ -92,6 +94,7 @@ public class Warzone {
this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone(); this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone();
this.autoAssignOnly = War.war.isDefaultAutoAssignOnly(); this.autoAssignOnly = War.war.isDefaultAutoAssignOnly();
this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly()); this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
this.setFlagMustBeHome(War.war.isDefaultFlagMustBeHome());
this.teamCap = War.war.getDefaultTeamCap(); this.teamCap = War.war.getDefaultTeamCap();
this.scoreCap = War.war.getDefaultScoreCap(); this.scoreCap = War.war.getDefaultScoreCap();
this.monumentHeal = War.war.getDefaultMonumentHeal(); this.monumentHeal = War.war.getDefaultMonumentHeal();
@ -121,7 +124,7 @@ public class Warzone {
// perfect match, return right away // perfect match, return right away
return warzone; return warzone;
} else if (warzone.getName().toLowerCase().startsWith(name.toLowerCase())) { } else if (warzone.getName().toLowerCase().startsWith(name.toLowerCase())) {
// prehaps there's a perfect match in the remaining zones, let's take this one aside // perhaps there's a perfect match in the remaining zones, let's take this one aside
bestGuess = warzone; bestGuess = warzone;
} }
} }
@ -1156,6 +1159,14 @@ public class Warzone {
return this.flagPointsOnly; return this.flagPointsOnly;
} }
public void setFlagMustBeHome(boolean flagMustBeHome) {
this.flagMustBeHome = flagMustBeHome;
}
public boolean isFlagMustBeHome() {
return this.flagMustBeHome;
}
public void setMinPlayers(int minPlayers) { public void setMinPlayers(int minPlayers) {
this.minPlayers = minPlayers; this.minPlayers = minPlayers;
} }

View File

@ -139,6 +139,11 @@ public class WarMapper {
War.war.setDefaultFlagPointsOnly(warConfig.getBoolean("defaultFlagPointsOnly")); War.war.setDefaultFlagPointsOnly(warConfig.getBoolean("defaultFlagPointsOnly"));
} }
// defaultFlagMustBeHome
if (warConfig.keyExists("defaultFlagMustBeHome")) {
War.war.setDefaultFlagMustBeHome(warConfig.getBoolean("defaultFlagMustBeHome"));
}
// defaultTeamCap // defaultTeamCap
if (warConfig.keyExists("defaultTeamCap")) { if (warConfig.keyExists("defaultTeamCap")) {
War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap")); War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
@ -347,6 +352,9 @@ public class WarMapper {
// defaultFlagPointsOnly // defaultFlagPointsOnly
warConfig.setBoolean("defaultFlagPointsOnly", War.war.isDefaultFlagPointsOnly()); warConfig.setBoolean("defaultFlagPointsOnly", War.war.isDefaultFlagPointsOnly());
// defaultFlagMustBeHome
warConfig.setBoolean("defaultFlagMustBeHome", War.war.isDefaultFlagMustBeHome());
// defaultTeamCap // defaultTeamCap
warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap()); warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap());
@ -365,13 +373,16 @@ public class WarMapper {
// disablePVPMessage // disablePVPMessage
warConfig.setBoolean("disablePvpMessage", War.war.isDisablePvpMessage()); warConfig.setBoolean("disablePvpMessage", War.war.isDisablePvpMessage());
// disableBuildMessage
warConfig.setBoolean("disableBuildMessage", War.war.isDisableBuildMessage());
// tntInZonesOnly // tntInZonesOnly
warConfig.setBoolean("tntInZonesOnly", War.war.isTntInZonesOnly()); warConfig.setBoolean("tntInZonesOnly", War.war.isTntInZonesOnly());
// spawnStyle // spawnStyle
warConfig.setString("spawnStyle", War.war.getDefaultSpawnStyle().toString()); warConfig.setString("spawnStyle", War.war.getDefaultSpawnStyle().toString());
// spawnStyle // flagReturn
warConfig.setString("flagReturn", War.war.getDefaultFlagReturn().toString()); warConfig.setString("flagReturn", War.war.getDefaultFlagReturn().toString());
// defaultReward // defaultReward

View File

@ -196,6 +196,11 @@ public class WarzoneMapper {
warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly")); warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly"));
} }
// flagPointsOnly
if (warzoneConfig.containsKey("flagMustBeHome")) {
warzone.setFlagMustBeHome(warzoneConfig.getBoolean("flagMustBeHome"));
}
// team cap // team cap
if (warzoneConfig.containsKey("teamCap")) { if (warzoneConfig.containsKey("teamCap")) {
warzone.setTeamCap(warzoneConfig.getInt("teamCap")); warzone.setTeamCap(warzoneConfig.getInt("teamCap"));
@ -480,9 +485,12 @@ public class WarzoneMapper {
// autoAssignOnly // autoAssignOnly
warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly()); warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly());
// flagPointsOnly-+ // flagPointsOnly
warzoneConfig.setBoolean("flagPointsOnly", warzone.isFlagPointsOnly()); warzoneConfig.setBoolean("flagPointsOnly", warzone.isFlagPointsOnly());
// flagMustBeHome
warzoneConfig.setBoolean("flagMustBeHome", warzone.isFlagMustBeHome());
// team cap // team cap
warzoneConfig.setInt("teamCap", warzone.getTeamCap()); warzoneConfig.setInt("teamCap", warzone.getTeamCap());