Reload Internal error occured

Discussion in 'Spigot Plugin Development' started by DocDrewskii, May 31, 2018.

  1. Hello, I am making a staff list plugin that reloads the config, But I'm having trouble, Everytime I reload it, An internal error occurs, can someone tell me whats wrong with the code
    Code (Text):
        if (cmd.getName().equalsIgnoreCase("StaffList")) {
            if (sender.hasPermission("StaffList.reload")) {
                if (args.length == 0) {
                    sender.sendMessage(ChatColor.GREEN + "USAGE: /StaffList Reload - Reloads the Config");
                    return true;
                }

                if (args[0].equalsIgnoreCase("Reload")) {
                    long l1 = System.currentTimeMillis();
                    sender.sendMessage("RELOADING");
                    Bukkit.getScheduler().cancelTasks(StaffList.getInstance());
                    StaffList.getInstance().reloadConfig();
                    StaffList.getInstance().saveConfig();
                   
                    long l2 = System.currentTimeMillis() - l1;
                    DecimalFormat formatter = new DecimalFormat("###.#");
                    sender.sendMessage(p.sendMessage("RELOAD-COMPLETE") + ("%ms%", formatter.format(l2)));
            }
        }
        return false;
        }
        }
      }
    }
     
  2. Would help to see the error.
     
    • Agree Agree x 1
  3. Error:
    Code (Text):
     30.05 20:11:07 [Server] ERROR null
    30.05 20:11:07 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'stafflist' in plugin StaffList v1.2
    30.05 20:11:07 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_05]
    30.05 20:11:07 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_05]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:714) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556) [spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_05]
    30.05 20:11:07 [Server] INFO Caused by: java.lang.IllegalArgumentException: Cannot cancel tasks of null plugin
    30.05 20:11:07 [Server] INFO at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.cancelTasks(CraftScheduler.java:202) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at com.LilDevs.spigot.StaffList.onCommand(StaffList.java:102) ~[?:?]
    30.05 20:11:07 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO ... 15 more
     
    @BillyGalbreath
     
  4. 0.05 20:11:07 [Server] INFO Caused by: java.lang.IllegalArgumentException: Cannot cancel tasks of null plugin
    30.05 20:11:07 [Server] INFO at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.cancelTasks(CraftScheduler.java:202) ~[spigot-1.8.8.jar:git-Spigot-76236cb-9cd1111]
    30.05 20:11:07 [Server] INFO at com.LilDevs.spigot.StaffList.onCommand(StaffList.java:102) ~[?:?]


    What is line 102 of your StaffList class?

    If it's Bukkit.getScheduler().cancelTasks(StaffList.getInstance()); then your main class's getInstance() method is returning null.


    Also, for future reference: https://bukkit.org/threads/how-to-r...ubleshoot-your-own-plugins-by-yourself.32457/
     
  5. My line for 102 is just a }
     
    • Informative Informative x 1
  6. Then your stacktrace does not match your current code. Recompile your current code, and check the error again. Use the knowledge from above to solve the issue.
     
  7. I am gonna fix your code
    Code (Text):
        if (cmd.getName().equalsIgnoreCase("StaffList")) {
            if (sender.hasPermission("StaffList.reload")) {
                if (args.length == 0) {
                    sender.sendMessage(ChatColor.GREEN + "USAGE: /StaffList Reload - Reloads the Config");
                    return true;
                }
            } else if (args[0].equalsIgnoreCase("Reload")) {
                    long l1 = System.currentTimeMillis();
                    sender.sendMessage("RELOADING");
                    Bukkit.getScheduler().cancelTasks(StaffList.getInstance());
                    StaffList.getInstance().reloadConfig();
                    StaffList.getInstance().saveConfig();
                 
                    long l2 = System.currentTimeMillis() - l1;
                    DecimalFormat formatter = new DecimalFormat("###.#");
                    sender.sendMessage(p.sendMessage("RELOAD-COMPLETE") + ("%ms%", formatter.format(l2)));
            }
        return false;
        }
        }
      }
    }
    Try this if you have error tell me
     
  8. Strahan

    Benefactor

    That code has flawed bracketing.