Closes gh-426. Closes gh-341. Bomb carrier doesn't blow up if warzone is unbreakable:true. Helmets can now be part of loadout if blockheads:false. When realdeaths:true, players don't get -Use /leave to exit- message spam when dying anymore.

This commit is contained in:
taoneill 2012-04-01 12:38:07 -04:00
parent bdae9df6b7
commit 2afc40fb00
4 changed files with 24 additions and 39 deletions

View File

@ -292,6 +292,9 @@ public class War extends JavaPlugin {
if (inv.getChestplate() != null && inv.getChestplate().getType() != Material.AIR) {
loadout.put(102, this.copyStack(inv.getChestplate()));
}
if (inv.getHelmet() != null && inv.getHelmet().getType() != Material.AIR) {
loadout.put(103, this.copyStack(inv.getHelmet()));
}
}
public ItemStack copyStack(ItemStack originalStack) {

View File

@ -374,6 +374,7 @@ public class Warzone {
playerInv.clear(playerInv.getSize() + 1);
playerInv.clear(playerInv.getSize() + 2);
playerInv.clear(playerInv.getSize() + 3); // helmet/blockHead
boolean helmetIsInLoadout = false;
for (Integer slot : loadout.keySet()) {
if (slot == 100) {
playerInv.setBoots(War.war.copyStack(loadout.get(slot)));
@ -381,6 +382,9 @@ public class Warzone {
playerInv.setLeggings(War.war.copyStack(loadout.get(slot)));
} else if (slot == 102) {
playerInv.setChestplate(War.war.copyStack(loadout.get(slot)));
} else if (slot == 103) {
playerInv.setHelmet(War.war.copyStack(loadout.get(slot)));
helmetIsInLoadout = true;
} else {
ItemStack item = loadout.get(slot);
if (item != null) {
@ -391,14 +395,16 @@ public class Warzone {
if (this.getWarzoneConfig().getBoolean(WarzoneConfig.BLOCKHEADS)) {
playerInv.setHelmet(new ItemStack(team.getKind().getMaterial(), 1, (short) 1, new Byte(team.getKind().getData())));
} else {
if (team.getKind() == TeamKind.GOLD) {
playerInv.setHelmet(new ItemStack(Material.GOLD_HELMET));
} else if (team.getKind() == TeamKind.DIAMOND) {
playerInv.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
} else if (team.getKind() == TeamKind.IRON) {
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
} else {
playerInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
if (!helmetIsInLoadout) {
if (team.getKind() == TeamKind.GOLD) {
playerInv.setHelmet(new ItemStack(Material.GOLD_HELMET));
} else if (team.getKind() == TeamKind.DIAMOND) {
playerInv.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
} else if (team.getKind() == TeamKind.IRON) {
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
} else {
playerInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
}
}
}
}
@ -514,13 +520,6 @@ public class Warzone {
}
}
public PlayerState getPlayerState(String playerName) {
if (this.playerStates.containsKey(playerName)) {
return this.playerStates.get(playerName);
}
return null;
}
public boolean hasMonument(String monumentName) {
for (Monument monument : this.monuments) {
if (monument.getName().startsWith(monumentName)) {

View File

@ -388,7 +388,9 @@ public class WarPlayerListener implements Listener {
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
if (locZone == null && playerTeam != null && playerWarzone.getLobby() != null && !playerWarzone.getLobby().getVolume().contains(playerLoc) && !isLeaving) {
List<BlockFace> nearestWalls = playerWarzone.getNearestWalls(playerLoc);
War.war.badMsg(player, "Use /leave (or /war leave) to exit the zone.");
if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
War.war.badMsg(player, "Use /leave (or /war leave) to exit the zone.");
}
if(nearestWalls != null && nearestWalls.size() > 0) {
// First, try to bump the player back in
int northSouthMove = 0;
@ -571,7 +573,10 @@ public class WarPlayerListener implements Listener {
Bomb bomb = playerWarzone.getBombForThief(player.getName());
// Boom!
playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
// Don't blow up if warzone is unbreakable
playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
}
playerTeam.addPoint();

View File

@ -63,28 +63,6 @@ public class HelmetProtectionTask implements Runnable {
War.war.badMsg(player, "All that " + team.getName() + " wool must have been heavy!");
}
}
} else {
// enforce helmet (good thing?)
if (team.getKind() == TeamKind.GOLD) {
teamBlockMaterial = Material.GOLD_HELMET;
} else if (team.getKind() == TeamKind.DIAMOND) {
teamBlockMaterial = Material.DIAMOND_HELMET;
} else if (team.getKind() == TeamKind.IRON) {
teamBlockMaterial = Material.IRON_HELMET;
} else {
teamBlockMaterial = Material.LEATHER_HELMET;
}
if (playerInv.getHelmet() == null || playerInv.getHelmet().getType() != teamBlockMaterial) {
playerInv.setHelmet(new ItemStack(teamBlockMaterial));
}
HashMap<Integer, ? extends ItemStack> helmets = playerInv.all(teamBlockMaterial);
if (helmets.size() > 1 || (helmets.size() == 1 && helmets.get(helmets.keySet().iterator().next()).getAmount() > 1)) {
playerInv.remove(teamBlockMaterial);
playerInv.setItem(playerInv.firstEmpty(), new ItemStack(teamBlockMaterial));
War.war.badMsg(player, "All those helmets must have been heavy!");
}
}
// check for thieves without their treasure in their hands