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

View File

@ -86,7 +86,7 @@ public class WarBlockListener extends BlockListener {
}
// 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.");
event.setCancelled(true);
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.");
} else {
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 boolean autoAssignOnly = false;
private boolean flagPointsOnly = false;
private boolean flagMustBeHome = true;
private boolean blockHeads = true;
private boolean unbreakableZoneBlocks = false;
private boolean disabled = false;
@ -83,6 +84,7 @@ public class Warzone {
@SuppressWarnings("unchecked")
public Warzone(World world, String name) {
War.war.log("DERP",Level.INFO);
this.world = world;
this.name = name;
this.friendlyFire = War.war.isDefaultFriendlyFire();
@ -92,6 +94,7 @@ public class Warzone {
this.reward = (HashMap<Integer, ItemStack>)War.war.getDefaultReward().clone();
this.autoAssignOnly = War.war.isDefaultAutoAssignOnly();
this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
this.setFlagMustBeHome(War.war.isDefaultFlagMustBeHome());
this.teamCap = War.war.getDefaultTeamCap();
this.scoreCap = War.war.getDefaultScoreCap();
this.monumentHeal = War.war.getDefaultMonumentHeal();
@ -121,7 +124,7 @@ public class Warzone {
// perfect match, return right away
return warzone;
} 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;
}
}
@ -1156,6 +1159,14 @@ public class Warzone {
return this.flagPointsOnly;
}
public void setFlagMustBeHome(boolean flagMustBeHome) {
this.flagMustBeHome = flagMustBeHome;
}
public boolean isFlagMustBeHome() {
return this.flagMustBeHome;
}
public void setMinPlayers(int minPlayers) {
this.minPlayers = minPlayers;
}

View File

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

View File

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