Help with: My server will not recognize my plugin.

Discussion in 'Plugin Development' started by Robotbuilder, Apr 9, 2014.

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

    Robotbuilder

    I had my plugin working for a while and now my server will not recognize it! When I type /plugins it
    does not appear in the list of plugins. How do I fix this?

    ...But on my test server it works.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    Pivotbanq

    make sure your plugin.yml is configured correctly. Post a pastebin link of this if you can :)
     
    Robotbuilder likes this.
  3. Offline

    ahuby09

    mabey you have an outdated version , or the methods used in it are outdated
     
  4. Offline

    Robotbuilder

    ahuby09 But its the same version.
     
  5. Offline

    amhokies

    Robotbuilder Check to make sure there are no errors in the server startup.
     
    Robotbuilder and ahuby09 like this.
  6. Offline

    Tehmaker

    I am going to bet you that if you look in the console, you are going to find an error during startup that relates to your plugin. Please post here and we can help you out.
    Robotbuilder
     
    Robotbuilder likes this.
  7. Offline

    Robotbuilder

    Ok. Thanks for all the responses! I will post the contents of the plugin.yml file for it when I can access to my PC.

    Here is my plugin.yml:

    Code:
    name: SimpleClear
    author: Robotbuilder
    version: 1.0.0
    description: This is a custom plugin for HyperBlock.
    main: net.redstonecity.robotbuilder.Main
    commands:
      csc:
        description: Custom Clear inventory plugin.
      
    amhokies Tehmaker

    Here is my error on start up:

    [08:11:26 ERROR]: Could not load 'plugins\SimpleClear.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Pl
    ugin already initialized!

    I hope you guys can understand the error because I cannot :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  8. Robotbuilder The plugin is loaded more than once. If you don't have any of the same plugin, please post your full code.
     
  9. Offline

    mazentheamazin

    Robotbuilder AdamQpzm
    Or another one, he is creating a new instance of the main class as such:
    Code:java
    1. Main main = new Main();
     
  10. Offline

    Robotbuilder

    AdamQpzm Ok, So you think I put the two of the same plugin in the plugins folder?

    I will post the code for my main class as well as the complete server startup as soon as I can.
     
  11. Offline

    Robotbuilder

    I do not have the two of the same plugin in the plugins folder at once.

    So it goes like this: SimpleClear\src\my_package\main.java

    Here is all my code for my "main" class:

    Code:java
    1. package net.redstonecity.robotbuilder;
    2.  
    3. import org.bukkit.command.Command;
    4. import org.bukkit.command.CommandSender;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7. import org.bukkit.potion.PotionEffect;
    8.  
    9.  
    10.  
    11. /*
    12.  
    13. This plugin is a custom plugin for the HyperBlock server.
    14.  
    15.  
    16.  
    17. Author: robotbuilder with help from lots of others on the bukkit forums.
    18.  
    19. */
    20.  
    21.  
    22.  
    23. public class Main extends JavaPlugin {
    24.  
    25.  
    26.  
    27. public void onEnable() {
    28.  
    29. getLogger().info("Simple Clear Enabled!");
    30.  
    31.  
    32.  
    33. }
    34.  
    35.  
    36.  
    37. public void onDisable() {
    38.  
    39. getLogger().info("Simple Clear Enabled");
    40.  
    41. }
    42.  
    43.  
    44. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    45.  
    46. if (cmd.getName().equalsIgnoreCase("hub") || cmd.getName().equalsIgnoreCase("spawn") ) {
    47.  
    48. Player player = (Player) sender;
    49.  
    50.  
    51. org.bukkit.inventory.PlayerInventory inv = player.getInventory();
    52.  
    53. inv.setArmorContents(null); //remove the armour in the armour slots
    54.  
    55. for (int i = 1; i != 8; i++) //clear slots 2 - 8 on the hotbar
    56. inv.setItem(i, null);
    57.  
    58. for(PotionEffect pe : player.getActivePotionEffects()) { //remove all potion effects
    59. player.removePotionEffect(pe.getType());
    60.  
    61. }
    62.  
    63. for (int i = 9; i < inv.getSize(); i++) //clear everything else that is not on the hotbar
    64. inv.setItem(i, null);
    65.  
    66. }
    67.  
    68. return true;
    69. }
    70.  
    71.  
    72. }
    73.  
     

  12. Potential stupid question (I'm no Java god.) do you have any other plugins you've made using that package with Main as the primary class? If so there's your problem I believe.
     
    Robotbuilder likes this.
  13. Offline

    moose517

    that is all the code nothing ommitted?
     
  14. Offline

    Konkz

    Can you post the full error?
     
    Robotbuilder likes this.
  15. Offline

    Robotbuilder

    moose517 That is all the code for my main class.

    Konkz Here is the full error:
    [10:27:23] [Server thread/ERROR]: Could not load 'plugins\SimpleClear.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:137) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:313) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:236) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:350) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:312) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
    at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.redstonecity.robotbuilder.Main.<init>(Main.java:23) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_45]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_45]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_45]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_45]
    at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_45]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ... 9 more
    Caused by: java.lang.IllegalStateException: Initial initialization
    at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at net.redstonecity.robotbuilder.Main.<init>(Main.java:23) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_45]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_45]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_45]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_45]
    at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_45]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    ... 9 more
    [10:27:23] [Thread-8/INFO]: ----- Bukkit Auto Updater -----
    [10:27:23] [Thread-8/INFO]: It appears that you're running a Beta Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [10:27:23] [Thread-8/INFO]: If you would like to be kept informed about new Beta Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'beta'.
    [10:27:23] [Thread-8/INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [10:27:23] [Thread-8/INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
     
  16. Robotbuilder Can we see the code for your other classes please?
     
  17. Offline

    Robotbuilder

    AdamQpzm That is the code for my only class: main

    charries96 Its not a stupid question. ;) I have been using that main class just for the plugin 'SimpleClear', not for any other plugins.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  18. Works for me. Make sure you don't have the same plugin, just renamed. Also make sure it looks like this :

    net.redstonecity.robotbuilder.Main
     
  19. Offline

    Robotbuilder

  20. Offline

    xTigerRebornx

    Robotbuilder The error is caused because you are trying to create a new instance when your plugin is already initialized (You are calling Main instance = new Main() somewhere), you are not able to create new instances this way, since Bukkit tries to keep only one instance of your plugin.
     
  21. Offline

    Robotbuilder

    Ravada ...Ok so you downloaded it and tested it out? I named it "SimpleClear2", that might fix something.

    xTigerRebornx... so how do I fix it? Sorry I am a newbie

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  22. Offline

    xTigerRebornx

    Robotbuilder Question, do you have any other plugins made by you when you ran your plugin? If so, then the error is caused because 2 of your plugins both have their Main class located in the same place (net.redstonecity.robotbuilder.Main)
    You need to give each plugin a unique location for their main classes (I.E. net.redstonecity.robotbuilder.plugin1.Main and net.redstonecity.robotbuilder.plugin2.Main) otherwise it will throw out these errors
     
  23. Offline

    Robotbuilder

  24. Offline

    xTigerRebornx

    Robotbuilder Read through the rest of the post. My guess is that the plugins share the same location for their main class (net.redstonecity.robotbuilder.Main) and Bukkit won't allow it, since it thinks its the same plugin.
     
  25. Offline

    Robotbuilder

    xTigerRebornx I tried naming the package: net.redstonecity.robotbuilder.SimpleClear, but it still will not register. :confused:
     
  26. Offline

    xTigerRebornx

    Robotbuilder Show me what the error is when you change the package and the plugin.yml
     
    Robotbuilder likes this.
  27. Offline

    Robotbuilder

    Yes it actually worked! I just forgot to change the package in plugin.yml!

    ...but my command does not work :C. I typed in the 'hub' command and it says it doesn't recognize the command.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  28. @Roboticbuilder this is what I was trying to get at :p
     
    Robotbuilder likes this.
  29. is that defined in your plugin.yml? If not then there's your problem, if it is then I have absolutely no clue I'm afraid!
     
    Robotbuilder likes this.
  30. Offline

    Robotbuilder

    charries96 Yes I probably did not define it, but I cannot check right. Why did I forget to do that? Forgetful me.

    One question... Can I define multiple commands with the same onCommand() method in the same class.

    Like this:

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (cmd.getName().equalsIgnoreCase("hub") ) {

    //Do something when the command 'hub' is run.

    }

    if (cmd.getName.equalsIgnoreCase("cci") {

    //Do something when the command 'cci' is run.

    {

    I would like to thank everyone who helped me with this! I will give everyone who helped likes! Thanks for helping!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page