2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: MeFisto94 <MeFisto94@users.noreply.github.com>
|
|
|
|
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
|
2021-07-22 20:11:56 +02:00
|
|
|
index f17fa8223dcb0e6a90e7745117029af0fa0aa70e..a9b4277855ed3536bd00a03b85b0ae3336336c2b 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2021-07-22 20:11:56 +02:00
|
|
|
@@ -772,5 +772,10 @@ public class CraftBlock implements Block {
|
2021-06-11 14:02:28 +02:00
|
|
|
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
|
2021-07-22 20:11:56 +02:00
|
|
|
return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMS().getBlock().defaultBlockState().getSoundType());
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
2021-07-18 09:41:53 +02:00
|
|
|
index 6b79b1ea43b713105f37de517019c033477f9835..135749c789d44f0af1ad11ccd1b208f1e28853eb 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
@@ -43,6 +43,7 @@ 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;
|
|
|
|
@@ -418,6 +419,30 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(Material mat) {
|
|
|
|
+ if (mat.isBlock()) {
|
2021-06-17 21:37:37 +02:00
|
|
|
+ return getBlock(mat).getDescriptionId();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+ return getItem(mat).getDescriptionId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(org.bukkit.block.Block block) {
|
2021-06-17 21:37:37 +02:00
|
|
|
+ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(org.bukkit.entity.EntityType type) {
|
2021-06-17 22:20:03 +02:00
|
|
|
+ return net.minecraft.world.entity.EntityType.byString(type.getName()).map(net.minecraft.world.entity.EntityType::getDescriptionId).orElse(null);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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
|
|
|
|
|
|
|
|
/**
|