this is the error i am getting, Overrides method that is deprecated and marked for removal in 'org.bukkit.Translatable'.
This is my code,
package jefry.viiper.signme;
import io.papermc.paper.enchantments.EnchantmentRarity;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.entity.EntityCategory;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.NamespacedKey;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.translation.Translatable;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
public class AccumulatedDamageEnchantment extends Enchantment implements Translatable {
private final NamespacedKey key;
public AccumulatedDamageEnchantment(@NotNull NamespacedKey key) {
super();
this.key = key;
}
@Override
public @NotNull Component displayName(int level) {
return Component.text("Accumulated Damage " + level);
}
@Override
public int getMinModifiedCost(int level) {
return level * 5; // Example logic: Minimum cost increases with level
}
@Override
public int getMaxModifiedCost(int level) {
return getMinModifiedCost(level) + 10;
}
@Override
public @NotNull EnchantmentRarity getRarity() {
return EnchantmentRarity.UNCOMMON;
}
@Override
public float getDamageIncrease(int level, EntityCategory entityCategory) {
return level * 1.5f; // Example logic: Damage increases with level
}
@Override
public @NotNull Set<EquipmentSlot> getActiveSlots() {
return Set.of(EquipmentSlot.HAND);
}
@Override
public @NotNull NamespacedKey getKey() {
return this.key; // Return the key used in the constructor
}
@Override
public @NotNull String getName() {
return "AccumulatedDamage";
}
@Override
public int getMaxLevel() {
return 5; // Maximum level for this enchantment
}
@Override
public int getStartLevel() {
return 1; // Starting level for this enchantment
}
@Override
public @NotNull EnchantmentTarget getItemTarget() {
return EnchantmentTarget.WEAPON;
}
@Override
public boolean canEnchantItem(@NotNull ItemStack item) {
// Example logic: Allow this enchantment to be applied to all items
return item.getItemMeta().getEnchants().keySet().stream()
.noneMatch(e -> e.conflictsWith(this));
}
@Override
public boolean conflictsWith(@NotNull Enchantment other) {
// Example logic: No conflicts with other enchantments
return false;
}
@Override
public @NotNull String translationKey() {
return null; // Return the translation key provided in the constructor
}
@Override
public boolean isTreasure() {
return false; // Example: not a treasure enchantment
}
@Override
public boolean isCursed() {
return false; // Example: not a cursed enchantment
}
@Override
public boolean isTradeable() {
return true; // Example: tradeable
}
@Override
public boolean isDiscoverable() {
return true; // Example: discoverable in loot
}
public double getExtraDamage(int level) {
return level * 1.5;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
AccumulatedDamageEnchantment other = (AccumulatedDamageEnchantment) obj;
return getKey().equals(other.getKey());
}
@Override
public int hashCode() {
return getKey().hashCode();
}
// Deprecated method from Translatable interface.
@Override
public @NotNull String getTranslationKey() {
return null;
}
}