org.bukkit.command.CommandException试图打开GUI



我正在制作一个Minecraft Java插件,我的插件6个月前工作得很好。现在,当我回到我的插件,它不工作。

这是一个错误给出/play,打开一个GUI。

[14:07:28 INFO]: LucaForever issued server command: /play
[14:07:28 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'play' in plugin BlocksUtilities v1.6
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at java.base/java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: java.lang.IllegalArgumentException: Title cannot be null
at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom$MinecraftInventory.<init>(CraftInventoryCustom.java:58) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryCustom.<init>(CraftInventoryCustom.java:32) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.createInventory(CraftServer.java:1525) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.Bukkit.createInventory(Bukkit.java:938) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
at org.blocks.ui.GamesUI.GUI(GamesUI.java:24) ~[?:?]
at org.blocks.commands.GameUICommand.onCommand(GameUICommand.java:33) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
... 15 more

下面是我认为有问题的部分代码:

public class GamesUI 
{
public static Inventory inv;
public static String inventory_name;
public static int inv_rows = 1 * 9;

public static void initialaize()
{
inventory_name = Utils.chat("&6&lChoose a Game!");

inv = Bukkit.createInventory(null, inv_rows);
}

public static Inventory GUI (Player p)
{
Inventory toReturn = Bukkit.createInventory(p, inv_rows, inventory_name); //i tried here p and 
              null but none work

Utils.createItem(inv, 166, 1, 2, "&cStaff World", "&bClick to join the staff world!", "&4Only staff allowed!");
Utils.createItem(inv, 355, 1, 1, "&cBedwars", "&bClick to join bedwars!", "&70 players playing!");

toReturn.setContents(inv.getContents());
return toReturn;
}

public static void clicked(Player p, int slot, ItemStack clicked, Inventory inv)
{
if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.chat("&cBedwars")))
{
p.sendMessage(Utils.chat("&7Sending you to the bedwars server..."));
p.performCommand("bedwars join");
}

}
}

这是utils的一部分:

public static ItemStack createItem(Inventory inv, int materialId, int amount, int invSlot, String displayName, String... loreString)
{
ItemStack item;
List<String> lore = new ArrayList();

item = new ItemStack(Material.getMaterial(materialId), amount);

ItemMeta meta = item.getItemMeta();
meta.setDisplayName(Utils.chat(displayName));
for (String s : loreString)
{
lore.add(Utils.chat(s));
}
meta.setLore(lore);
item.setItemMeta(meta);
inv.setItem(invSlot - 1, item);
return item;
}

------------------& gt;第2部分

其他命令,如/gmc,不做任何事情。它们不显示错误,只是显示我执行了命令,然后什么也没显示。图片

谢谢你,希望能收到别人的来信。

我认为出现错误是因为您没有为您的库存设置标题。要解决这个问题,您应该为inventory_name:

分配一个值
public static String inventory_name = "name";

如果你不想要标题,你可以使用:

Inventory toReturn = Bukkit.createInventory(p, inv_rows);

您可以保留其余的代码。它应该看起来像这样:

public class GamesUI 
{
public static Inventory inv;
public static String inventory_name;
public static int inv_rows = 1 * 9;

public static void initialaize()
{
inventory_name = Utils.chat("&6&lChoose a Game!");

inv = Bukkit.createInventory(null, inv_rows);
}

public static Inventory GUI (Player p)
{
Inventory toReturn = Bukkit.createInventory(p, inv_rows, inventory_name); //i tried here p and 
              null but none work

Utils.createItem(inv, 166, 1, 2, "&cStaff World", "&bClick to join the staff world!", "&4Only staff allowed!");
Utils.createItem(inv, 355, 1, 1, "&cBedwars", "&bClick to join bedwars!", "&70 players playing!");

toReturn.setContents(inv.getContents());
return toReturn;
}

public static void clicked(Player p, int slot, ItemStack clicked, Inventory inv)
{
if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.chat("&cBedwars")))
{
p.sendMessage(Utils.chat("&7Sending you to the bedwars server..."));
p.performCommand("bedwars join");
}

}
}

相关内容

  • 没有找到相关文章

最新更新