SPIGOT-7799, #1436: Expose explosion world interaction in EntityExplodeEvent and BlockExplodeEvent

By: antiPerson <nathat890@outlook.com>
This commit is contained in:
CraftBukkit/Spigot
2024-07-06 17:19:45 +10:00
parent 41b8d833db
commit b6655d093f
5 changed files with 88 additions and 27 deletions

View File

@@ -0,0 +1,27 @@
package org.bukkit.craftbukkit;
import com.google.common.base.Preconditions;
import net.minecraft.world.level.Explosion;
import org.bukkit.ExplosionResult;
public final class CraftExplosionResult {
private CraftExplosionResult() {}
public static ExplosionResult toBukkit(Explosion.Effect effect) {
Preconditions.checkArgument(effect != null, "explosion effect cannot be null");
switch (effect) {
case KEEP:
return ExplosionResult.KEEP;
case DESTROY:
return ExplosionResult.DESTROY;
case DESTROY_WITH_DECAY:
return ExplosionResult.DESTROY_WITH_DECAY;
case TRIGGER_BLOCK:
return ExplosionResult.TRIGGER_BLOCK;
default:
throw new IllegalArgumentException("There is no ExplosionResult which matches " + effect);
}
}
}