mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 04:02:50 +01:00
74f507f4e3
Upstream has released updates that appears 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: e461dcfe #555: Item - add getters/setters for owner/thrower CraftBukkit Changes: 055870c4 #758: Item - add getters/setters for owner/thrower
98 lines
3.8 KiB
Diff
98 lines
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MeFisto94 <MeFisto94@users.noreply.github.com>
|
|
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 e203c5bfc1d1bf6b500ef8a4446d3aef182b8ecb..4ba991b79f13219182df35b4ce0c5cf57cbd208b 100644
|
|
--- a/src/main/java/org/bukkit/Material.java
|
|
+++ b/src/main/java/org/bukkit/Material.java
|
|
@@ -3580,6 +3580,16 @@ 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 d3ec5084e33dff038d54cdd2aeb703a3eb25f7a7..ac43afbf6230a481ab8cffbb3bc91b716316c00d 100644
|
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
@@ -94,5 +94,27 @@ 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 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 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 TranslatableComponent.<br>
|
|
+ * This is <code>null</code>, when the EntityType isn't known to NMS (custom entities)
|
|
+ * @return the translation key
|
|
+ */
|
|
+ String getTranslationKey(org.bukkit.entity.EntityType type);
|
|
// Paper end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
|
index f8c599718143fe638de422fd4625f353ee6c54ae..7616c5601adee3cbe0e5f722646a2458b535ab77 100644
|
|
--- a/src/main/java/org/bukkit/block/Block.java
|
|
+++ b/src/main/java/org/bukkit/block/Block.java
|
|
@@ -573,5 +573,13 @@ 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 774363a8186b3861f10c0452ac63726cae365169..692b75eb78405874077c850bfc72e247ccc80860 100644
|
|
--- a/src/main/java/org/bukkit/entity/EntityType.java
|
|
+++ b/src/main/java/org/bukkit/entity/EntityType.java
|
|
@@ -414,4 +414,15 @@ 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.<br>
|
|
+ * This is <code>null</code>, when the EntityType isn't known to NMS (custom entities)
|
|
+ * @return the translation key
|
|
+ */
|
|
+ @Nullable
|
|
+ String getTranslationKey() {
|
|
+ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
|
|
+ }
|
|
}
|