mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
31699ae9a8
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: a6a9d2a4 Remove some old ApiStatus.Experimental annotations be72314c SPIGOT-7300, PR-829: Add new DamageSource API providing enhanced information about entity damage b252cf05 SPIGOT-7576, PR-970: Add methods in MushroomCow to change stew effects b1c689bd PR-902: Add Server#isLoggingIPs to get log-ips configuration 08f86d1c PR-971: Add Player methods for client-side potion effects 2e3024a9 PR-963: Add API for in-world structures a23292a7 SPIGOT-7530, PR-948: Improve Resource Pack API with new 1.20.3 functionality 1851857b SPIGOT-3071, PR-969: Add entity spawn method with spawn reason cde4c52a SPIGOT-5553, PR-964: Add EntityKnockbackEvent CraftBukkit Changes: 38fd4bd50 Fix accidentally renamed internal damage method 80f0ce4be SPIGOT-7300, PR-1180: Add new DamageSource API providing enhanced information about entity damage 7e43f3b16 SPIGOT-7581: Fix typo in BlockMushroom ea14b7d90 SPIGOT-7576, PR-1347: Add methods in MushroomCow to change stew effects 4c687f243 PR-1259: Add Server#isLoggingIPs to get log-ips configuration 22a541a29 Improve support for per-world game rules cb7dccce2 PR-1348: Add Player methods for client-side potion effects b8d6109f0 PR-1335: Add API for in-world structures 4398a1b5b SPIGOT-7577: Make CraftWindCharge#explode discard the entity e74107678 Fix Crafter maximum stack size 0bb0f4f6a SPIGOT-7530, PR-1314: Improve Resource Pack API with new 1.20.3 functionality 4949f556d SPIGOT-3071, PR-1345: Add entity spawn method with spawn reason 20ac73ca2 PR-1353: Fix Structure#place not working as documented with 0 palette 3c1b77871 SPIGOT-6911, PR-1349: Change max book length in CraftMetaBook 333701839 SPIGOT-7572: Bee nests generated without bees f48f4174c SPIGOT-5553, PR-1336: Add EntityKnockbackEvent
144 lines
6.8 KiB
Diff
144 lines
6.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Tue, 11 Aug 2020 19:16:09 +0200
|
|
Subject: [PATCH] Add methods to get translation keys
|
|
|
|
== AT ==
|
|
public org.bukkit.craftbukkit.inventory.CraftMetaFirework
|
|
public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/FireworkEffect$Type;)I
|
|
|
|
Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index f041b5d80bff9c022b007e04ef1558e9116acc6b..a586442422a2b2c06b785af0d261d3e19eb1d59b 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -669,5 +669,10 @@ public class CraftBlock implements Block {
|
|
public org.bukkit.SoundGroup getBlockSoundGroup() {
|
|
return org.bukkit.craftbukkit.CraftSoundGroup.getSoundGroup(this.getNMS().getSoundType());
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public String translationKey() {
|
|
+ return this.getNMS().getBlock().getDescriptionId();
|
|
+ }
|
|
// 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 f0f7fb977edb7e7009716429f007e44fa36bfcda..7aa4035a4df1ddcc71065034eafd569ca59be810 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java
|
|
@@ -152,6 +152,11 @@ public class CraftEnchantment extends Enchantment implements Handleable<net.mine
|
|
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.handle.getDescriptionId();
|
|
+ }
|
|
// 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
|
|
index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..dbd1dc4453bd26fb6116b62f6ccbf69e92e09fc4 100644
|
|
--- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
|
+++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
|
|
@@ -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;
|
|
import org.bukkit.Difficulty;
|
|
+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.jupiter.api.Assertions;
|
|
+import org.junit.jupiter.api.Disabled;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
-public class TranslationKeyTest {
|
|
+public class TranslationKeyTest extends AbstractTestingBase {
|
|
|
|
@Test
|
|
public void testChatVisibilityKeys() {
|
|
@@ -15,4 +30,67 @@ public class TranslationKeyTest {
|
|
Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match");
|
|
}
|
|
}
|
|
+
|
|
+ @Test
|
|
+ public void testDifficultyKeys() {
|
|
+ for (Difficulty bukkitDifficulty : Difficulty.values()) {
|
|
+ Assertions.assertEquals(((TranslatableContents) net.minecraft.world.Difficulty.byId(bukkitDifficulty.ordinal()).getDisplayName().getContents()).getKey(), bukkitDifficulty.translationKey(), bukkitDifficulty + "'s translation key doesn't match");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testGameruleKeys() {
|
|
+ for (GameRule<?> rule : GameRule.values()) {
|
|
+ Assertions.assertEquals(org.bukkit.craftbukkit.CraftWorld.getGameRulesNMS().get(rule.getName()).getDescriptionId(), rule.translationKey(), rule.getName() + "'s translation doesn't match");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testAttributeKeys() {
|
|
+ for (Attribute attribute : Attribute.values()) {
|
|
+ Assertions.assertEquals(org.bukkit.craftbukkit.attribute.CraftAttribute.bukkitToMinecraft(attribute).getDescriptionId(), attribute.translationKey(), "translation key mismatch for " + attribute);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testFireworkEffectType() {
|
|
+ for (FireworkEffect.Type type : FireworkEffect.Type.values()) {
|
|
+ Assertions.assertEquals(net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type), "translation key mismatch for " + type);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ @Disabled // TODO fix
|
|
+ public void testCreativeCategory() {
|
|
+ // for (CreativeModeTab tab : CreativeModeTabs.tabs()) {
|
|
+ // CreativeCategory category = Objects.requireNonNull(CraftCreativeCategory.fromNMS(tab));
|
|
+ // Assertions.assertEquals("translation key mismatch for " + category, ((TranslatableContents) tab.getDisplayName().getContents()).getKey(), category.translationKey());
|
|
+ // }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testGameMode() {
|
|
+ for (GameType nms : GameType.values()) {
|
|
+ GameMode bukkit = GameMode.getByValue(nms.getId());
|
|
+ Assertions.assertNotNull(bukkit);
|
|
+ Assertions.assertEquals(((TranslatableContents) nms.getLongDisplayName().getContents()).getKey(), bukkit.translationKey(), "translation key mismatch for " + bukkit);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testBiome() {
|
|
+ for (Map.Entry<ResourceKey<Biome>, Biome> nms : AbstractTestingBase.BIOMES.entrySet()) {
|
|
+ org.bukkit.block.Biome bukkit = org.bukkit.block.Biome.valueOf(nms.getKey().location().getPath().toUpperCase());
|
|
+ Assertions.assertEquals(nms.getKey().location().toLanguageKey("biome"), bukkit.translationKey(), "translation key mismatch for " + bukkit);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Test
|
|
+ public void testMusicInstrument() {
|
|
+ for (final ResourceLocation nms : BuiltInRegistries.INSTRUMENT.keySet()) {
|
|
+ final MusicInstrument bukkit = MusicInstrument.getByKey(CraftNamespacedKey.fromMinecraft(nms));
|
|
+ Assertions.assertNotNull(bukkit, "Missing bukkit instrument for " + nms);
|
|
+ Assertions.assertEquals(nms.toLanguageKey("instrument"), bukkit.translationKey(), "translation key mismatch for " + bukkit);
|
|
+ }
|
|
+ }
|
|
}
|