mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 12:46:11 +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.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
//import org.bukkit.event.entity.EntityRegainHealthEvent;
|
//import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
|
|
||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.Team;
|
||||||
@ -213,7 +214,7 @@ public class WarEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded() && event.getRegainReason() == RegainReason.REGEN) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if(entity instanceof Player) {
|
if(entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
|
@ -75,7 +75,6 @@ public class Team {
|
|||||||
int y = teamSpawn.getBlockY();
|
int y = teamSpawn.getBlockY();
|
||||||
int z = teamSpawn.getBlockZ();
|
int z = teamSpawn.getBlockZ();
|
||||||
|
|
||||||
|
|
||||||
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
if(warzone.getSpawnStyle().equals(TeamSpawnStyles.INVISIBLE)) {
|
||||||
// nothing but glowstone
|
// nothing but glowstone
|
||||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.GLOWSTONE);
|
||||||
|
@ -321,6 +321,9 @@ public class Warzone {
|
|||||||
|
|
||||||
public void setLifePool(int lifePool) {
|
public void setLifePool(int lifePool) {
|
||||||
this.lifePool = lifePool;
|
this.lifePool = lifePool;
|
||||||
|
for(Team team : teams) {
|
||||||
|
team.setRemainingLives(lifePool);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLifePool() {
|
public int getLifePool() {
|
||||||
|
@ -23,7 +23,7 @@ public class RestoreWarzonesJob implements Runnable {
|
|||||||
for(String warzoneName : warzoneSplit) {
|
for(String warzoneName : warzoneSplit) {
|
||||||
if(warzoneName != null && !warzoneName.equals("")){
|
if(warzoneName != null && !warzoneName.equals("")){
|
||||||
war.logInfo("Restoring zone " + warzoneName + "...");
|
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
|
if(zone != null) { // could have failed, would've been logged already
|
||||||
war.getWarzones().add(zone);
|
war.getWarzones().add(zone);
|
||||||
//zone.getVolume().loadCorners();
|
//zone.getVolume().loadCorners();
|
||||||
|
@ -47,7 +47,6 @@ public class WarzoneMapper {
|
|||||||
world = war.getServer().getWorld(worldStr);
|
world = war.getServer().getWorld(worldStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(world == null) {
|
if(world == null) {
|
||||||
war.logWarn("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!");
|
war.logWarn("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!");
|
||||||
} else {
|
} 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"));
|
warzone.setLifePool(warzoneConfig.getInt("lifePool"));
|
||||||
|
|
||||||
// monument heal //SY
|
// monument heal //SY
|
||||||
|
@ -271,25 +271,27 @@ public class ZoneVolumeMapper {
|
|||||||
|
|
||||||
private static List<ItemStack> readInventoryString(String invString) {
|
private static List<ItemStack> readInventoryString(String invString) {
|
||||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
String[] itemsStrSplit = invString.split(";;");
|
if(invString != null && !invString.equals("")) {
|
||||||
for(String itemStr : itemsStrSplit) {
|
String[] itemsStrSplit = invString.split(";;");
|
||||||
String[] itemStrSplit = itemStr.split(";");
|
for(String itemStr : itemsStrSplit) {
|
||||||
if(itemStrSplit.length == 4) {
|
String[] itemStrSplit = itemStr.split(";");
|
||||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
if(itemStrSplit.length == 4) {
|
||||||
Integer.parseInt(itemStrSplit[1]));
|
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||||
stack.setData(new MaterialData(stack.getTypeId(),Byte.parseByte(itemStrSplit[3])));
|
Integer.parseInt(itemStrSplit[1]));
|
||||||
short durability = (short)Integer.parseInt(itemStrSplit[2]);
|
stack.setData(new MaterialData(stack.getTypeId(),Byte.parseByte(itemStrSplit[3])));
|
||||||
stack.setDurability(durability);
|
short durability = (short)Integer.parseInt(itemStrSplit[2]);
|
||||||
items.add(stack);
|
stack.setDurability(durability);
|
||||||
} else if(itemStrSplit.length == 3) {
|
items.add(stack);
|
||||||
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
} else if(itemStrSplit.length == 3) {
|
||||||
Integer.parseInt(itemStrSplit[1]));
|
ItemStack stack = new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||||
short durability = (short)Integer.parseInt(itemStrSplit[2]);
|
Integer.parseInt(itemStrSplit[1]));
|
||||||
stack.setDurability(durability);
|
short durability = (short)Integer.parseInt(itemStrSplit[2]);
|
||||||
items.add(stack);
|
stack.setDurability(durability);
|
||||||
} else {
|
items.add(stack);
|
||||||
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
} else {
|
||||||
Integer.parseInt(itemStrSplit[1])));
|
items.add(new ItemStack(Integer.parseInt(itemStrSplit[0]),
|
||||||
|
Integer.parseInt(itemStrSplit[1])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: War
|
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.
|
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
|
||||||
author: tommytony
|
author: tommytony
|
||||||
website: war.tommytony.com
|
website: war.tommytony.com
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: War
|
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.
|
description: Lets you create TDM and CTF (warzones) for a more structured PVP experience.
|
||||||
author: tommytony
|
author: tommytony
|
||||||
website: war.tommytony.com
|
website: war.tommytony.com
|
||||||
|
Loading…
Reference in New Issue
Block a user