mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Closes gh-227. Emtpy chests and dispenser don't crash teh zone reset (or the server) anymore. Sorry.
This commit is contained in:
parent
6929b81dc4
commit
06653e6633
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user