Closes gh-267. Glass walls can be turned off with glasswalls:off. Clearing the latest locations at unload - hello big leak.

This commit is contained in:
taoneill 2011-09-13 00:13:59 -04:00
commit b62e8ffd53
6 changed files with 102 additions and 41 deletions

View File

@ -73,6 +73,7 @@ public class War extends JavaPlugin {
private boolean defaultBlockHeads = true; private boolean defaultBlockHeads = true;
private boolean defaultFriendlyFire = false; private boolean defaultFriendlyFire = false;
private boolean defaultAutoAssignOnly = false; private boolean defaultAutoAssignOnly = false;
private boolean defaultFlagPointsOnly = false;
private boolean defaultUnbreakableZoneBlocks = false; private boolean defaultUnbreakableZoneBlocks = false;
private boolean defaultNoCreatures = false; private boolean defaultNoCreatures = false;
private boolean defaultGlassWalls = true; private boolean defaultGlassWalls = true;
@ -164,6 +165,7 @@ public class War extends JavaPlugin {
} }
this.getServer().getScheduler().cancelTasks(this); this.getServer().getScheduler().cancelTasks(this);
this.playerListener.purgeLatestPositions();
this.log("War v" + this.desc.getVersion() + " is off.", Level.INFO); this.log("War v" + this.desc.getVersion() + " is off.", Level.INFO);
this.setLoaded(false); this.setLoaded(false);
@ -260,6 +262,10 @@ public class War extends JavaPlugin {
String onOff = namedParams.get("autoassign"); String onOff = namedParams.get("autoassign");
warzone.setAutoAssignOnly(onOff.equals("on") || onOff.equals("true")); warzone.setAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
} }
if (namedParams.containsKey("flagpointsonly")) {
String onOff = namedParams.get("flagpointsonly");
warzone.setFlagPointsOnly(onOff.equals("on") || onOff.equals("true"));
}
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"));
@ -352,6 +358,10 @@ public class War extends JavaPlugin {
String onOff = namedParams.get("autoassign"); String onOff = namedParams.get("autoassign");
this.setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true")); 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"));
}
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"));
@ -390,6 +400,10 @@ public class War extends JavaPlugin {
String onOff = namedParams.get("nocreatures"); String onOff = namedParams.get("nocreatures");
this.setDefaultNoCreatures(onOff.equals("on") || onOff.equals("true")); this.setDefaultNoCreatures(onOff.equals("on") || onOff.equals("true"));
} }
if (namedParams.containsKey("glasswalls")) {
String onOff = namedParams.get("glasswalls");
this.setDefaultGlassWalls(onOff.equals("on") || onOff.equals("true"));
}
if (namedParams.containsKey("resetonempty")) { if (namedParams.containsKey("resetonempty")) {
String onOff = namedParams.get("resetonempty"); String onOff = namedParams.get("resetonempty");
@ -428,7 +442,8 @@ public class War extends JavaPlugin {
+ " teamsize:" + zone.getTeamCap() + " teamsize:" + zone.getTeamCap()
+ " maxscore:" + zone.getScoreCap() + " maxscore:" + zone.getScoreCap()
+ " ff:" + String.valueOf(zone.getFriendlyFire()) + " ff:" + String.valueOf(zone.getFriendlyFire())
+ " autoassign:" + String.valueOf(zone.getAutoAssignOnly()) + " autoassign:" + String.valueOf(zone.isAutoAssignOnly())
+ " flagpointsonly:" + String.valueOf(zone.isFlagPointsOnly())
+ " blockheads:" + String.valueOf(zone.isBlockHeads()) + " blockheads:" + String.valueOf(zone.isBlockHeads())
+ " spawnstyle:" + zone.getSpawnStyle() + " spawnstyle:" + zone.getSpawnStyle()
+ " flagreturn:" + zone.getFlagReturn() + " flagreturn:" + zone.getFlagReturn()
@ -436,6 +451,7 @@ public class War extends JavaPlugin {
+ " unbreakable:" + String.valueOf(zone.isUnbreakableZoneBlocks()) + " unbreakable:" + String.valueOf(zone.isUnbreakableZoneBlocks())
+ " disabled:" + String.valueOf(zone.isDisabled()) + " disabled:" + String.valueOf(zone.isDisabled())
+ " nocreatures:" + String.valueOf(zone.isNoCreatures()) + " nocreatures:" + String.valueOf(zone.isNoCreatures())
+ " glasswalls:" + String.valueOf(zone.isGlassWalls())
+ " resetonempty:" + String.valueOf(zone.isResetOnEmpty()) + " resetonempty:" + String.valueOf(zone.isResetOnEmpty())
+ " resetonload:" + String.valueOf(zone.isResetOnLoad()) + " resetonload:" + String.valueOf(zone.isResetOnLoad())
+ " resetonunload:" + String.valueOf(zone.isResetOnUnload()); + " resetonunload:" + String.valueOf(zone.isResetOnUnload());
@ -443,24 +459,26 @@ public class War extends JavaPlugin {
public String printConfig() { public String printConfig() {
return "War config -" return "War config -"
+ " pvpinzonesonly:" + String.valueOf(War.war.isPvpInZonesOnly()) + " pvpinzonesonly:" + String.valueOf(this.isPvpInZonesOnly())
+ " disablepvpmessage:" + String.valueOf(War.war.isDisablePvpMessage()) + " disablepvpmessage:" + String.valueOf(this.isDisablePvpMessage())
+ " buildinzonesonly:" + String.valueOf(War.war.isBuildInZonesOnly()) + " buildinzonesonly:" + String.valueOf(this.isBuildInZonesOnly())
+ " - Warzone defaults -" + " - Warzone defaults -"
+ " lifepool:" + War.war.getDefaultLifepool() + " lifepool:" + this.getDefaultLifepool()
+ " teamsize:" + War.war.getDefaultTeamCap() + " teamsize:" + this.getDefaultTeamCap()
+ " maxscore:" + War.war.getDefaultScoreCap() + " maxscore:" + this.getDefaultScoreCap()
+ " ff:" + String.valueOf(War.war.isDefaultFriendlyFire()) + " ff:" + String.valueOf(this.isDefaultFriendlyFire())
+ " autoassign:" + String.valueOf(War.war.isDefaultAutoAssignOnly()) + " autoassign:" + String.valueOf(this.isDefaultAutoAssignOnly())
+ " blockheads:" + String.valueOf(War.war.isDefaultBlockHeads()) + " flagpointsonly:" + String.valueOf(this.isDefaultFlagPointsOnly())
+ " spawnstyle:" + War.war.getDefaultSpawnStyle() + " blockheads:" + String.valueOf(this.isDefaultBlockHeads())
+ " flagreturn:" + War.war.getDefaultFlagReturn() + " spawnstyle:" + this.getDefaultSpawnStyle()
+ " monumentheal:" + War.war.getDefaultMonumentHeal() + " flagreturn:" + this.getDefaultFlagReturn()
+ " unbreakable:" + String.valueOf(War.war.isDefaultUnbreakableZoneBlocks()) + " monumentheal:" + this.getDefaultMonumentHeal()
+ " nocreatures:" + String.valueOf(War.war.isDefaultNoCreatures()) + " unbreakable:" + String.valueOf(this.isDefaultUnbreakableZoneBlocks())
+ " resetonempty:" + String.valueOf(War.war.isDefaultResetOnEmpty()) + " nocreatures:" + String.valueOf(this.isDefaultNoCreatures())
+ " resetonload:" + String.valueOf(War.war.isDefaultResetOnLoad()) + " glasswalls:" + String.valueOf(this.isDefaultGlassWalls())
+ " resetonunload:" + String.valueOf(War.war.isDefaultResetOnUnload()); + " resetonempty:" + String.valueOf(this.isDefaultResetOnEmpty())
+ " resetonload:" + String.valueOf(this.isDefaultResetOnLoad())
+ " resetonunload:" + String.valueOf(this.isDefaultResetOnUnload());
} }
private void setZoneRallyPoint(String warzoneName, Player player) { private void setZoneRallyPoint(String warzoneName, Player player) {
@ -898,6 +916,14 @@ public class War extends JavaPlugin {
} }
public boolean isDefaultGlassWalls() { public boolean isDefaultGlassWalls() {
return defaultGlassWalls; return this.defaultGlassWalls;
}
public void setDefaultFlagPointsOnly(boolean defaultFlagPointsOnly) {
this.defaultFlagPointsOnly = defaultFlagPointsOnly;
}
public boolean isDefaultFlagPointsOnly() {
return this.defaultFlagPointsOnly;
} }
} }

View File

@ -228,7 +228,8 @@ public class WarPlayerListener extends PlayerListener {
if (previousLocation != null && if (previousLocation != null &&
playerLoc.getBlockX() == previousLocation.getBlockX() && playerLoc.getBlockX() == previousLocation.getBlockX() &&
playerLoc.getBlockY() == previousLocation.getBlockY() && playerLoc.getBlockY() == previousLocation.getBlockY() &&
playerLoc.getBlockZ() == previousLocation.getBlockZ()) { playerLoc.getBlockZ() == previousLocation.getBlockZ() &&
playerLoc.getWorld() == previousLocation.getWorld()) {
// we only care when people change location // we only care when people change location
return; return;
} }
@ -451,6 +452,10 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
public void purgeLatestPositions() {
this.latestLocations.clear();
}
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) { private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
if (zone.getLobby() != null) { if (zone.getLobby() != null) {
War.war.badMsg(player, "This warzone is disabled."); War.war.badMsg(player, "This warzone is disabled.");
@ -467,4 +472,6 @@ public class WarPlayerListener extends PlayerListener {
} }
} }
} }
} }

