[1.20.1] Adventure translatable 文本组件用作箱子 GUI 的标题时无法被翻译
Closed this issue · 1 comments
SNWCreations commented
Minecraft Version : 1.20.1
Mohist Version : 895 (发稿时最新)
Operating System : Windows 10
Concerned mod / plugin: 自制插件
Logs : Not applicable
Description:
编译以下这段插件代码 (使用 Paper 1.20.1 API):
package snw.srs.workbench;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
public final class Workbench extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equals("workbench")) {
if (sender instanceof Player casted) {
final Inventory inventory = Bukkit.createInventory(casted, 54, Component.translatable(Material.TNT.getBlockTranslationKey())); // issue here
casted.openInventory(inventory);
}
}
return true;
}
}
然后使用 /workbench 指令,将打开一个箱子 GUI,按照预期,箱子的标题应该是 "TNT" ,但是得到了 "block.minecraft.tnt" 。
这个问题在 Paper 1.20.1 上不能复现,疑似 Mohist 对 Paper API 的实现有误。
SNWCreations commented
#3416 解决此问题。