diff --git a/build-data/paper.at b/build-data/paper.at index 235ae06d79..59c32f006c 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -233,3 +233,7 @@ public net.minecraft.world.level.entity.PersistentEntitySectionManager sectionSt # Optimize light engine public-f net.minecraft.world.level.chunk.DataLayer + +# Add methods to get translation keys +public org.bukkit.craftbukkit.inventory.CraftMetaFirework +public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/FireworkEffect$Type;)I diff --git a/patches/api/Add-Block-isValidTool.patch b/patches/api/Add-Block-isValidTool.patch index ea3d7653cd..d115b7cfde 100644 --- a/patches/api/Add-Block-isValidTool.patch +++ b/patches/api/Add-Block-isValidTool.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukki index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java -@@ -0,0 +0,0 @@ public interface Block extends Metadatable { +@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran public static int getBlockKeyZ(long packed) { return (int) ((packed << 10) >> 37); } diff --git a/patches/api/Add-Destroy-Speed-API.patch b/patches/api/Add-Destroy-Speed-API.patch index 228bf01d9f..4aaeed43e4 100644 --- a/patches/api/Add-Destroy-Speed-API.patch +++ b/patches/api/Add-Destroy-Speed-API.patch @@ -9,9 +9,9 @@ diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukki index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java -@@ -0,0 +0,0 @@ public interface Block extends Metadatable { - */ +@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran @NotNull + @Deprecated String getTranslationKey(); + + /** diff --git a/patches/api/Add-Player-Client-Options-API.patch b/patches/api/Add-Player-Client-Options-API.patch index e1a66a70d0..837ec2b7ba 100644 --- a/patches/api/Add-Player-Client-Options-API.patch +++ b/patches/api/Add-Player-Client-Options-API.patch @@ -12,6 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package com.destroystokyo.paper; + ++import net.kyori.adventure.translation.Translatable; ++import net.kyori.adventure.util.Index; +import org.jetbrains.annotations.NotNull; + +import org.bukkit.inventory.MainHand; @@ -36,11 +38,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return type; + } + -+ public enum ChatVisibility { -+ FULL, -+ SYSTEM, -+ HIDDEN, -+ UNKNOWN ++ public enum ChatVisibility implements Translatable { ++ FULL("full"), ++ SYSTEM("system"), ++ HIDDEN("hidden"), ++ UNKNOWN("unknown"); ++ ++ public static Index NAMES = Index.create(ChatVisibility.class, chatVisibility -> chatVisibility.name); ++ private final String name; ++ ++ ChatVisibility(String name) { ++ this.name = name; ++ } ++ ++ @Override ++ public @NotNull String translationKey() { ++ if (this == UNKNOWN) { ++ throw new UnsupportedOperationException(this.name + " doesn't have a translation key"); ++ } ++ return "options.chat.visibility." + this.name; ++ } + } +} diff --git a/src/main/java/com/destroystokyo/paper/SkinParts.java b/src/main/java/com/destroystokyo/paper/SkinParts.java diff --git a/patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch b/patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch deleted file mode 100644 index 4333bf8fe4..0000000000 --- a/patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MeFisto94 -Date: Tue, 11 Aug 2020 19:17:46 +0200 -Subject: [PATCH] Add a way to get translation keys for blocks, entities and - materials - - -diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/Material.java -+++ b/src/main/java/org/bukkit/Material.java -@@ -0,0 +0,0 @@ public enum Material implements Keyed { - } - return false; - } -+ -+ /** -+ * Return the translation key for the Material, so the client can translate it into the active -+ * locale when using a TranslatableComponent. -+ * @return the translation key -+ */ -+ @NotNull -+ public String getTranslationKey() { -+ return Bukkit.getUnsafe().getTranslationKey(this); -+ } - // Paper end - - /** -diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/UnsafeValues.java -+++ b/src/main/java/org/bukkit/UnsafeValues.java -@@ -0,0 +0,0 @@ public interface UnsafeValues { - byte[] serializeItem(ItemStack item); - - ItemStack deserializeItem(byte[] data); -+ -+ /** -+ * Return the translation key for the Material, so the client can translate it into the active -+ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}. -+ * @return the translation key -+ */ -+ String getTranslationKey(Material mat); -+ -+ /** -+ * Return the translation key for the Block, so the client can translate it into the active -+ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}. -+ * @return the translation key -+ */ -+ String getTranslationKey(org.bukkit.block.Block block); -+ -+ /** -+ * Return the translation key for the EntityType, so the client can translate it into the active -+ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}.
-+ * This is null, when the EntityType isn't known to NMS (custom entities) -+ * @return the translation key -+ */ -+ String getTranslationKey(org.bukkit.entity.EntityType type); -+ -+ /** -+ * Return the translation key for the ItemStack, so the client can translate it into the active -+ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}.
-+ * @return the translation key -+ */ -+ String getTranslationKey(ItemStack itemStack); - // Paper end - } -diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/block/Block.java -+++ b/src/main/java/org/bukkit/block/Block.java -@@ -0,0 +0,0 @@ public interface Block extends Metadatable { - */ - @NotNull - com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup(); -+ -+ /** -+ * Return the translation key for the Block, so the client can translate it into the active -+ * locale when using a TranslatableComponent. -+ * @return the translation key -+ */ -+ @NotNull -+ String getTranslationKey(); - // Paper end - } -diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/entity/EntityType.java -+++ b/src/main/java/org/bukkit/entity/EntityType.java -@@ -0,0 +0,0 @@ public enum EntityType implements Keyed { - public boolean isAlive() { - return living; - } -+ -+ /** -+ * Return the translation key for the EntityType, so the client can translate it into the active -+ * locale when using a TranslatableComponent.
-+ * This is null, when the EntityType isn't known to NMS (custom entities) -+ * @return the translation key -+ */ -+ @Nullable -+ public String getTranslationKey() { -+ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); -+ } - } -diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/ItemStack.java -+++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor - ItemMeta itemMeta = getItemMeta(); - return itemMeta != null && itemMeta.hasItemFlag(flag); - } -+ -+ /** -+ * Gets the translation key for this itemstack. -+ * This is not the same as getting the translation key -+ * for the material of this itemstack. -+ * -+ * @return the translation key -+ */ -+ @NotNull -+ public String getTranslationKey() { -+ return Bukkit.getUnsafe().getTranslationKey(this); -+ } - // Paper end - } diff --git a/patches/api/Add-methods-to-get-translation-keys.patch b/patches/api/Add-methods-to-get-translation-keys.patch new file mode 100644 index 0000000000..9c8a9ea1e0 --- /dev/null +++ b/patches/api/Add-methods-to-get-translation-keys.patch @@ -0,0 +1,355 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 11 Aug 2020 19:17:46 +0200 +Subject: [PATCH] Add methods to get translation keys + +Co-authored-by: MeFisto94 + +diff --git a/src/main/java/org/bukkit/Difficulty.java b/src/main/java/org/bukkit/Difficulty.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Difficulty.java ++++ b/src/main/java/org/bukkit/Difficulty.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + /** + * Represents the various difficulty levels that are available. + */ +-public enum Difficulty { ++public enum Difficulty implements net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + /** + * Players regain health over time, hostile mobs don't spawn, the hunger + * bar does not deplete. +@@ -0,0 +0,0 @@ public enum Difficulty { + return value; + } + ++ // Paper start ++ @Override ++ public @org.jetbrains.annotations.NotNull String translationKey() { ++ return "options.difficulty." + this.name().toLowerCase(java.util.Locale.ENGLISH); ++ } ++ // Paper end + /** + * Gets the Difficulty represented by the specified value + * +diff --git a/src/main/java/org/bukkit/FireworkEffect.java b/src/main/java/org/bukkit/FireworkEffect.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/FireworkEffect.java ++++ b/src/main/java/org/bukkit/FireworkEffect.java +@@ -0,0 +0,0 @@ public final class FireworkEffect implements ConfigurationSerializable { + /** + * The type or shape of the effect. + */ +- public enum Type { ++ public enum Type implements net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + /** + * A small ball effect. + */ +- BALL, ++ BALL("small_ball"), // Paper - add name + /** + * A large ball effect. + */ +- BALL_LARGE, ++ BALL_LARGE("large_ball"), // Paper - add name + /** + * A star-shaped effect. + */ +- STAR, ++ STAR("star"), // Paper - add name + /** + * A burst effect. + */ +- BURST, ++ BURST("burst"), // Paper - add name + /** + * A creeper-face effect. + */ +- CREEPER, ++ CREEPER("creeper"), // Paper - add name + ; ++ // Paper start ++ /** ++ * The name map. ++ */ ++ public static final net.kyori.adventure.util.Index NAMES = net.kyori.adventure.util.Index.create(Type.class, type -> type.name); ++ private final String name; ++ ++ Type(final String name) { ++ this.name = name; ++ } ++ ++ @Override ++ public @NotNull String translationKey() { ++ return "item.minecraft.firework_star.shape." + this.name; ++ } ++ // Paper end + } + + /** +diff --git a/src/main/java/org/bukkit/GameRule.java b/src/main/java/org/bukkit/GameRule.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/GameRule.java ++++ b/src/main/java/org/bukkit/GameRule.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * + * @param type of rule (Boolean or Integer) + */ +-public final class GameRule { ++public final class GameRule implements net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + + private static Map> gameRules = new HashMap<>(); + // Boolean rules +@@ -0,0 +0,0 @@ public final class GameRule { + public static GameRule[] values() { + return gameRules.values().toArray(new GameRule[gameRules.size()]); + } ++ ++ // Paper start ++ @Override ++ public @NotNull String translationKey() { ++ return "gamerule." + this.name; ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Material.java ++++ b/src/main/java/org/bukkit/Material.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * An enum of all material IDs accepted by the official server and client + */ + @SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper +-public enum Material implements Keyed { ++public enum Material implements Keyed, net.kyori.adventure.translation.Translatable { // Paper + // + AIR(9648, 0), + STONE(22948), +@@ -0,0 +0,0 @@ public enum Material implements Keyed { + } + return false; + } ++ ++ /** ++ * Return the translation key for the Material, so the client can translate it into the active ++ * locale when using a TranslatableComponent. ++ * @return the translation key ++ * @deprecated use {@link #translationKey()} ++ */ ++ @NotNull ++ @Deprecated ++ public String getTranslationKey() { ++ return this.translationKey(); ++ } ++ ++ @Override ++ public @NotNull String translationKey() { ++ return Bukkit.getUnsafe().getTranslationKey(this); ++ } + // Paper end + + /** +diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/UnsafeValues.java ++++ b/src/main/java/org/bukkit/UnsafeValues.java +@@ -0,0 +0,0 @@ public interface UnsafeValues { + byte[] serializeItem(ItemStack item); + + ItemStack deserializeItem(byte[] data); ++ ++ /** ++ * Return the translation key for the Material, so the client can translate it into the active ++ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}. ++ * @return the translation key ++ */ ++ String getTranslationKey(Material mat); ++ ++ /** ++ * Return the translation key for the Block, so the client can translate it into the active ++ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}. ++ * @return the translation key ++ */ ++ String getTranslationKey(org.bukkit.block.Block block); ++ ++ /** ++ * Return the translation key for the EntityType, so the client can translate it into the active ++ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}.
++ * This is null, when the EntityType isn't known to NMS (custom entities) ++ * @return the translation key ++ */ ++ String getTranslationKey(org.bukkit.entity.EntityType type); ++ ++ /** ++ * Return the translation key for the ItemStack, so the client can translate it into the active ++ * locale when using a {@link net.kyori.adventure.text.TranslatableComponent}.
++ * @return the translation key ++ */ ++ String getTranslationKey(ItemStack itemStack); + // Paper end + } +diff --git a/src/main/java/org/bukkit/attribute/Attribute.java b/src/main/java/org/bukkit/attribute/Attribute.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/attribute/Attribute.java ++++ b/src/main/java/org/bukkit/attribute/Attribute.java +@@ -0,0 +0,0 @@ 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, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + + /** + * Maximum health of an Entity. +@@ -0,0 +0,0 @@ public enum Attribute implements Keyed { + public NamespacedKey getKey() { + return key; + } ++ // Paper start ++ @Override ++ public @NotNull String translationKey() { ++ return "attribute.name." + this.key.getKey(); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/block/Block.java ++++ b/src/main/java/org/bukkit/block/Block.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * (i.e. lighting and power) may not be able to be safely accessed during world + * generation when used in cases like BlockPhysicsEvent!!!! + */ +-public interface Block extends Metadatable { ++public interface Block extends Metadatable, net.kyori.adventure.translation.Translatable { // Paper - translatable + + /** + * Gets the metadata for this block +@@ -0,0 +0,0 @@ public interface Block extends Metadatable { + */ + @NotNull + com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup(); ++ ++ /** ++ * Return the translation key for the Block, so the client can translate it into the active ++ * locale when using a TranslatableComponent. ++ * @return the translation key ++ * @deprecated use {@link #translationKey()} ++ */ ++ @NotNull ++ @Deprecated ++ String getTranslationKey(); + // Paper end + } +diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/enchantments/Enchantment.java ++++ b/src/main/java/org/bukkit/enchantments/Enchantment.java +@@ -0,0 +0,0 @@ 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, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations + /** + * Provides protection against environmental damage + */ +diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java ++++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +@@ -0,0 +0,0 @@ public class EnchantmentWrapper extends Enchantment { + public net.kyori.adventure.text.Component displayName(int level) { + return getEnchantment().displayName(level); + } ++ ++ @Override ++ public @NotNull String translationKey() { ++ return getEnchantment().translationKey(); ++ } + // Paper end + } +diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/EntityType.java ++++ b/src/main/java/org/bukkit/entity/EntityType.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Contract; + import org.jetbrains.annotations.NotNull; + import org.jetbrains.annotations.Nullable; + +-public enum EntityType implements Keyed { ++public enum EntityType implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translatable + + // These strings MUST match the strings in nms.EntityTypes and are case sensitive. + /** +@@ -0,0 +0,0 @@ public enum EntityType implements Keyed { + public boolean isAlive() { + return living; + } ++ // Paper start ++ /** ++ * Return the translation key for the EntityType, so the client can translate it into the active ++ * locale when using a TranslatableComponent.
++ * This is null, when the EntityType isn't known to NMS (custom entities) ++ * @return the translation key ++ * @deprecated use {@link #translationKey()} ++ */ ++ @Deprecated ++ @Nullable ++ public String getTranslationKey() { ++ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); ++ } ++ ++ /** ++ * @throws IllegalArgumentException if the entity does not have a translation key (is probably a custom entity) ++ */ ++ @Override ++ public @NotNull String translationKey() { ++ Preconditions.checkArgument(this != UNKNOWN, "UNKNOWN entities do not have translation keys"); ++ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/inventory/ItemStack.java ++++ b/src/main/java/org/bukkit/inventory/ItemStack.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * use this class to encapsulate Materials for which {@link Material#isItem()} + * returns false. + */ +-public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyori.adventure.text.event.HoverEventSource { // Paper ++public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.translation.Translatable { // Paper + private Material type = Material.AIR; + private int amount = 0; + private MaterialData data = null; +@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor + ItemMeta itemMeta = getItemMeta(); + return itemMeta != null && itemMeta.hasItemFlag(flag); + } ++ ++ /** ++ * Gets the translation key for this itemstack. ++ * This is not the same as getting the translation key ++ * for the material of this itemstack. ++ * ++ * @return the translation key ++ * @deprecated use {@link #translationKey()} ++ */ ++ @NotNull ++ @Deprecated ++ public String getTranslationKey() { ++ return this.translationKey(); ++ } ++ ++ /** ++ * {@inheritDoc} ++ *

++ * This is not the same as getting the translation key ++ * for the material of this itemstack. ++ */ ++ @Override ++ public @NotNull String translationKey() { ++ return Bukkit.getUnsafe().getTranslationKey(this); ++ } + // Paper end + } diff --git a/patches/api/Additional-Block-Material-API-s.patch b/patches/api/Additional-Block-Material-API-s.patch index 79c613671c..994c0f52b8 100644 --- a/patches/api/Additional-Block-Material-API-s.patch +++ b/patches/api/Additional-Block-Material-API-s.patch @@ -12,7 +12,7 @@ diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukki index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/block/Block.java +++ b/src/main/java/org/bukkit/block/Block.java -@@ -0,0 +0,0 @@ public interface Block extends Metadatable { +@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran */ boolean isLiquid(); diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 2f740686d2..892ccb1a38 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -15,6 +15,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } +val adventureVersion = "4.8.1" ++val apiAndDocs by configurations.creating { ++ attributes { ++ attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION)) ++ attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) ++ attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES)) ++ attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) ++ } ++} ++configurations.api { ++ extendsFrom(apiAndDocs) ++} + dependencies { // api dependencies are listed transitively to API consumers @@ -23,15 +34,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 api("org.yaml:snakeyaml:1.28") api("com.googlecode.json-simple:json-simple:1.1.1") // Paper api("it.unimi.dsi:fastutil:8.2.2") -+ api(platform("net.kyori:adventure-bom:$adventureVersion")) -+ api("net.kyori:adventure-api") -+ api("net.kyori:adventure-text-serializer-gson") -+ api("net.kyori:adventure-text-serializer-legacy") -+ api("net.kyori:adventure-text-serializer-plain") ++ apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion")) ++ apiAndDocs("net.kyori:adventure-api") ++ apiAndDocs("net.kyori:adventure-text-serializer-gson") ++ apiAndDocs("net.kyori:adventure-text-serializer-legacy") ++ apiAndDocs("net.kyori:adventure-text-serializer-plain") compileOnly("org.apache.maven:maven-resolver-provider:3.8.1") compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0") -@@ -0,0 +0,0 @@ tasks.withType().configureEach { +@@ -0,0 +0,0 @@ tasks.jar { + } + + tasks.withType().configureEach { ++ (options as CoreJavadocOptions).addStringOption("sourcepath", apiAndDocs.resolvedConfiguration.files.joinToString(separator = File.pathSeparator, transform = File::getPath)) + (options as StandardJavadocDocletOptions).links( + "https://guava.dev/releases/21.0/api/docs/", "https://javadoc.io/doc/org.yaml/snakeyaml/1.28/", "https://javadoc.io/doc/org.jetbrains/annotations/21.0.1/", // Paper - we don't want Java 5 annotations "https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/", diff --git a/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch b/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch index 27626f930e..5efd92de6f 100644 --- a/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch +++ b/patches/api/Allow-plugins-to-use-SLF4J-for-logging.patch @@ -18,9 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - api("net.kyori:adventure-text-serializer-gson") - api("net.kyori:adventure-text-serializer-legacy") - api("net.kyori:adventure-text-serializer-plain") + apiAndDocs("net.kyori:adventure-text-serializer-gson") + apiAndDocs("net.kyori:adventure-text-serializer-legacy") + apiAndDocs("net.kyori:adventure-text-serializer-plain") + api("org.apache.logging.log4j:log4j-api:2.14.1") // Paper + api("org.slf4j:slf4j-api:1.7.30") // Paper diff --git a/patches/api/Attributes-API-for-item-defaults.patch b/patches/api/Attributes-API-for-item-defaults.patch index 814c825117..344bb6e7cd 100644 --- a/patches/api/Attributes-API-for-item-defaults.patch +++ b/patches/api/Attributes-API-for-item-defaults.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/M index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -0,0 +0,0 @@ public enum Material implements Keyed { +@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata public io.papermc.paper.inventory.ItemRarity getItemRarity() { return Bukkit.getUnsafe().getItemRarity(this); } diff --git a/patches/api/Cache-the-result-of-Material-isBlock.patch b/patches/api/Cache-the-result-of-Material-isBlock.patch index d506462869..85161b8783 100644 --- a/patches/api/Cache-the-result-of-Material-isBlock.patch +++ b/patches/api/Cache-the-result-of-Material-isBlock.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/M index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -0,0 +0,0 @@ public enum Material implements Keyed { +@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata public final Class data; private final boolean legacy; private final NamespacedKey key; @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private Material(final int id) { this(id, 64); -@@ -0,0 +0,0 @@ public enum Material implements Keyed { +@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata * @return true if this material is a block */ public boolean isBlock() { @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 switch (this) { // case ACACIA_BUTTON: -@@ -0,0 +0,0 @@ public enum Material implements Keyed { +@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata static { for (Material material : values()) { BY_NAME.put(material.name(), material); diff --git a/patches/api/Item-Rarity-API.patch b/patches/api/Item-Rarity-API.patch index dec20c0839..bb76044813 100644 --- a/patches/api/Item-Rarity-API.patch +++ b/patches/api/Item-Rarity-API.patch @@ -42,8 +42,8 @@ diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/M index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -0,0 +0,0 @@ public enum Material implements Keyed { - public String getTranslationKey() { +@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata + public @NotNull String translationKey() { return Bukkit.getUnsafe().getTranslationKey(this); } + @@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor - public String getTranslationKey() { + public @NotNull String translationKey() { return Bukkit.getUnsafe().getTranslationKey(this); } + diff --git a/patches/api/More-Enchantment-API.patch b/patches/api/More-Enchantment-API.patch index 2f0bd9ed01..b106977018 100644 --- a/patches/api/More-Enchantment-API.patch +++ b/patches/api/More-Enchantment-API.patch @@ -38,7 +38,7 @@ diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/j index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/src/main/java/org/bukkit/enchantments/Enchantment.java -@@ -0,0 +0,0 @@ public abstract class Enchantment implements Keyed { +@@ -0,0 +0,0 @@ public abstract class Enchantment implements Keyed, net.kyori.adventure.translat * @return the name of the enchantment with {@code level} applied */ public abstract @NotNull net.kyori.adventure.text.Component displayName(int level); @@ -90,8 +90,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java @@ -0,0 +0,0 @@ public class EnchantmentWrapper extends Enchantment { - public net.kyori.adventure.text.Component displayName(int level) { - return getEnchantment().displayName(level); + public @NotNull String translationKey() { + return getEnchantment().translationKey(); } + + @Override diff --git a/patches/api/Use-ASM-for-event-executors.patch b/patches/api/Use-ASM-for-event-executors.patch index a0f1a34aad..beb99bd5c8 100644 --- a/patches/api/Use-ASM-for-event-executors.patch +++ b/patches/api/Use-ASM-for-event-executors.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - api("net.kyori:adventure-text-serializer-legacy") - api("net.kyori:adventure-text-serializer-plain") + apiAndDocs("net.kyori:adventure-text-serializer-legacy") + apiAndDocs("net.kyori:adventure-text-serializer-plain") + implementation("org.ow2.asm:asm:9.1") + implementation("org.ow2.asm:asm-commons:9.1") diff --git a/patches/server/Add-Destroy-Speed-API.patch b/patches/server/Add-Destroy-Speed-API.patch index 64312bf671..113b765096 100644 --- a/patches/server/Add-Destroy-Speed-API.patch +++ b/patches/server/Add-Destroy-Speed-API.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -0,0 +0,0 @@ public class CraftBlock implements Block { - public String getTranslationKey() { + public String translationKey() { return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); } + diff --git a/patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch b/patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch deleted file mode 100644 index b980978bbd..0000000000 --- a/patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MeFisto94 -Date: Tue, 11 Aug 2020 19:16:09 +0200 -Subject: [PATCH] Add a way to get translation keys for blocks, entities and - materials - - -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -@@ -0,0 +0,0 @@ public class CraftBlock implements Block { - public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() { - return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMS().getBlock().defaultBlockState().getSoundType()); - } -+ -+ @Override -+ public String getTranslationKey() { -+ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); -+ } - // Paper end - } -diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -0,0 +0,0 @@ import org.bukkit.Registry; - import org.bukkit.UnsafeValues; - import org.bukkit.advancement.Advancement; - import org.bukkit.block.data.BlockData; -+import org.bukkit.craftbukkit.block.CraftBlock; - import org.bukkit.craftbukkit.block.data.CraftBlockData; - import org.bukkit.craftbukkit.inventory.CraftItemStack; - import org.bukkit.craftbukkit.legacy.CraftLegacy; -@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - throw new RuntimeException(); - } - } -+ -+ @Override -+ public String getTranslationKey(Material mat) { -+ if (mat.isBlock()) { -+ return getBlock(mat).getDescriptionId(); -+ } -+ return getItem(mat).getDescriptionId(); -+ } -+ -+ @Override -+ public String getTranslationKey(org.bukkit.block.Block block) { -+ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId(); -+ } -+ -+ @Override -+ public String getTranslationKey(org.bukkit.entity.EntityType type) { -+ return net.minecraft.world.entity.EntityType.byString(type.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElse(null); -+ } -+ -+ @Override -+ public String getTranslationKey(org.bukkit.inventory.ItemStack itemStack) { -+ net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack); -+ return nmsItemStack.getItem().getDescriptionId(nmsItemStack); -+ } - // Paper end - - /** diff --git a/patches/server/Add-methods-to-get-translation-keys.patch b/patches/server/Add-methods-to-get-translation-keys.patch new file mode 100644 index 0000000000..22d8726ba5 --- /dev/null +++ b/patches/server/Add-methods-to-get-translation-keys.patch @@ -0,0 +1,124 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Tue, 11 Aug 2020 19:16:09 +0200 +Subject: [PATCH] Add methods to get translation keys + +Co-authored-by: MeFisto94 + +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +@@ -0,0 +0,0 @@ public class CraftBlock implements Block { + public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() { + return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMS().getBlock().defaultBlockState().getSoundType()); + } ++ ++ @Override ++ public String getTranslationKey() { ++ return this.translationKey(); ++ } ++ ++ @Override ++ public String translationKey() { ++ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this); ++ } + // Paper end + } +diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java ++++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +@@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment { + public net.kyori.adventure.text.Component displayName(int level) { + return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level)); + } ++ ++ @Override ++ public String translationKey() { ++ return this.target.getDescriptionId(); ++ } + // Paper end + + public net.minecraft.world.item.enchantment.Enchantment getHandle() { +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { + throw new RuntimeException(); + } + } ++ ++ @Override ++ public String getTranslationKey(Material mat) { ++ if (mat.isBlock()) { ++ return getBlock(mat).getDescriptionId(); ++ } ++ return getItem(mat).getDescriptionId(); ++ } ++ ++ @Override ++ public String getTranslationKey(org.bukkit.block.Block block) { ++ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId(); ++ } ++ ++ @Override ++ public String getTranslationKey(org.bukkit.entity.EntityType type) { ++ return net.minecraft.world.entity.EntityType.byString(type.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElse(null); ++ } ++ ++ @Override ++ public String getTranslationKey(org.bukkit.inventory.ItemStack itemStack) { ++ net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack); ++ return nmsItemStack.getItem().getDescriptionId(nmsItemStack); ++ } + // Paper end + + /** +diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java ++++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +@@ -0,0 +0,0 @@ import org.bukkit.Difficulty; + import org.junit.Assert; + import org.junit.Test; + +-public class TranslationKeyTest { ++public class TranslationKeyTest extends org.bukkit.support.AbstractTestingBase { + + @Test + public void testChatVisibilityKeys() { +@@ -0,0 +0,0 @@ public class TranslationKeyTest { + Assert.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey()); + } + } ++ ++ @Test ++ public void testDifficultyKeys() { ++ for (Difficulty bukkitDifficulty : Difficulty.values()) { ++ Assert.assertEquals(bukkitDifficulty + "'s translation key doesn't match", ((TranslatableComponent) net.minecraft.world.Difficulty.byId(bukkitDifficulty.ordinal()).getDisplayName()).getKey(), bukkitDifficulty.translationKey()); ++ } ++ } ++ ++ @Test ++ public void testGameruleKeys() { ++ for (org.bukkit.GameRule rule : org.bukkit.GameRule.values()) { ++ Assert.assertEquals(rule.getName() + "'s translation doesn't match", org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey()); ++ } ++ } ++ ++ @Test ++ public void testAttributeKeys() { ++ for (org.bukkit.attribute.Attribute attribute : org.bukkit.attribute.Attribute.values()) { ++ Assert.assertEquals("translation key mismatch for " + attribute, org.bukkit.craftbukkit.attribute.CraftAttributeMap.toMinecraft(attribute).getDescriptionId(), attribute.translationKey()); ++ } ++ } ++ ++ @Test ++ public void testFireworkEffectType() { ++ for (org.bukkit.FireworkEffect.Type type : org.bukkit.FireworkEffect.Type.values()) { ++ Assert.assertEquals("translation key mismatch for " + type, net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type)); ++ } ++ } + } diff --git a/patches/server/Implement-Player-Client-Options-API.patch b/patches/server/Implement-Player-Client-Options-API.patch index 9eb2e5f9f3..89f6592911 100644 --- a/patches/server/Implement-Player-Client-Options-API.patch +++ b/patches/server/Implement-Player-Client-Options-API.patch @@ -125,3 +125,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end @Override +diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 +--- /dev/null ++++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +@@ -0,0 +0,0 @@ ++package io.papermc.paper.world; ++ ++import com.destroystokyo.paper.ClientOption; ++import net.minecraft.network.chat.TranslatableComponent; ++import net.minecraft.world.entity.player.ChatVisiblity; ++import org.bukkit.Difficulty; ++import org.junit.Assert; ++import org.junit.Test; ++ ++public class TranslationKeyTest { ++ ++ @Test ++ public void testChatVisibilityKeys() { ++ for (ClientOption.ChatVisibility chatVisibility : ClientOption.ChatVisibility.values()) { ++ if (chatVisibility == ClientOption.ChatVisibility.UNKNOWN) continue; ++ Assert.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey()); ++ } ++ } ++} diff --git a/patches/server/More-Enchantment-API.patch b/patches/server/More-Enchantment-API.patch index 3aa9e49073..88e7fb9e15 100644 --- a/patches/server/More-Enchantment-API.patch +++ b/patches/server/More-Enchantment-API.patch @@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override @@ -0,0 +0,0 @@ public class CraftEnchantment extends Enchantment { - public net.kyori.adventure.text.Component displayName(int level) { - return io.papermc.paper.adventure.PaperAdventure.asAdventure(getHandle().getFullname(level)); + public String translationKey() { + return this.target.getDescriptionId(); } + + @Override