Solved Scheduler

Discussion in 'Spigot Plugin Development' started by tinusium, Jun 29, 2018.

  1. Well hello, I make a survival plugin for self use.But it has also a scoreboard in it. I have registererd the Scoreboard class in my main class and when i reload it gives no errors but when i join it gives a error. Can someone help me?

    Main.class: ttps://
    scoreboard.class: ttps://
  2. Optic_Fusion1

    Resource Staff

    This is not a resource
    Edit: "29.06 12:53:05 [Server] INFO Caused by: java.lang.IllegalArgumentException: Plugin cannot be null"
    You never initialize the plugin variables also "Bukkit.getServer().getPluginManager().enablePlugin(this);"
    Don't do this, you're enabling the plugin twice which will cause errors
    • Agree Agree x 1
    • Informative Informative x 1
  3. The thing is that you did not initialize the Plugin instance in your main class properly, and so it is null. Please check your stacktrace again. If you do not now how to initialize correctly tell me.

    Edit: in your onEnable method put plugin = this;
    • Informative Informative x 1
  4. Optic_Fusion1

    Resource Staff


    Code (Text):

        //You don't need the plugin variable if you have the instance
        private static Main instance;
        public void onEnable() {
                    //Set the instance variable
                    instance = this;
            this.getServer().getPluginManager().registerEvents(new gui(), this);
            this.getServer().getPluginManager().registerEvents(new scoreboard(), this);
            ConsoleCommandSender consolesender = Bukkit.getServer().getConsoleSender();
            consolesender.sendMessage(ChatColor.RED + "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
            consolesender.sendMessage(ChatColor.WHITE + "plugin: " + ChatColor.RED + "Survival");
            consolesender.sendMessage(ChatColor.WHITE + "version: " + ChatColor.RED + getDescription().getVersion());
            consolesender.sendMessage(ChatColor.WHITE + "by: " + ChatColor.RED + "tinusium");
            consolesender.sendMessage(ChatColor.WHITE + "Website: " + ChatColor.RED + "");
            consolesender.sendMessage(ChatColor.RED + "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
            this.getCommand("survival").setExecutor(new survival());
           public static Main getInstance() {
               return instance;

  5. I removed it from my main class. I added also some stuff to my scoreboard what gives also no errors but it wont load the scoreboard when i join my server
  6. The way you are doing it is not the best one. Create a method, in your main class for example with all the scoreboard staff and with the Scoreboard as a class-variable, and then schedule in your onEnable the method for all the online players.
  7. Remove the resource tag.