Solved How can this simple line glitch my whole plugin

Discussion in 'Spigot Plugin Development' started by Kyllian, May 2, 2017.

  1. Alright,

    This is my big friend that glitches my whole plugin:

    Code (Text):
    private CreateCaptcha cc = CreateCaptcha.getInstance();
    I '//'ed all the parts that used that class. so I was sure it was that.

    When I // that line it works fine too.

    The class that gives errors uses the exact same line.

    Code (Text):
    [19:04:50 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:124) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:04:50 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:53) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:53) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:124) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:100) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:31) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:100) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:05 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:77) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    [19:06:06 WARN]: [Captcha] Task #530 for Captcha v3.05 generated an exception
    java.lang.NullPointerException
            at me.kyllian.captcha.utils.CreateCaptcha.createCaptcha(CreateCaptcha.java:124) ~[?:?]
            at me.kyllian.captcha.listeners.OnPlayerJoinEvent$1.run(OnPlayerJoinEvent.java:53) ~[?:?]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at org.bukkit.craftbukkit.v1_11_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:353) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:738) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
            at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot1.11.jar:git-Spigot-625bc00-d09304e]
    Those lines are

    Code (Text):
    if (main.getConfig().getBoolean("Captcha2Enabled")) {
    So getting things from main class.

    How I get main class
    Code (Text):
    private Captcha main = Captcha.getInstance();
     
    How I send my CreateCaptcha class

    Code (Text):
        public static CreateCaptcha cc = new CreateCaptcha();

        public static CreateCaptcha getInstance() {
            return cc;
        }
    It only glitches with one line enabled, what's wrong?
     
    #1 Kyllian, May 2, 2017
    Last edited: May 2, 2017
  2. Maybe initialize it :O I wonder....
     
  3. How do you mean intialize, Intializing the main class is done already.

    Main class:

    Code (Text):
        public static Captcha main;

        public static Captcha getInstance() {
            return main;
        }

    public void onEnable() {
            main = this;
    // more of my fancy code
    }
    CreateCaptcha:

    Code (Text):
    public static CreateCaptcha cc = new CreateCaptcha();

        public static CreateCaptcha getInstance() {
            return cc;
        }

        private Captcha main = Captcha.getInstance();
     
     
  4. Maybe try it this way,
    Code (Text):
    private static Captcha cc;
    public static Captcha getInstance(){
    if (cc==null){
    cc = new Captcha();
    }
    return cc;
    }
     
  5. Doesn't work.
     
  6. Guess I fixed it by doing:

    Code (Text):
    private CreateCaptcha cc;
    Above my class,

    And in the end of onenable:

    cc = CreateCaptcha.getInstance();
     
  7. Yep, works thread is marked as solved