From 9dd7d7c03ef7a66128f22639e37a83f7569a5f49 Mon Sep 17 00:00:00 2001 From: Joo200 Date: Sat, 27 Jul 2024 16:58:19 +0200 Subject: [PATCH] Fix wind-charge-burst flag for player knockback --- .../bukkit/listener/EventAbstractionListener.java | 13 +++++++++++++ .../bukkit/listener/WorldGuardEntityListener.java | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 1a523158..58e971da 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -68,6 +68,7 @@ import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.type.Dispenser; +import org.bukkit.entity.AbstractWindCharge; import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; @@ -117,6 +118,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.entity.EntityKnockbackByEntityEvent; import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.event.entity.EntityUnleashEvent; @@ -357,6 +359,17 @@ public void onEntityChangeBlock(EntityChangeBlockEvent event) { } + @EventHandler(ignoreCancelled = true) + public void onEntityKnockbackByEntity(EntityKnockbackByEntityEvent event) { + Entity damager = event.getSourceEntity(); + + final DamageEntityEvent eventToFire = new DamageEntityEvent(event, create(damager), event.getEntity()); + if (damager instanceof AbstractWindCharge) { + eventToFire.getRelevantFlags().add(Flags.WIND_CHARGE_BURST); + } + Events.fireToCancel(event, eventToFire); + } + @EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); diff --git a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java index 111cffdd..8ae09c3c 100644 --- a/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java +++ b/worldguard-bukkit/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardEntityListener.java @@ -330,7 +330,6 @@ private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) { } } if (wcfg.useRegions) { - WorldGuardPlugin.inst().getLogger().info("Getting damager type " + event.getDamager().getType()); RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery(); if (!query.testState(localPlayer.getLocation(), localPlayer, Entities.getExplosionFlag(event.getDamager())) && wcfg.explosionFlagCancellation) { event.setCancelled(true);