mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-27 03:27:39 +01:00
Retain backwards compatibility for the LingeringPotion event listener.
This commit is contained in:
parent
9b2eff0a71
commit
8e35db0f35
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user