Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-24 07:10:10 +01:00
Add Translatable interface to MusicInstrument (#9538)
Dieser Commit ist enthalten in:
Ursprung
a40e48f3fd
Commit
7d1cc6d409
@ -184,6 +184,31 @@ index 7705fece7f58bd66f7d68da85f8f34e43b4bae12..6a89eab53f21bc4420e616cc299864fb
|
||||
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 614dc9f2ff5aa69659947c3fcedef98f9c9bab98..be5b47659d780ab5f97634fc44faa24456b6ebf0 100644
|
||||
--- a/src/main/java/org/bukkit/MusicInstrument.java
|
||||
+++ b/src/main/java/org/bukkit/MusicInstrument.java
|
||||
@@ -8,7 +8,7 @@ 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<>();
|
||||
//
|
||||
@@ -63,4 +63,11 @@ 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 e3faa2c675c85a9cbdbbb1debec0ff81c58a1bbd..fd1629c2d2028a88fb3d56b0aeb833d17235080a 100644
|
||||
--- a/src/main/java/org/bukkit/Translatable.java
|
||||
|
@ -41,16 +41,18 @@ index e8334e2264510f5101e80b4f130e7ae1442560d7..57decf4156f176ebcc988478c17856cb
|
||||
|
||||
public net.minecraft.world.item.enchantment.Enchantment getHandle() {
|
||||
diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
index fab3063fffa959ac7f0eb5937f2fae94d11b6591..4cc8ca5dd95e9cccd08ada057a9592a1421f434a 100644
|
||||
index fab3063fffa959ac7f0eb5937f2fae94d11b6591..ffc9776a8927d6255820d1384c9e66f99a7b692c 100644
|
||||
--- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
+++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
||||
@@ -1,12 +1,23 @@
|
||||
@@ -1,12 +1,27 @@
|
||||
package io.papermc.paper.world;
|
||||
|
||||
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 fab3063fffa959ac7f0eb5937f2fae94d11b6591..4cc8ca5dd95e9cccd08ada057a9592a1
|
||||
+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;
|
||||
@ -69,7 +73,7 @@ index fab3063fffa959ac7f0eb5937f2fae94d11b6591..4cc8ca5dd95e9cccd08ada057a9592a1
|
||||
|
||||
@Test
|
||||
public void testChatVisibilityKeys() {
|
||||
@@ -15,4 +26,58 @@ public class TranslationKeyTest {
|
||||
@@ -15,4 +30,67 @@ public class TranslationKeyTest {
|
||||
Assert.assertEquals(chatVisibility + "'s translation key doesn't match", ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey());
|
||||
}
|
||||
}
|
||||
@ -126,5 +130,14 @@ index fab3063fffa959ac7f0eb5937f2fae94d11b6591..4cc8ca5dd95e9cccd08ada057a9592a1
|
||||
+ 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());
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren