mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-30 19:40:37 +01:00
Add Translatable interface to MusicInstrument (#9538)
This commit is contained in:
parent
cbfc2065f5
commit
1f967356b8
2 changed files with 38 additions and 0 deletions
|
@ -184,6 +184,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
public String getTranslationKey() {
|
||||
if (this.isItem()) {
|
||||
return Bukkit.getUnsafe().getItemTranslationKey(this);
|
||||
diff --git a/src/main/java/org/bukkit/MusicInstrument.java b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/MusicInstrument.java
|
||||
+++ b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
@@ -0,0 +0,0 @@ import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-public final class MusicInstrument implements Keyed {
|
||||
+public final class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys
|
||||
|
||||
private static final Map<NamespacedKey, MusicInstrument> INSTRUMENTS = new HashMap<>();
|
||||
//
|
||||
@@ -0,0 +0,0 @@ public final class MusicInstrument implements Keyed {
|
||||
|
||||
return new MusicInstrument(NamespacedKey.minecraft(name));
|
||||
}
|
||||
+
|
||||
+ // Paper start - translation key
|
||||
+ @Override
|
||||
+ public @NotNull String translationKey() {
|
||||
+ return "instrument.minecraft." + this.key.value();
|
||||
+ }
|
||||
+ // Paper end - translation key
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Translatable.java b/src/main/java/org/bukkit/Translatable.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Translatable.java
|
||||
|
|
|
@ -49,8 +49,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
import com.destroystokyo.paper.ClientOption;
|
||||
+import java.util.Map;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.ChatVisiblity;
|
||||
+import net.minecraft.world.level.GameType;
|
||||
+import net.minecraft.world.level.biome.Biome;
|
||||
|
@ -58,7 +60,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import org.bukkit.FireworkEffect;
|
||||
+import org.bukkit.GameMode;
|
||||
+import org.bukkit.GameRule;
|
||||
+import org.bukkit.MusicInstrument;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
+import org.junit.Ignore;
|
||||
|
@ -126,5 +130,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase());
|
||||
+ Assert.assertEquals("translation key mismatch for " + bukkit, nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testMusicInstrument() {
|
||||
+ for (final ResourceLocation nms : BuiltInRegistries.INSTRUMENT.keySet()) {
|
||||
+ final MusicInstrument bukkit = MusicInstrument.getByKey(CraftNamespacedKey.fromMinecraft(nms));
|
||||
+ Assert.assertNotNull("Missing bukkit instrument for " + nms, bukkit);
|
||||
+ Assert.assertEquals("translation key mismatch for " + bukkit, nms.toLanguageKey("instrument"), bukkit.translationKey());
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue