Instance manipulation

Discussion in 'Plugin Development' started by girardcome, Aug 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    girardcome

    Hey there i have a problem an instance manipulation, i have a NPE but idk how to fix it ...

    Stacktrace:
    PHP:
    08.08 14:24:02 [ServerINFO CONSOLEReload complete.
    08.08 14:24:02 [ServerINFO Server permissions file permissions.yml is empty, ignoring it
    08.08 14
    :24:02 [ServerINFO Enabling EssentialsChat v2.11.1
    08.08 14
    :24:02 [ServerINFO ... 10 more
    08.08 14
    :24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:771) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:350) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 14:24:02 [ServerINFO at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 14:24:02 [ServerINFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 14:24:02 [ServerINFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 14:24:02 [ServerINFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_51]
    08.08 14:24:02 [ServerINFO at fr.HungerGames.Main.<init>(Main.java:35)~[?:?]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO Caused byjava.lang.IllegalStateExceptionInitial initialization
    08.08 14
    :24:02 [ServerINFO at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:251) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at net.minecraft.server.v1_7_R1.DedicatedServer.aw(DedicatedServer.java:286) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchServerCommand(CraftServer.java:670) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.Bukkit.reload(Bukkit.java:279) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:773) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.enablePlugins(CraftServer.java:375) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugin(CraftServer.java:439) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:250) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at fr.HungerGames.Main.onEnable(Main.java:124) ~[?:?]
    08.08 14:24:02 [ServerINFO at fr.HungerGames.Main.events(Main.java:150) ~[?:?]
    08.08 14:24:02 [ServerINFO at fr.HungerGames.KitSelector.<init>(KitSelector.java:19) ~[?:?]
    08.08 14:24:02 [ServerINFOat fr.HungerGames.Main.<init>(Main.java:35)[/COLOR][/U][/U] ~[?:?]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 14:24:02 [ServerINFO java.lang.IllegalArgumentExceptionPlugin already initialized!
    08.08 14:24:02 [ServerERROR Error occurred while enabling HungerGames v1.0 (Is it up to date?)
    08.08 14:24:02 [ServerINFO Enabled
    08.08 14
    :24:02 [ServerINFO Enabling HungerGames v1.0
    08.08 14
    :24:02 [ServerINFO Permissions listed in as player-commands will be given to all users.
    08.08 14:24:02 [ServerINFO EssentialsUsing config file enhanced permissions.
    08.08 14:24:02 [ServerINFO Enabling Essentials v2.11.1
    08.08 14
    :24:02 [ServerINFO Loading EssentialsChat v2.11.1
    08.08 14
    :24:02 [ServerINFO Loading HungerGames v1.0
    08.08 14
    :24:02 [ServerINFO Loading Essentials v2.11.1
    08.08 14
    :24:02 [ServerINFO Disabling Essentials v2.11.1
    08.08 14
    :24:02 [ServerINFO Disabled
    08.08 14
    :24:02 [ServerINFO Disabling HungerGames v1.0
    08.08 14
    :24:02 [ServerINFO Disabling EssentialsChat v2.11.1

    Main class
    KitSelector

    Please help me to fix those errors...
     
    hintss likes this.
  2. Offline

    1Rogue

    Remove this line:

    Code:java
    1. public Main plugin = this;
     
  3. Offline

    girardcome

    Still error:
    PHP:
    08.08 15:29:59 [ServerINFO CONSOLEReload complete.
    08.08 15:29:59 [ServerINFO Server permissions file permissions.yml is empty, ignoring it
    08.08 15
    :29:59 [ServerINFO Enabling EssentialsChat v2.11.1
    08.08 15
    :29:59 [ServerINFO ... 10 more
    08.08 15
    :29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:771) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:350) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 15:29:59 [ServerINFO at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 15:29:59 [ServerINFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 15:29:59 [ServerINFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
    08.08 15:29:59 [ServerINFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_51]
    08.08 15:29:59 [ServerINFO at fr.HungerGames.Main.<init>(Main.java:35) ~[?:?]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO Caused byjava.lang.IllegalStateExceptionInitial initialization
    08.08 15
    :29:59 [ServerINFO at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:251) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at net.minecraft.server.v1_7_R1.DedicatedServer.aw(DedicatedServer.java:286) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchServerCommand(CraftServer.java:670) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.Bukkit.reload(Bukkit.java:279) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:773) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.enablePlugins(CraftServer.java:375) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugin(CraftServer.java:439) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:250) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at fr.HungerGames.Main.onEnable(Main.java:124) ~[?:?]
    08.08 15:29:59 [ServerINFO at fr.HungerGames.Main.events(Main.java:150) ~[?:?]
    08.08 15:29:59 [ServerINFO at fr.HungerGames.KitSelector.<init>(KitSelector.java:19) ~[?:?]
    08.08 15:29:59 [ServerINFO at fr.HungerGames.Main.<init>(Main.java:35) ~[?:?]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit_dev_3024.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    08.08 15:29:59 [ServerINFO java.lang.IllegalArgumentExceptionPlugin already initialized!
    08.08 15:29:59 [ServerERROR Error occurred while enabling HungerGames v1.0 (Is it up to date?)
    08.08 15:29:59 [ServerINFO Enabled
    08.08 15
    :29:59 [ServerINFO Enabling HungerGames v1.0
    08.08 15
    :29:59 [ServerINFO Permissions listed in as player-commands will be given to all users.
    08.08 15:29:59 [ServerINFO EssentialsUsing config file enhanced permissions.
    08.08 15:29:58 [ServerINFO Enabling Essentials v2.11.1
    08.08 15
    :29:58 [ServerINFO Loading EssentialsChat v2.11.1
    08.08 15
    :29:58 [ServerINFO Loading HungerGames v1.0
    08.08 15
    :29:58 [ServerINFO Loading Essentials v2.11.1
    08.08 15
    :29:58 [ServerINFO Disabling Essentials v2.11.1
    08.08 15
    :29:58 [ServerINFO Disabled
    08.08 15
    :29:58 [ServerINFO Disabling HungerGames v1.0
    08.08 15
    :29:58 [ServerINFO Disabling EssentialsChat v2.11.1
     
  4. Offline

    YoloEnderman

    I found this error to happen when
    Code:java
    1. Main plugin;
    is used twice without changing the field name.
     
  5. Offline

    Rocoty

    Do not manually create a new instance of the main class.

    Also, are you sure you want to be doing this?:
    (byte)8234
    (byte)16389
    (byte)8196
    Those numbers are out of byte bounds.
     
    AdamQpzm and Comphenix like this.
  6. Offline

    girardcome

    Not working..
     
  7. Offline

    Comphenix

    Do not create a new instance of Main() i KitSelector (line 19).

    Instead, pass in the main class constructed by Bukkit. Give KitSelector the following constructor:
    Code:
    // Line 19
    private Main main;
    // etc.
     
    public KitSelector(Main main) {
      this.main = main;
    }
    Then you pass in the current main instance in line 150. You should also save a reference to KitSelector in main, since you have defined a KitSelector field:
    Code:java
    1. public void events() {
    2. PluginManager pm = Bukkit.getServer().getPluginManager();
    3.  
    4. KitSelector = new KitSelector(this);
    5. pm.registerEvents(new PlayerListener(), this);
    6. pm.registerEvents(new KitManager(), this);
    7. pm.registerEvents(KitSelector, this);
    8. pm.registerEvents(new FeastManager(), this);
    9. pm.registerEvents(new Anchor(), this);
    10. }

    You should probably do the same for KitManager in KitSelector as well. There's no need to construct it twice.
     
Thread Status:
Not open for further replies.

Share This Page