From 8e35db0f35c5203474a0b7caf60e751310548e4c Mon Sep 17 00:00:00 2001 From: wizjany Date: Tue, 29 Nov 2016 01:35:21 -0500 Subject: [PATCH] Retain backwards compatibility for the LingeringPotion event listener. --- .../listener/EventAbstractionListener.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 6863f6c5..ea4f4063 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -109,6 +109,10 @@ public void registerEvents() { getPlugin().getServer().getPluginManager().registerEvents(new SpigotCompatListener(), getPlugin()); } catch (LinkageError ignored) { } + try { + getPlugin().getServer().getPluginManager().registerEvents(new LingeringPotionListener(), getPlugin()); + } catch (NoClassDefFoundError ignored) { + } } //------------------------------------------------------------------------- @@ -858,23 +862,6 @@ public void onPotionSplash(PotionSplashEvent event) { } } - @EventHandler(ignoreCancelled = true) - public void onLingeringSplash(LingeringPotionSplashEvent event) { - AreaEffectCloud aec = event.getAreaEffectCloud(); - LingeringPotion potion = event.getEntity(); - World world = potion.getWorld(); - Cause cause = create(event.getEntity()); - - // Fire item interaction event - Events.fireToCancel(event, new UseItemEvent(event, cause, world, potion.getItem())); - - // Fire entity spawn event - if (!event.isCancelled()) { - // radius unfortunately doesn't go through with this, so only a single location is tested - Events.fireToCancel(event, new SpawnEntityEvent(event, cause, aec.getLocation().add(0.5, 0, 0.5), EntityType.AREA_EFFECT_CLOUD)); - } - } - @EventHandler(ignoreCancelled = true) public void onBlockDispense(BlockDispenseEvent event) { Cause cause = create(event.getBlock()); @@ -1021,4 +1008,22 @@ public void onBlockExplode(BlockExplodeEvent event) { } } + public class LingeringPotionListener implements Listener { + @EventHandler(ignoreCancelled = true) + public void onLingeringSplash(LingeringPotionSplashEvent event) { + AreaEffectCloud aec = event.getAreaEffectCloud(); + LingeringPotion potion = event.getEntity(); + World world = potion.getWorld(); + Cause cause = create(event.getEntity()); + + // Fire item interaction event + Events.fireToCancel(event, new UseItemEvent(event, cause, world, potion.getItem())); + + // Fire entity spawn event + if (!event.isCancelled()) { + // radius unfortunately doesn't go through with this, so only a single location is tested + Events.fireToCancel(event, new SpawnEntityEvent(event, cause, aec.getLocation().add(0.5, 0, 0.5), EntityType.AREA_EFFECT_CLOUD)); + } + } + } }