Fix wind-charge-burst flag for player knockback

This commit is contained in:
Joo200 2024-07-27 16:58:19 +02:00 committed by wizjany
parent afb619d2ac
commit 9dd7d7c03e
No known key found for this signature in database
GPG Key ID: 1DB5861C03B76B5E
2 changed files with 13 additions and 1 deletions

View File

@ -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();

View File

@ -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);