因此,我正在为服务器创建自定义插件,我的功能之一要求我在gui中设置一个整数,以显示用户拥有多少个“ CommonPackages”。我遇到的问题是,当我从配置中获取字符串时(我的配置使用了由朋友提供给我的自定义文件创建/管理类),它说在gui中为null,我会在控制台中没有任何错误,请有人帮我吗? gui中的项目以及在gui中设置该项目的代码。
gui创建代码:
public static Inventory WhiteBackpack(Player player) {
UUID uuid = player.getUniqueId();
Inventory inv = Bukkit.createInventory(null, 27, (inventoryname));
ItemStack common = new ItemStack(Material.INK_SACK);
common.setDurability((byte) 8);
ItemMeta commonMeta = common.getItemMeta();
commonMeta.setDisplayName(Utils.chat("&fCommon Packages &8» &f&l" + Main.pl.getFileControl().getConfig().getString("players." + uuid + ".Packages.Common"))); //How I access my custom configs.
common.setItemMeta(commonMeta);
inv.setItem(10, common);
return inv;
}
答案 0 :(得分:0)
没有用于获取配置的方法代码,我只能说实际文件中的字符串不存在。
如Bukkit文档所述:
If the String does not exist and no default value was specified, this will return null.
因此,密钥只是在文件中不存在,或者您指向了错误的文件。配置也应该格式正确。 (没有标签,只有空格)