Fix firework entity not being removed when FireworkExplodeEvent is cancelled (#12268)

* Fix Firework not removed when FireworkExplodeEvent is canceled

* JUnit require pass null

* tweaks
This commit is contained in:
Pedro
2025-03-23 20:20:14 -03:00
committed by GitHub
parent 058455e4ca
commit f225858235
3 changed files with 23 additions and 20 deletions

View File

@@ -1762,10 +1762,13 @@ public class CraftEventFactory {
return (Cancellable) event;
}
public static FireworkExplodeEvent callFireworkExplodeEvent(FireworkRocketEntity firework) {
public static boolean callFireworkExplodeEvent(FireworkRocketEntity firework) {
FireworkExplodeEvent event = new FireworkExplodeEvent((Firework) firework.getBukkitEntity());
firework.level().getCraftServer().getPluginManager().callEvent(event);
return event;
if (!event.callEvent()) {
firework.discard(null);
return false;
}
return true;
}
public static PrepareAnvilEvent callPrepareAnvilEvent(AnvilView view, ItemStack item) {