Closes gh-58. Added unbreakableZoneBlocks setting. Zone makers are not affected.

This commit is contained in:
taoneill 2011-02-15 09:44:16 -05:00
parent bb66feab2d
commit 10ae82999b
5 changed files with 49 additions and 3 deletions

View File

@ -77,6 +77,7 @@ public class War extends JavaPlugin {
private boolean defaultDropLootOnDeath = false;
private String defaultSpawnStyle = TeamSpawnStyles.BIG;
private final HashMap<Integer, ItemStack> defaultReward = new HashMap<Integer, ItemStack>();
private boolean defaultUnbreakableZoneBlocks = false;
private boolean pvpInZonesOnly = false;
private boolean buildInZonesOnly = false;
@ -1056,6 +1057,10 @@ public class War extends JavaPlugin {
warzone.setSpawnStyle(TeamSpawnStyles.BIG);
}
}
if(namedParams.containsKey("unbreakable")) {
String onOff = namedParams.get("unbreakable");
warzone.setUnbreakableZoneBlocks(onOff.equals("on") || onOff.equals("true"));
}
// if(namedParams.containsKey("dropLootOnDeath")){
// String onOff = namedParams.get("dropLootOnDeath");
// warzone.setDropLootOnDeath(onOff.equals("on") || onOff.equals("true"));
@ -1118,6 +1123,10 @@ public class War extends JavaPlugin {
String onOff = namedParams.get("buildinzonesonly");
setBuildInZonesOnly(onOff.equals("on") || onOff.equals("true"));
}
if(namedParams.containsKey("unbreakable")) {
String onOff = namedParams.get("unbreakable");
setDefaultUnbreakableZoneBlocks(onOff.equals("on") || onOff.equals("true"));
}
// if(namedParams.containsKey("dropLootOnDeath")){
// String onOff = namedParams.get("dropLootOnDeath");
// setDefaultDropLootOnDeath(onOff.equals("on") || onOff.equals("true"));
@ -1459,5 +1468,13 @@ public class War extends JavaPlugin {
public boolean isBuildInZonesOnly() {
return buildInZonesOnly;
}
public void setDefaultUnbreakableZoneBlocks(boolean defaultUnbreakableZoneBlocks) {
this.defaultUnbreakableZoneBlocks = defaultUnbreakableZoneBlocks;
}
public boolean isDefaultUnbreakableZoneBlocks() {
return defaultUnbreakableZoneBlocks;
}
}

View File

@ -134,7 +134,7 @@ public class WarBlockListener extends BlockListener {
event.setCancelled(true);
return;
} else {
event.setCancelled(false);
event.setCancelled(false); // very important, otherwise could get cancelled but unbreakableZoneBlocks further down
return;
}
// let team members loot one block the spawn for monument captures
@ -165,7 +165,7 @@ public class WarBlockListener extends BlockListener {
event.setCancelled(true);
return;
}
}
}
// protect warzone lobbies
if(block != null) {
@ -187,12 +187,21 @@ public class WarBlockListener extends BlockListener {
}
// buildInZonesOnly
if(war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ())) == null
Warzone blockZone = war.warzone(new Location(block.getWorld(), block.getX(), block.getY(), block.getZ()));
if(blockZone == null
&& war.isBuildInZonesOnly()
&& !war.canBuildOutsideZone(player)) {
war.badMsg(player, "You can only build inside warzones. Ask for the 'war.build' permission to build outside.");
event.setCancelled(true);
return;
}
// unbreakableZoneBlocks
if(blockZone != null && blockZone.isUnbreakableZoneBlocks() && !isZoneMaker) {
// if the zone is unbreakable, no one but zone makers can break blocks
war.badMsg(player, "The blocks in this zone are unbreakable!");
event.setCancelled(true);
return;
}
}
}

View File

@ -55,6 +55,7 @@ public class Warzone {
private boolean autoAssignOnly;
private boolean blockHeads;
private boolean dropLootOnDeath;
private boolean unbreakableZoneBlocks;
public Warzone(War war, World world, String name) {
@ -70,6 +71,7 @@ public class Warzone {
this.scoreCap = war.getDefaultScoreCap();
this.setBlockHeads(war.isDefaultBlockHeads());
this.setDropLootOnDeath(war.isDefaultDropLootOnDeath());
this.setUnbreakableZoneBlocks(war.isDefaultUnbreakableZoneBlocks());
this.volume = new VerticalVolume(name, war, this.getWorld());
}
@ -1104,5 +1106,13 @@ public class Warzone {
return reward;
}
public void setUnbreakableZoneBlocks(boolean unbreakableZoneBlocks) {
this.unbreakableZoneBlocks = unbreakableZoneBlocks;
}
public boolean isUnbreakableZoneBlocks() {
return unbreakableZoneBlocks;
}
}

View File

@ -141,6 +141,8 @@ public class WarMapper {
}
}
// defaultUnbreakableZoneBlocks
war.setDefaultUnbreakableZoneBlocks(warConfig.getBoolean("defaultUnbreakableZoneBlocks"));
// defaultDropLootOnDeath
//war.setDefaultDropLootOnDeath(warConfig.getBoolean("defaultDropLootOnDeath"));
@ -245,6 +247,9 @@ public class WarMapper {
defaultRewardStr += item.getTypeId() + "," + item.getAmount() + "," + slot + ";";
}
warConfig.setString("defaultReward", defaultRewardStr);
// defaultUnbreakableZoneBlocks
warConfig.setBoolean("defaultUnbreakableZoneBlocks", war.isDefaultUnbreakableZoneBlocks());
// defaultDropLootOnDeath
//warConfig.setBoolean("defaultDropLootOnDeath", war.isDefaultDropLootOnDeath());

View File

@ -208,6 +208,9 @@ public class WarzoneMapper {
}
}
// unbreakableZoneBlocks
warzone.setUnbreakableZoneBlocks(warzoneConfig.getBoolean("unbreakableZoneBlocks"));
// dropLootOnDeath
//warzone.setDropLootOnDeath(warzoneConfig.getBoolean("dropLootOnDeath"));
@ -389,6 +392,8 @@ public class WarzoneMapper {
}
warzoneConfig.setString("reward", rewardStr);
// unbreakableZoneBlocks
warzoneConfig.setBoolean("unbreakableZoneBlocks", warzone.isUnbreakableZoneBlocks());
// defaultDropLootOnDeath
//warzoneConfig.setBoolean("dropLootOnDeath", warzone.isDropLootOnDeath());