Add paper comments

This commit is contained in:
Chaosdave34 2024-12-23 13:18:10 +01:00
parent e5b3b72c83
commit 51a33de5eb
4 changed files with 16 additions and 11 deletions

View file

@ -6,6 +6,7 @@ import org.bukkit.Sound;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
// Paper start
/** /**
* Represents a type of effect that occurs when damage is inflicted. Currently, * Represents a type of effect that occurs when damage is inflicted. Currently,
* effects only determine the sound that plays. * effects only determine the sound that plays.
@ -54,3 +55,4 @@ public enum DamageEffect {
return Bukkit.getUnsafe().getSoundForDamageEffect(this); return Bukkit.getUnsafe().getSoundForDamageEffect(this);
} }
} }
// Paper end

View file

@ -5,8 +5,10 @@ import org.bukkit.Sound;
import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageEffect;
// Paper start
@Deprecated @Deprecated
public class CraftDamageEffect { public class CraftDamageEffect {
// Paper end
private final DamageEffects damageEffects; private final DamageEffects damageEffects;
@ -19,7 +21,7 @@ public class CraftDamageEffect {
} }
public Sound getSound() { public Sound getSound() {
return CraftSound.minecraftToBukkit(this.getHandle().sound()); return CraftSound.minecraftToBukkit(this.getHandle().sound()); // Paper
} }
public static DamageEffect getById(String id) { public static DamageEffect getById(String id) {

View file

@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.damage;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries; import net.minecraft.core.registries.Registries;
import net.minecraft.world.damagesource.DamageEffects;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.craftbukkit.CraftRegistry; import org.bukkit.craftbukkit.CraftRegistry;
@ -99,7 +98,8 @@ public class CraftDamageType implements DamageType, Handleable<net.minecraft.wor
}; };
} }
public static DamageEffect damageEffectToBukkit(DamageEffects damageEffect) { // Paper start
public static DamageEffect damageEffectToBukkit(net.minecraft.world.damagesource.DamageEffects damageEffect) {
return switch (damageEffect) { return switch (damageEffect) {
case HURT -> DamageEffect.HURT; case HURT -> DamageEffect.HURT;
case THORNS -> DamageEffect.THORNS; case THORNS -> DamageEffect.THORNS;
@ -111,17 +111,18 @@ public class CraftDamageType implements DamageType, Handleable<net.minecraft.wor
}; };
} }
public static DamageEffects damageEffectToNMS(DamageEffect damageEffect) { public static net.minecraft.world.damagesource.DamageEffects damageEffectToNMS(DamageEffect damageEffect) {
return switch (damageEffect) { return switch (damageEffect) {
case DamageEffect.HURT -> DamageEffects.HURT; case DamageEffect.HURT -> net.minecraft.world.damagesource.DamageEffects.HURT;
case DamageEffect.THORNS -> DamageEffects.THORNS; case DamageEffect.THORNS -> net.minecraft.world.damagesource.DamageEffects.THORNS;
case DamageEffect.DROWNING -> DamageEffects.DROWNING; case DamageEffect.DROWNING -> net.minecraft.world.damagesource.DamageEffects.DROWNING;
case DamageEffect.BURNING -> DamageEffects.BURNING; case DamageEffect.BURNING -> net.minecraft.world.damagesource.DamageEffects.BURNING;
case DamageEffect.POKING -> DamageEffects.POKING; case DamageEffect.POKING -> net.minecraft.world.damagesource.DamageEffects.POKING;
case DamageEffect.FREEZING -> DamageEffects.FREEZING; case DamageEffect.FREEZING -> net.minecraft.world.damagesource.DamageEffects.FREEZING;
default -> throw new IllegalArgumentException("Bukkit DamageEffect." + damageEffect + " cannot be converted to a NMS DamageEffect"); default -> throw new IllegalArgumentException("Bukkit DamageEffect." + damageEffect + " cannot be converted to a NMS DamageEffect");
}; };
} }
// Paper end
public static DamageType minecraftHolderToBukkit(Holder<net.minecraft.world.damagesource.DamageType> minecraftHolder) { public static DamageType minecraftHolderToBukkit(Holder<net.minecraft.world.damagesource.DamageType> minecraftHolder) {
return CraftDamageType.minecraftToBukkit(minecraftHolder.value()); return CraftDamageType.minecraftToBukkit(minecraftHolder.value());

View file

@ -467,7 +467,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
} }
@Override @Override
@Deprecated @Deprecated // Paper
public DamageEffect getDamageEffect(String key) { public DamageEffect getDamageEffect(String key) {
Preconditions.checkArgument(key != null, "key cannot be null"); Preconditions.checkArgument(key != null, "key cannot be null");
return CraftDamageEffect.getById(key); return CraftDamageEffect.getById(key);