Moved fireball handling to somewhere that actually gets called by it...

This commit is contained in:
Wizjany 2011-06-29 15:43:01 -04:00
parent 3325feb1cb
commit d90b960597

View File

@ -76,6 +76,7 @@ public void registerEvents() {
registerEvent("ENTITY_DAMAGE", Priority.High);
registerEvent("ENTITY_COMBUST", Priority.High);
registerEvent("ENTITY_EXPLODE", Priority.High);
registerEvent("ENTITY_PRIME", Priority.High);
registerEvent("CREATURE_SPAWN", Priority.High);
registerEvent("ENTITY_INTERACT", Priority.High);
registerEvent("CREEPER_POWER", Priority.High);
@ -483,21 +484,6 @@ public void onEntityExplode(EntityExplodeEvent event) {
return;
}
}
} else if (ent instanceof Fireball) {
if (wcfg.blockFireballBlockDamage) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) {
Vector pt = toVector(l);
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.GHAST_FIREBALL)) {
event.setCancelled(true);
return;
}
}
} else if (ent instanceof TNTPrimed) {
if (cfg.activityHaltToggle) {
event.setCancelled(true);
@ -544,6 +530,39 @@ public void onEntityExplode(EntityExplodeEvent event) {
}
}
/**
* Called on explosion prime
*/
@Override
public void onExplosionPrime(ExplosionPrimeEvent event) {
if (event.isCancelled()) {
return;
}
ConfigurationManager cfg = plugin.getGlobalStateManager();
Location l = event.getEntity().getLocation();
World world = l.getWorld();
WorldConfiguration wcfg = cfg.get(world);
Entity ent = event.getEntity();
if (ent instanceof Fireball) {
if (wcfg.blockFireballBlockDamage) {
event.setCancelled(true);
return;
}
if (wcfg.useRegions) {
Vector pt = toVector(l);
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.GHAST_FIREBALL)) {
event.setCancelled(true);
return;
}
}
}
}
/**
* Called on creature spawn.
*/