Permalink
Browse files

Include fireworks in other-explosion flag.

Unfortunately, since fireworks neither have a "shooter" entity nor fire an EntityExplode,
the only way to mitigate damage is a complete on/off for any damage they cause.

Fortunately (probably), this should not interfere with elytra boosting, since the
acceleration is applied directly to the player upon use, not from the firework "explosion".

Fixes WORLDGUARD-3786.
  • Loading branch information...
wizjany committed Jan 4, 2017
1 parent c0f3171 commit 22ef224a8104bb4ca39e779b9a92a934d9de1315
@@ -39,6 +39,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import javax.annotation.Nullable;
@@ -106,17 +107,29 @@ public void onEntityDamage(EntityDamageEvent event) {
if (entity instanceof Player && event.getCause() == DamageCause.FALL) {
if (!query.testState(entity.getLocation(), (Player) entity, DefaultFlag.FALL_DAMAGE)) {
event.setCancelled(true);
return;
}
} else {
try {
if (entity instanceof Player && event.getCause() == DamageCause.FLY_INTO_WALL) {
if (!query.testState(entity.getLocation(), (Player) entity, DefaultFlag.FALL_DAMAGE)) {
event.setCancelled(true);
return;
}
}
} catch (NoSuchFieldError ignored) {
}
}
if (event instanceof EntityDamageByEntityEvent) {
Entity damager = (((EntityDamageByEntityEvent) event)).getDamager();
if (damager != null && damager.getType() == EntityType.FIREWORK) {
if (!query.testState(entity.getLocation(), (RegionAssociable) null, DefaultFlag.OTHER_EXPLOSION)) {
event.setCancelled(true);
return;
}
}
}
}
/**

2 comments on commit 22ef224

@mibby

This comment has been minimized.

Show comment
Hide comment
@mibby

mibby Jan 7, 2017

@wizjany Would it be possible to split this off into a separate flag? I'd like to disable firework damage but keep other explosions globally.

mibby replied Jan 7, 2017

@wizjany Would it be possible to split this off into a separate flag? I'd like to disable firework damage but keep other explosions globally.

@stuntguy3000

This comment has been minimized.

Show comment
Hide comment
@stuntguy3000

stuntguy3000 Jan 8, 2017

Contributor

+1

Contributor

stuntguy3000 replied Jan 8, 2017

+1

Please sign in to comment.