Allow disableautoheal

This commit is contained in:
Eric Stokes 2011-06-30 18:40:57 -06:00
parent 1024506f8c
commit 72fc006795
2 changed files with 16 additions and 1 deletions

View File

@ -14,6 +14,8 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDeathEvent; 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.RegainReason;
//import org.bukkit.event.entity.ExplosionPrimedEvent; //import org.bukkit.event.entity.ExplosionPrimedEvent;
@ -40,6 +42,18 @@ public class MVEntityListener extends EntityListener {
} }
super.onEntityDeath(event); super.onEntityDeath(event);
} }
@Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if(event.isCancelled()) {
return;
}
RegainReason reason = event.getRegainReason();
if(reason == RegainReason.REGEN && this.plugin.configMV.getBoolean("disableautoheal", false)) {
event.setCancelled(true);
return;
}
}
/** /**
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. * Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.

View File

@ -124,7 +124,8 @@ public class MultiverseCore extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this); pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, this.entityListener, Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth. pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning. pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.