I'm making a plugin and got an error executing a cmd.

Discussion in 'Plugin Development' started by Sarcry, Aug 14, 2016.

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

    Sarcry

    Code:
    [15:05:01] [Server thread/INFO]: Sarcry issued server command: /staffon
    [15:05:01] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'staffon' in plugin StaffPl v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:139) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.dispatchCommand(CraftServer.java:625) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PlayerConnection.handleCommand(PlayerConnection.java:1299) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:1159) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:37) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(SourceFile:9) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_101]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_101]
        at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:688) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:361) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:643) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:547) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at me.certe.Certe.<init>(Certe.java:11) ~[?:?]
        at me.certe.Mod.<init>(Mod.java:20) ~[?:?]
        at me.certe.Certe.onCommand(Certe.java:27) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        ... 15 more
    Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at me.certe.Certe.<init>(Certe.java:11) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_101]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_101]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_101]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_101]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:294) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.<init>(CraftServer.java:256) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PlayerList.<init>(PlayerList.java:70) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.DedicatedPlayerList.<init>(SourceFile:14) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:184) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:514) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        ... 1 more
     
    Last edited: Aug 14, 2016
  2. @Sarcry
    You are somehow creating a new instance of your main class, I can't tell you much more without seeing your code.
     
  3. Offline

    Sarcry

    http://pastebin.com/jAYWVXhx

    if you need the Mod class code ask me

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  4. @Sarcry
    Can you show me the other two classes?
     
  5. Offline

    Sarcry

  6. Offline

    timtower Administrator Administrator Moderator

    @Sarcry Why are your classes extending your main class?
     
  7. Offline

    Sarcry

    Realized that was the little problem but now other one surged. I execute the command(in this case /staffon or /staffoff) and apears for first time on the chat and then I execute the cmd again and gives me the stuff twice and they dont have their names I set.
     
  8. @Sarcry
    As @timtower pointed out, your problem is that your two classes extend your main class, and when you create instances of said classes, they count as new instances of the main class, which Bukkit does not allow. Just stop extending your main class and you should be fine.
     
    MCMastery likes this.
Thread Status:
Not open for further replies.

Share This Page