Apply exp flag and config setting to xp bottles.

"Workaround" for not being able to blacklist exp bottles at the moment.
Although I supposed I could have just fixed that instead, this allows more flexibility.
This commit is contained in:
Wizjany 2013-02-21 10:20:47 -05:00
parent 327ae2b807
commit 2d50659b48

View File

@ -61,6 +61,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PigZapEvent;
@ -127,6 +128,17 @@ public void onEntityInteract(EntityInteractEvent event) {
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExpBottle(ExpBottleEvent event) {
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld());
if (wcfg.disableExpDrops || !plugin.getGlobalRegionManager().allows(DefaultFlag.EXP_DROPS,
event.getEntity().getLocation())) {
event.setExperience(0);
// event.setShowEffect(false); // don't want to cancel the bottle entirely I suppose, just the exp
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) {
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld());