Solved Console Error

Discussion in 'Spigot Plugin Development' started by WaysFXasd, Jul 22, 2021.

  1. I'm sure that I'm making some really obvious error that I just cannot see. I tried creating a GUI and I'm having a problem with the command execution. Help me if you think where the problem. I got this error when executing command /xguicreator open <name> <player>

    ERROR:
    org.bukkit.command.CommandException: Unhandled exception executing command 'xguicreator' in plugin XGuiCreator v1.0-SNAPSHOT
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2185) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:2000) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1953) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:7) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1266) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1259) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1220) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1134) ~[patched_1.16.5.jar:git-Paper-782]
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-782]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
    Caused by: java.lang.IllegalArgumentException: Title cannot be null
    at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryCustom$MinecraftInventory.<init>(CraftInventoryCustom.java:77) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventoryCustom.<init>(CraftInventoryCustom.java:43) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.inventory.util.CraftCustomInventoryConverter.createInventory(CraftCustomInventoryConverter.java:38) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.inventory.util.CraftInventoryCreator.createInventory(CraftInventoryCreator.java:82) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.createInventory(CraftServer.java:1888) ~[patched_1.16.5.jar:git-Paper-782]
    at org.bukkit.Bukkit.createInventory(Bukkit.java:1280) ~[patched_1.16.5.jar:git-Paper-782]
    at XGui.WaysFX.ru.lambda$onCommand$0(ru.java:59) ~[?:?]
    at java.lang.Iterable.forEach(Unknown Source) ~[?:1.8.0_281]
    at XGui.WaysFX.ru.onCommand(ru.java:56) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-782]
    ... 19 more

    CODE
    Code (Java):


    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (label.equalsIgnoreCase("xguicreator")) {
            if (!sender.hasPermission("xgui.main")) {
                for (String msg : this.getConfig().getStringList("messages.missing-permission")) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                }
                return true;
            }
            if (args.length == 0) {
                for (String msg : this.getConfig().getStringList("messages.help-message")) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                }
                return true;
            }
            if (args[0].equalsIgnoreCase("reload")) {
                for (String msg : this.getConfig().getStringList("messages.reload-message")) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                }
                this.reloadConfig();
            }
            if (args[0].equalsIgnoreCase("open")) {
                this.getConfig().getConfigurationSection("guis").getKeys(false).forEach(key -> {
                    if (key.equalsIgnoreCase(args[1])) {
                        if (sender instanceof Player) {
                            Inventory CurrentInventory = Bukkit.createInventory((Player) sender, this.getConfig().getInt("guis." + key + ".size"), this.getConfig().getString("guis" + key));
                            ((Player) sender).openInventory(CurrentInventory);
                        }else{
                            for (String msg : this.getConfig().getStringList("messages.Executable-only-player")) {
                                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                            }
                        }
                    }else {
                        for (String msg : this.getConfig().getStringList("messages.UnknownGUI-message")) {
                            sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                        }
                    }
                });
            }
            if (args.length > 0) {
                if (args[0].equalsIgnoreCase("editor")) {
                    this.getConfig().getConfigurationSection("guis").getKeys(false).forEach(key -> {
                        if (key.equalsIgnoreCase(args[1])) {
                            if (sender instanceof Player) {
                                Inventory editor = Bukkit.createInventory(null, 45, this.getConfig().getString("guis." + key + ".| EDITOR"));


                            }else{
                                for (String msg : this.getConfig().getStringList("messages.Executable-only-player")) {
                                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                                }
                            }
                        }else{
                            for (String msg : this.getConfig().getStringList("messages.UnknownGUI-message")) {
                                sender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
                            }
                        }

                    });
                }
            }
        }
        return false;
    }
     
  2. Send ru.java:59 code.
     
  3. what's wrong with that?
    Code (Java):
     
    Inventory CurrentInventory = Bukkit.createInventory((Player) sender, this.getConfig().getInt("guis." + key + ".size"), this.getConfig().getString("guis" + key));
     
  4. The contents of config.yml are empty or written incorrectly.
     
  5. My config
    Code (Java):
     
    guis:
      "ExampleGUI":
        size: 9
        close-icon-enabled: true
        filler-enabled: true
        filler-slots:
          - 0
          - 1
          - 2
          - 3
          - 4
          - 5
          - 6
          - 7
          - 8
          - 9
     
  6. Remove the " between "ExampleGUI".
     
    • Agree Agree x 1
  7. I changed the config and code a little (Thank you for pointing out the error to me)
    Code (Java):
     
    guis:
      ExampleGUI:
        name: XGui
        size: 9
        close-icon-enabled: true
        filler-enabled: true
        filler-slots:
          - 0
          - 1
          - 2
          - 3
          - 4
          - 5
          - 6
          - 7
          - 8
          - 9


    Inventory CurrentInventory = Bukkit.createInventory((Player) sender, this.getConfig().getInt("guis." + key + ".size"), this.getConfig().getString("guis." + key + ".name"));