Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +01:00
a0b8b886c8
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
CraftBukkit Changes:
d5a72960
SPIGOT-6063: ConsoleSender sending extra lines in Java 13+
Spigot Changes:
2740d5ae Rebuild patches
111 Zeilen
5.1 KiB
Diff
111 Zeilen
5.1 KiB
Diff
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/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
|
index a45ceff9ff970b996b2767379a2ecd4693f52d3a..4b4f14711d483089a5d5478b57539911a9c7a2fc 100644
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
|
@@ -279,6 +279,7 @@ public class Block extends BlockBase implements IMaterial {
|
|
return !this.material.isBuildable() && !this.material.isLiquid();
|
|
}
|
|
|
|
+ public String getDescriptionId() { return i(); } // Paper - OBFHELPER
|
|
public String i() {
|
|
if (this.name == null) {
|
|
this.name = SystemUtils.a("block", IRegistry.BLOCK.getKey(this));
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
index 5c03fb3af34e13bc3b8bc1840c5a7e229cf9d1f7..a71ad8418e08dd506fa6b912eaed725567ac4648 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
|
@@ -147,6 +147,7 @@ public class EntityTypes<T extends Entity> {
|
|
return IRegistry.ENTITY_TYPE.getKey(entitytypes);
|
|
}
|
|
|
|
+ public static Optional<EntityTypes<?>> getByName(String name) { return a(name); } // Paper - OBFHELPER
|
|
public static Optional<EntityTypes<?>> a(String s) {
|
|
return IRegistry.ENTITY_TYPE.getOptional(MinecraftKey.a(s));
|
|
}
|
|
@@ -285,6 +286,7 @@ public class EntityTypes<T extends Entity> {
|
|
return this.bg;
|
|
}
|
|
|
|
+ public String getDescriptionId() { return f(); } // Paper - OBFHELPER
|
|
public String f() {
|
|
if (this.bo == null) {
|
|
this.bo = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
|
|
diff --git a/src/main/java/net/minecraft/server/Item.java b/src/main/java/net/minecraft/server/Item.java
|
|
index 5ae1542a04b6f89c36231dc340c7d4538c4dbdd4..c3b57e8d572d13ec74d6df5544072cdc55756690 100644
|
|
--- a/src/main/java/net/minecraft/server/Item.java
|
|
+++ b/src/main/java/net/minecraft/server/Item.java
|
|
@@ -26,7 +26,7 @@ public class Item implements IMaterial {
|
|
private final FoodInfo foodInfo;
|
|
|
|
public static int getId(Item item) {
|
|
- return item == null ? 0 : IRegistry.ITEM.a((Object) item);
|
|
+ return item == null ? 0 : IRegistry.ITEM.a(item); // Paper - Fix Decompiler Issue
|
|
}
|
|
|
|
public static Item getById(int i) {
|
|
@@ -122,6 +122,7 @@ public class Item implements IMaterial {
|
|
return IRegistry.ITEM.getKey(this).getKey();
|
|
}
|
|
|
|
+ public String getOrCreateDescriptionId() { return m(); } // Paper - OBFHELPER
|
|
protected String m() {
|
|
if (this.name == null) {
|
|
this.name = SystemUtils.a("item", IRegistry.ITEM.getKey(this));
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
index f787238575ed7ac9108a2fd9782af55056219767..3524b677525bf2bb529b797fe1f258efb34ac3fc 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
@@ -752,5 +752,10 @@ public class CraftBlock implements Block {
|
|
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
|
|
return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMSBlock().getBlockData().getStepSound());
|
|
}
|
|
+
|
|
+ @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
|
|
index e76187767eddba8c38cf59691dbe93279d3dc750..b5ec7a161b22d0a0d39a6e60ce015cbf3520651a 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -42,6 +42,7 @@ import org.bukkit.NamespacedKey;
|
|
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;
|
|
@@ -373,6 +374,22 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
throw new RuntimeException();
|
|
}
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public String getTranslationKey(Material mat) {
|
|
+ return getItem(mat).getOrCreateDescriptionId();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getTranslationKey(org.bukkit.block.Block block) {
|
|
+ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getTranslationKey(org.bukkit.entity.EntityType type) {
|
|
+ return net.minecraft.server.EntityTypes.getByName(type.getName()).map(net.minecraft.server.EntityTypes::getDescriptionId).orElse(null);
|
|
+ }
|
|
+
|
|
// Paper end
|
|
|
|
/**
|