Uncancels damage event first (Disabling of /god)

This commit is contained in:
TimWolla 2011-07-10 18:21:12 +02:00
parent 6c0212d405
commit bd6d02ba76
2 changed files with 7 additions and 3 deletions

View File

@ -143,7 +143,7 @@ public class War extends JavaPlugin {
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
//pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.High, 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);
@ -1618,4 +1618,4 @@ public class War extends JavaPlugin {
public boolean isLoaded() {
return loaded;
}
}
}

View File

@ -165,12 +165,16 @@ public class WarEntityListener extends EntityListener {
public void onEntityDamage(EntityDamageEvent event) {
if(war.isLoaded()) {
Entity entity = event.getEntity();
if(entity instanceof Player && war.getPlayerTeamWarzone(((Player) entity).getName()) != null) {
event.setCancelled(false);
}
if(event instanceof EntityDamageByEntityEvent ||
event instanceof EntityDamageByProjectileEvent) {
handlerAttackDefend((EntityDamageByEntityEvent)event);
} else {
// Detect death (from , prevent it and respawn the player
Entity entity = event.getEntity();
if(entity instanceof Player) {
Player player = (Player) entity;
Warzone zone = war.getPlayerTeamWarzone(player.getName());