diff --git a/paper-api/src/main/java/org/bukkit/UnsafeValues.java b/paper-api/src/main/java/org/bukkit/UnsafeValues.java index d60cf05396..d0de7ce3c3 100644 --- a/paper-api/src/main/java/org/bukkit/UnsafeValues.java +++ b/paper-api/src/main/java/org/bukkit/UnsafeValues.java @@ -125,7 +125,6 @@ public interface UnsafeValues { @ApiStatus.Internal @Nullable - @Deprecated DamageEffect getDamageEffect(@NotNull String key); /** @@ -252,15 +251,6 @@ public interface UnsafeValues { * @throws IllegalArgumentException if the entity does not exist of have default attributes (use {@link #hasDefaultEntityAttributes(NamespacedKey)} first) */ @org.jetbrains.annotations.NotNull org.bukkit.attribute.Attributable getDefaultEntityAttributes(@org.jetbrains.annotations.NotNull NamespacedKey entityKey); - - /** - * Get the {@link Sound} played for this {@link DamageEffect} - * - * @param damageEffect the damageEffect - * @return the sound - */ - @ApiStatus.Internal - Sound getSoundForDamageEffect(@NotNull DamageEffect damageEffect); // Paper end // Paper start - namespaced key biome methods diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java b/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java index 2c6dd04769..8cf8fde602 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageEffect.java @@ -11,35 +11,34 @@ import org.jetbrains.annotations.NotNull; * effects only determine the sound that plays. */ @ApiStatus.Experimental -public enum DamageEffect { +public interface DamageEffect { /** * The default damage effect. */ - HURT, + public static final DamageEffect HURT = getDamageEffect("hurt"); /** * Thorns. */ - THORNS, + public static final DamageEffect THORNS = getDamageEffect("thorns"); /** * Drowning. */ - DROWNING, + public static final DamageEffect DROWNING = getDamageEffect("drowning"); /** * A single burn tick (fire, lava, etc.). */ - BURNING, + public static final DamageEffect BURNING = getDamageEffect("burning"); /** * Poked by a berry bush. */ - POKING, + public static final DamageEffect POKING = getDamageEffect("poking"); /** * Freeze tick (powder snow). */ - FREEZING; + public static final DamageEffect FREEZING = getDamageEffect("freezing"); @NotNull - @Deprecated private static DamageEffect getDamageEffect(@NotNull String key) { return Preconditions.checkNotNull(Bukkit.getUnsafe().getDamageEffect(key), "No DamageEffect found for %s. This is a bug.", key); } @@ -50,7 +49,5 @@ public enum DamageEffect { * @return the sound */ @NotNull - public Sound getSound() { - return Bukkit.getUnsafe().getSoundForDamageEffect(this); - } + public Sound getSound(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageEffect.java b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageEffect.java index 94e74608a2..e472a61c16 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageEffect.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageEffect.java @@ -5,8 +5,7 @@ import org.bukkit.Sound; import org.bukkit.craftbukkit.CraftSound; import org.bukkit.damage.DamageEffect; -@Deprecated -public class CraftDamageEffect { +public class CraftDamageEffect implements DamageEffect { private final DamageEffects damageEffects; @@ -18,6 +17,7 @@ public class CraftDamageEffect { return this.damageEffects; } + @Override public Sound getSound() { return CraftSound.minecraftToBukkit(this.getHandle().sound()); } @@ -32,6 +32,6 @@ public class CraftDamageEffect { } public static DamageEffect toBukkit(DamageEffects damageEffects) { - return CraftDamageType.damageEffectToBukkit(damageEffects); + return new CraftDamageEffect(damageEffects); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java index 67dafedf57..d486412429 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/damage/CraftDamageType.java @@ -98,30 +98,6 @@ public class CraftDamageType implements DamageType, Handleable DamageEffect.HURT; - case THORNS -> DamageEffect.THORNS; - case DROWNING -> DamageEffect.DROWNING; - case BURNING -> DamageEffect.BURNING; - case POKING -> DamageEffect.POKING; - case FREEZING -> DamageEffect.FREEZING; - default -> throw new IllegalArgumentException("NMS DamageEffect." + damageEffect + " cannot be converted to a Bukkit DamageEffect"); - }; - } - - public static net.minecraft.world.damagesource.DamageEffects damageEffectToNMS(DamageEffect damageEffect) { - return switch (damageEffect) { - case DamageEffect.HURT -> net.minecraft.world.damagesource.DamageEffects.HURT; - case DamageEffect.THORNS -> net.minecraft.world.damagesource.DamageEffects.THORNS; - case DamageEffect.DROWNING -> net.minecraft.world.damagesource.DamageEffects.DROWNING; - case DamageEffect.BURNING -> net.minecraft.world.damagesource.DamageEffects.BURNING; - case DamageEffect.POKING -> net.minecraft.world.damagesource.DamageEffects.POKING; - case DamageEffect.FREEZING -> net.minecraft.world.damagesource.DamageEffects.FREEZING; - default -> throw new IllegalArgumentException("Bukkit DamageEffect." + damageEffect + " cannot be converted to a NMS DamageEffect"); - }; - } - public static DamageType minecraftHolderToBukkit(Holder minecraftHolder) { return CraftDamageType.minecraftToBukkit(minecraftHolder.value()); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 86757f2df6..b6665e1875 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -674,12 +674,6 @@ public final class CraftMagicNumbers implements UnsafeValues { player == null ? null : ((org.bukkit.craftbukkit.entity.CraftPlayer) player).getHandle(), flag); return lines.stream().map(io.papermc.paper.adventure.PaperAdventure::asAdventure).toList(); } - - @Override - public org.bukkit.Sound getSoundForDamageEffect(DamageEffect damageEffect) { - Preconditions.checkArgument(damageEffect != null, "key cannot be null"); - return org.bukkit.craftbukkit.CraftSound.minecraftToBukkit(org.bukkit.craftbukkit.damage.CraftDamageType.damageEffectToNMS(damageEffect).sound()); - } // Paper end // Paper start - spawn egg color visibility