Closes gh-227. Emtpy chests and dispenser don't crash teh zone reset (or the server) anymore. Sorry.

This commit is contained in:
taoneill 2011-07-03 16:42:18 -04:00
parent 6929b81dc4
commit 06653e6633
8 changed files with 30 additions and 26 deletions

View File

@ -16,6 +16,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
//import org.bukkit.event.entity.EntityRegainHealthEvent;
import com.tommytony.war.Team;
@ -213,7 +214,7 @@ public class WarEntityListener extends EntityListener {
}
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if(war.isLoaded()) {
if(war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;

View File

@ -75,7 +75,6 @@ public class Team {
int y = teamSpawn.getBlockY();
int z = teamSpawn.getBlockZ();
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
// nothing but glowstone
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);

View File

@ -321,6 +321,9 @@ public class Warzone {
public void setLifePool(int lifePool) {
this.lifePool = lifePool;
for(Team team : teams) {
team.setRemainingLives(lifePool);
}
}
public int getLifePool() {

View File

@ -23,7 +23,7 @@ public class RestoreWarzonesJob implements Runnable {
for(String warzoneName : warzoneSplit) {
if(warzoneName != null && !warzoneName.equals("")){
war.logInfo("Restoring zone " + warzoneName + "...");
Warzone zone = WarzoneMapper.load(war, warzoneName, !newWarInstall); // cascade load, only load blocks if warzone exists
Warzone zone = WarzoneMapper.load(war, warzoneName, !newWarInstall);
if(zone != null) { // could have failed, would've been logged already
war.getWarzones().add(zone);
//zone.getVolume().loadCorners();

View File

@ -47,7 +47,6 @@ public class WarzoneMapper {
world = war.getServer().getWorld(worldStr);
}
if(world == null) {
war.logWarn("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!");
} else {
@ -144,7 +143,7 @@ public class WarzoneMapper {
}
}
// life pool
// life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
// monument heal //SY

View File

@ -271,25 +271,27 @@ public class ZoneVolumeMapper {
private static List<ItemStack> readInventoryString(String invString) {
List<ItemStack> items = new ArrayList<ItemStack>();
String[] itemsStrSplit = invString.split(";;");
for(String itemStr : itemsStrSplit) {
String[] itemStrSplit = itemStr.split(";");
if(itemStrSplit.length == 4) {
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1]));
stack.setData(new MaterialData(stack.getTypeId(),Byte.parseByte(itemStrSplit[3])));
short durability = (short)Integer.parseInt(itemStrSplit[2]);
stack.setDurability(durability);
items.add(stack);
} else if(itemStrSplit.length == 3) {
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1]));
short durability = (short)Integer.parseInt(itemStrSplit[2]);
stack.setDurability(durability);
items.add(stack);
} else {
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1])));
if(invString != null && !invString.equals("")) {
String[] itemsStrSplit = invString.split(";;");
for(String itemStr : itemsStrSplit) {
String[] itemStrSplit = itemStr.split(";");
if(itemStrSplit.length == 4) {
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1]));
stack.setData(new MaterialData(stack.getTypeId(),Byte.parseByte(itemStrSplit[3])));
short durability = (short)Integer.parseInt(itemStrSplit[2]);
stack.setDurability(durability);
items.add(stack);
} else if(itemStrSplit.length == 3) {
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1]));
short durability = (short)Integer.parseInt(itemStrSplit[2]);
stack.setDurability(durability);
items.add(stack);
} else {
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
Integer.parseInt(itemStrSplit[1])));
}
}
}
return items;

View File

@ -1,5 +1,5 @@
name: War
version: 1.6 (de Gaulle)
version: 1.6 (de Gaulle) PREVIEW 2
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony
website: war.tommytony.com

View File

@ -1,5 +1,5 @@
name: War
version: 1.6 (de Gaulle)
version: 1.6 (de Gaulle) PREVIEW 2
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
author: tommytony
website: war.tommytony.com