Finished regain-health-prevention

This commit is contained in:
TimWolla 2011-05-22 22:34:18 +02:00
parent 7cafc2dde5
commit 9e7ec98789
2 changed files with 14 additions and 3 deletions

View File

@ -156,6 +156,7 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);

View File

@ -208,8 +208,18 @@ public class WarEntityListener extends EntityListener {
}
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if(!war.isLoaded()) return;
if (((org.bukkit.craftbukkit.entity.CraftPlayer) event.getEntity()).getHandle().ticksLived % 20 * 12 == 0)
event.setCancelled(true);
if(war.isLoaded()) {
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;
Location location = player.getLocation();
Warzone zone = war.warzone(location);
if(zone != null) {
if (((CraftPlayer) player).getHandle().ticksLived % 20 * 12 == 0) {
event.setCancelled(true);
}
}
}
}
}
}