From 6ba05011fac787a7dacc63a2bc914ee0742f7efb Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 17 Mar 2024 10:26:51 +1100 Subject: [PATCH] #979: Add more translation keys By: Miles Holder --- paper-api/src/main/java/org/bukkit/UnsafeValues.java | 2 ++ .../src/main/java/org/bukkit/attribute/Attribute.java | 10 +++++++++- .../main/java/org/bukkit/enchantments/Enchantment.java | 3 ++- .../org/bukkit/inventory/meta/trim/TrimMaterial.java | 3 ++- .../org/bukkit/inventory/meta/trim/TrimPattern.java | 3 ++- .../main/java/org/bukkit/potion/PotionEffectType.java | 3 ++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/UnsafeValues.java b/paper-api/src/main/java/org/bukkit/UnsafeValues.java index 6ca5f7a850..ef3c0410ba 100644 --- a/paper-api/src/main/java/org/bukkit/UnsafeValues.java +++ b/paper-api/src/main/java/org/bukkit/UnsafeValues.java @@ -94,6 +94,8 @@ public interface UnsafeValues { String getTranslationKey(ItemStack itemStack); + String getTranslationKey(Attribute attribute); + @Nullable FeatureFlag getFeatureFlag(@NotNull NamespacedKey key); diff --git a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java index 36501052de..7d5e6961e7 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/Attribute.java +++ b/paper-api/src/main/java/org/bukkit/attribute/Attribute.java @@ -1,13 +1,15 @@ package org.bukkit.attribute; +import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; +import org.bukkit.Translatable; import org.jetbrains.annotations.NotNull; /** * Types of attributes which may be present on an {@link Attributable}. */ -public enum Attribute implements Keyed { +public enum Attribute implements Keyed, Translatable { /** * Maximum health of an Entity. @@ -77,4 +79,10 @@ public enum Attribute implements Keyed { public NamespacedKey getKey() { return key; } + + @NotNull + @Override + public String getTranslationKey() { + return Bukkit.getUnsafe().getTranslationKey(this); + } } diff --git a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java index c349cd16de..a456e43308 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -5,6 +5,7 @@ import com.google.common.collect.Lists; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; +import org.bukkit.Translatable; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable; /** * The various type of enchantments that may be added to armour or weapons */ -public abstract class Enchantment implements Keyed { +public abstract class Enchantment implements Keyed, Translatable { /** * Provides protection against environmental damage */ diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java index 4327cbc15b..eb80f24da6 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java @@ -4,11 +4,12 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.Registry; +import org.bukkit.Translatable; /** * Represents a material that may be used in an {@link ArmorTrim}. */ -public interface TrimMaterial extends Keyed { +public interface TrimMaterial extends Keyed, Translatable { /** * {@link Material#QUARTZ}. diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java index 2365220dc0..ccf02c79e2 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java @@ -4,11 +4,12 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.Registry; +import org.bukkit.Translatable; /** * Represents a pattern that may be used in an {@link ArmorTrim}. */ -public interface TrimPattern extends Keyed { +public interface TrimPattern extends Keyed, Translatable { /** * {@link Material#SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE}. diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java index b7c394fb70..28dd05c706 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -8,6 +8,7 @@ import org.bukkit.Color; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; +import org.bukkit.Translatable; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,7 +16,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents a type of potion and its effect on an entity. */ -public abstract class PotionEffectType implements Keyed { +public abstract class PotionEffectType implements Keyed, Translatable { private static final BiMap ID_MAP = HashBiMap.create(); /**