View File

@ -55,6 +55,7 @@ public class Warzone {
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>(); private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
private ZoneLobby lobby; private ZoneLobby lobby;
private boolean autoAssignOnly; private boolean autoAssignOnly;
private boolean flagPointsOnly;
private boolean blockHeads; private boolean blockHeads;
private boolean unbreakableZoneBlocks; private boolean unbreakableZoneBlocks;
private boolean disabled = false; private boolean disabled = false;
@ -75,6 +76,7 @@ public class Warzone {
this.setLifePool(War.war.getDefaultLifepool()); this.setLifePool(War.war.getDefaultLifepool());
this.setLoadout(War.war.getDefaultLoadout()); this.setLoadout(War.war.getDefaultLoadout());
this.setAutoAssignOnly(War.war.isDefaultAutoAssignOnly()); this.setAutoAssignOnly(War.war.isDefaultAutoAssignOnly());
this.setFlagPointsOnly(War.war.isDefaultFlagPointsOnly());
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();
@ -169,6 +171,11 @@ public class Warzone {
return this.name; return this.name;
} }
@Override
public String toString() {
return this.getName();
}
public void setTeleport(Location location) { public void setTeleport(Location location) {
this.teleport = location; this.teleport = location;
} }
@ -383,6 +390,11 @@ public class Warzone {
return this.friendlyFire; return this.friendlyFire;
} }
public void setFriendlyFire(boolean ffOn) {
this.friendlyFire = ffOn;
}
public void setLoadout(HashMap<Integer, ItemStack> newLoadout) { public void setLoadout(HashMap<Integer, ItemStack> newLoadout) {
this.loadout.clear(); this.loadout.clear();
for (Integer slot : newLoadout.keySet()) { for (Integer slot : newLoadout.keySet()) {
@ -416,10 +428,6 @@ public class Warzone {
return this.monumentHeal; return this.monumentHeal;
} }
public void setFriendlyFire(boolean ffOn) {
this.friendlyFire = ffOn;
}
public boolean hasPlayerInventory(String playerName) { public boolean hasPlayerInventory(String playerName) {
return this.inventories.containsKey(playerName); return this.inventories.containsKey(playerName);
} }
@ -681,10 +689,6 @@ public class Warzone {
playerGuards.clear(); playerGuards.clear();
} }
public boolean getAutoAssignOnly() {
return this.isAutoAssignOnly();
}
public void setLobby(ZoneLobby lobby) { public void setLobby(ZoneLobby lobby) {
this.lobby = lobby; this.lobby = lobby;
} }
@ -756,7 +760,7 @@ public class Warzone {
for (Team t : teams) { for (Team t : teams) {
t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool."); t.teamcast("The battle is over. Team " + playerTeam.getName() + " lost: " + player.getName() + " died and there were no lives left in their life pool.");
if (t.getPlayers().size() != 0) { if (t.getPlayers().size() != 0 && !this.flagPointsOnly) {
if (!t.getName().equals(playerTeam.getName())) { if (!t.getName().equals(playerTeam.getName())) {
// all other teams get a point // all other teams get a point
t.addPoint(); t.addPoint();
@ -1083,6 +1087,14 @@ public class Warzone {
} }
public boolean isGlassWalls() { public boolean isGlassWalls() {
return glassWalls; return this.glassWalls;
}
public void setFlagPointsOnly(boolean flagPointsOnly) {
this.flagPointsOnly = flagPointsOnly;
}
public boolean isFlagPointsOnly() {
return this.flagPointsOnly;
} }
} }

View File

@ -362,7 +362,7 @@ public class ZoneLobby {
rightSide = BlockFace.SOUTH; rightSide = BlockFace.SOUTH;
} }
this.teamGateBlocks.clear(); this.teamGateBlocks.clear();
if (this.warzone.getAutoAssignOnly()) { if (this.warzone.isAutoAssignOnly()) {
this.autoAssignGate = new BlockInfo(lobbyMiddleWallBlock); this.autoAssignGate = new BlockInfo(lobbyMiddleWallBlock);
} else { } else {
this.autoAssignGate = null; this.autoAssignGate = null;

View File

@ -98,6 +98,9 @@ public class WarMapper {
// defaultAutoAssignOnly // defaultAutoAssignOnly
War.war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly")); War.war.setDefaultAutoAssignOnly(warConfig.getBoolean("defaultAutoAssignOnly"));
// defaultFlagPointsOnly
War.war.setDefaultFlagPointsOnly(warConfig.getBoolean("defaultFlagPointsOnly"));
// defaultTeamCap // defaultTeamCap
War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap")); War.war.setDefaultTeamCap(warConfig.getInt("defaultTeamCap"));
@ -148,6 +151,9 @@ public class WarMapper {
// defaultNoCreatures // defaultNoCreatures
War.war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures")); War.war.setDefaultNoCreatures(warConfig.getBoolean("defaultNoCreatures"));
// defaultGlassWalls
War.war.setDefaultGlassWalls(warConfig.getBoolean("defaultGlassWalls"));
// defaultResetOnEmpty // defaultResetOnEmpty
War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty")); War.war.setDefaultResetOnEmpty(warConfig.getBoolean("defaultResetOnEmpty"));
@ -216,6 +222,9 @@ public class WarMapper {
// defaultAutoAssignOnly // defaultAutoAssignOnly
warConfig.setBoolean("defaultAutoAssignOnly", War.war.isDefaultAutoAssignOnly()); warConfig.setBoolean("defaultAutoAssignOnly", War.war.isDefaultAutoAssignOnly());
// defaultFlagPointsOnly
warConfig.setBoolean("defaultFlagPointsOnly", War.war.isDefaultFlagPointsOnly());
// defaultTeamCap // defaultTeamCap
warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap()); warConfig.setInt("defaultTeamCap", War.war.getDefaultTeamCap());
@ -257,6 +266,9 @@ public class WarMapper {
// defaultNoCreatures // defaultNoCreatures
warConfig.setBoolean("defaultNoCreatures", War.war.isDefaultNoCreatures()); warConfig.setBoolean("defaultNoCreatures", War.war.isDefaultNoCreatures());
// defaultGlassWalls
warConfig.setBoolean("defaultGlassWalls", War.war.isDefaultGlassWalls());
// defaultResetOnEmpty // defaultResetOnEmpty
warConfig.setBoolean("defaultResetOnEmpty", War.war.isDefaultResetOnEmpty()); warConfig.setBoolean("defaultResetOnEmpty", War.war.isDefaultResetOnEmpty());
@ -266,9 +278,6 @@ public class WarMapper {
// defaultResetOnUnload // defaultResetOnUnload
warConfig.setBoolean("defaultResetOnUnload", War.war.isDefaultResetOnUnload()); warConfig.setBoolean("defaultResetOnUnload", War.war.isDefaultResetOnUnload());
// defaultDropLootOnDeath
// warConfig.setBoolean("defaultDropLootOnDeath", war.isDefaultDropLootOnDeath());
// warhub // warhub
String hubStr = ""; String hubStr = "";
WarHub hub = War.war.getWarHub(); WarHub hub = War.war.getWarHub();

View File

@ -150,6 +150,9 @@ public class WarzoneMapper {
// autoAssignOnly // autoAssignOnly
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("autoAssignOnly")); warzone.setAutoAssignOnly(warzoneConfig.getBoolean("autoAssignOnly"));
// flagPointsOnly
warzone.setAutoAssignOnly(warzoneConfig.getBoolean("flagPointsOnly"));
// team cap // team cap
warzone.setTeamCap(warzoneConfig.getInt("teamCap")); warzone.setTeamCap(warzoneConfig.getInt("teamCap"));
@ -191,9 +194,13 @@ public class WarzoneMapper {
// disabled // disabled
warzone.setDisabled(warzoneConfig.getBoolean("disabled")); warzone.setDisabled(warzoneConfig.getBoolean("disabled"));
// defaultNoCreatures // noCreatures
warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures")); warzone.setNoCreatures(warzoneConfig.getBoolean("noCreatures"));
// glassWalls
warzone.setGlassWalls(warzoneConfig.getBoolean("glassWalls"));
// resetOnEmpty // resetOnEmpty
warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty")); warzone.setResetOnEmpty(warzoneConfig.getBoolean("resetOnEmpty"));
@ -359,6 +366,9 @@ public class WarzoneMapper {
// autoAssignOnly // autoAssignOnly
warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly()); warzoneConfig.setBoolean("autoAssignOnly", warzone.isAutoAssignOnly());
// flagPointsOnly
warzoneConfig.setBoolean("flagPointsOnly", warzone.isFlagPointsOnly());
// team cap // team cap
warzoneConfig.setInt("teamCap", warzone.getTeamCap()); warzoneConfig.setInt("teamCap", warzone.getTeamCap());
@ -394,6 +404,9 @@ public class WarzoneMapper {
// noCreatures // noCreatures
warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures()); warzoneConfig.setBoolean("noCreatures", warzone.isNoCreatures());
// glassWalls
warzoneConfig.setBoolean("glassWalls", warzone.isGlassWalls());
// resetOnEmpty // resetOnEmpty
warzoneConfig.setBoolean("resetOnEmpty", warzone.isResetOnEmpty()); warzoneConfig.setBoolean("resetOnEmpty", warzone.isResetOnEmpty());
@ -462,12 +475,6 @@ public class WarzoneMapper {
if (warzone.getLobby() != null) { if (warzone.getLobby() != null) {
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName()); VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName());
} }
// if (saveBlocks) {
// war.getLogger().info("Saved warzone " + warzone.getName() + " config and blocks.");
// } else {
// war.getLogger().info("Saved warzone " + warzone.getName() + " config.");
// }
} }
public static void delete(String name) { public static void delete(String name) {