Plugin already initialized error

Discussion in 'Plugin Development' started by CodePlaysMC, May 4, 2014.

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

    CodePlaysMC

    So I've been developing a GUI plugin plugin, and I keep getting an error saying that the plugin is already initialized.

    Here's the error:
    Code:
    [21:08:39] [Server thread/ERROR]: Could not load 'plugins\TeamCubedGUI.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:357) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:799) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.Bukkit.reload(Bukkit.java:288) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:703) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchServerCommand(CraftServer.java:690) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.aB(DedicatedServer.java:296) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:261) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at me.CodePlaysMC.Main.<init>(Main.java:13) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_51]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_51]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_51]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        ... 14 more
    Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at me.CodePlaysMC.Main.<init>(Main.java:13) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_51]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_51]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_51]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_51]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        ... 14 more
    This is my Main (and only) class:
    Code:java
    1. package me.CodePlaysMC;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Material;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.block.Action;
    11. import org.bukkit.event.inventory.InventoryClickEvent;
    12. import org.bukkit.event.player.PlayerInteractEvent;
    13. import org.bukkit.event.player.PlayerJoinEvent;
    14. import org.bukkit.inventory.Inventory;
    15. import org.bukkit.inventory.ItemStack;
    16. import org.bukkit.inventory.meta.ItemMeta;
    17. import org.bukkit.plugin.java.JavaPlugin;
    18.  
    19. public class Main extends JavaPlugin implements Listener {
    20.  
    21. public void onEnable() {
    22. getServer().getPluginManager().registerEvents(this, this);
    23. }
    24.  
    25. private void teleportInWorld(Player player, int x, int y, int z) {
    26. player.teleport(new Location(player.getWorld(), x, y, z));
    27. }
    28.  
    29. private void openGUI(Player player) {
    30. Inventory inv = Bukkit.createInventory(null, 9, ChatColor.DARK_GREEN
    31. + "Server Selector");
    32.  
    33. ItemStack factions = new ItemStack(Material.IRON_SWORD);
    34. ItemMeta factionsMeta = factions.getItemMeta();
    35. ItemStack survival = new ItemStack(Material.WORKBENCH);
    36. ItemMeta survivalMeta = factions.getItemMeta();
    37.  
    38. survivalMeta.setDisplayName(ChatColor.GREEN + "Survival");
    39. survival.setItemMeta(survivalMeta);
    40.  
    41. factionsMeta.setDisplayName(ChatColor.GREEN + "Factions");
    42. factions.setItemMeta(factionsMeta);
    43.  
    44. inv.setItem(3, factions);
    45. inv.setItem(5, survival);
    46.  
    47. player.openInventory(inv);
    48. }
    49.  
    50. @EventHandler
    51. public void onInventoryClick(InventoryClickEvent event) {
    52. if (!ChatColor.stripColor(event.getInventory().getName())
    53. .equalsIgnoreCase("Server Selector"))
    54. return;
    55.  
    56. Player player = (Player) event.getWhoClicked();
    57. event.setCancelled(true);
    58.  
    59. if (event.getCurrentItem() == null
    60. || event.getCurrentItem().getType() == Material.AIR
    61. || !event.getCurrentItem().hasItemMeta()) {
    62. player.closeInventory();
    63. return;
    64. }
    65.  
    66. switch (event.getCurrentItem().getType()) {
    67. case IRON_SWORD:
    68. teleportInWorld(player, 0, 50, 0);
    69. player.closeInventory();
    70. player.sendMessage(ChatColor.GREEN + "Minigame"
    71. + ChatColor.DARK_GRAY + " >> " + ChatColor.GRAY
    72. + "You have been teleported to " + ChatColor.GREEN
    73. + "Factions" + ChatColor.GRAY + ".");
    74. break;
    75. case WORKBENCH:
    76. teleportInWorld(player, 70, 300, 20);
    77. player.closeInventory();
    78. player.sendMessage(ChatColor.GREEN + "Minigame"
    79. + ChatColor.DARK_GRAY + " >> " + ChatColor.GRAY
    80. + "You have been teleported to " + ChatColor.GREEN
    81. + "Survival" + ChatColor.GRAY + ".");
    82. break;
    83. default:
    84. player.closeInventory();
    85. break;
    86. }
    87. }
    88.  
    89. @EventHandler
    90. public void onPlayerJoinEvent(PlayerJoinEvent event) {
    91. event.getPlayer().getInventory().addItem(new ItemStack(Material.WATCH));
    92. }
    93.  
    94. @EventHandler
    95. public void onPlayerInteract(PlayerInteractEvent event) {
    96. Action a = event.getAction();
    97. ItemStack is = event.getItem();
    98.  
    99. if (a == Action.PHYSICAL || is == null || is.getType() == Material.AIR)
    100. return;
    101.  
    102. if (is.getType() == Material.WATCH)
    103. openGUI(event.getPlayer());
    104. }
    105. }


    Please help!
     
  2. Offline

    SaxSalute

    This is probably off point, but do you have 2 instances of the same plugin in your plugins folder?
     
  3. Offline

    paully104

    If your using eclipse and exporting you can sometimes export your project into another jar by accident. Check all your plugins and see if another plugin is the exact same size. You might of overwritten one without realizing it.
     
  4. Offline

    SaxSalute

    You don't want both. This would only happen if they are duplicates. You only need the newest version. Is there some reason you want both at the same time?
     
  5. Offline

    CodePlaysMC

    Yes, but they aren't duplicates, even though they are the same size. One of for main server stuff (Player join message, commands, etc.) one is for a server GUI
     
  6. Offline

    Zethariel

    If they have the same name, this error will be thrown. The loader doesn't care about the guts, it needs to run and register the plugin according to it's name. Rename one or the other.
     
  7. Offline

    CodePlaysMC

    They don't have the same name, but they do contain some of the same characters. One is named TeamCubed and one is named TeamCubedGUI.
     
  8. Offline

    SaxSalute

    Did you just copy paste the plugin.yml? If so Bukkit will see them as the same plugin.
     
  9. Offline

    CodePlaysMC

    I copied and pasted plugin.yml, but I changed the main, and the plugin name, and the commands. Hm... I guess I'll just have to use only 1 of the plugins...

    Okay, so I've been looking, and I've been editing, and I've got a new error:

    Code:
    [18:08:47] [Server thread/ERROR]: Error occurred while enabling TeamCubed v1.0.0 (Is it up to date?)
    java.lang.NullPointerException
        at me.CodePlaysMC.TeamCubed.Main.onEnable(Main.java:19) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:250) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:448) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:382) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:801) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.Bukkit.reload(Bukkit.java:288) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:703) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchServerCommand(CraftServer.java:690) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.aB(DedicatedServer.java:296) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:261) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
        at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-59-g6efeddf-b3074jnks]
    This is for the other plugin. (TeamCubed.jar) (Not TeamCubedGUI.jar)
    If you need me to lists any classes, tell me because there are various classes...

    Heres the main anyway:
    Code:java
    1. import org.bukkit.plugin.java.JavaPlugin;
    2.  
    3. public class Main extends JavaPlugin {
    4.  
    5. @Override
    6. public void onEnable() {
    7. new PlayerJoin(this);
    8. new PlayerQuit(this);
    9. getLogger().info("TeamCubed has been enabled!");
    10. getCommand("hp").setExecutor(new PlayerHealing());
    11. getCommand("gmc").setExecutor(new PlayerGamemode());
    12. getCommand("gms").setExecutor(new PlayerGamemode());
    13. getCommand("gma").setExecutor(new PlayerGamemode());
    14. getCommand("ban").setExecutor(new PlayerBan());
    15. getCommand("unban").setExecutor(new PlayerUnban());
    16. getCommand("kick").setExecutor(new PlayerKick());
    17. getCommand("feed").setExecutor(new PlayerHealing());
    18. }
    19.  
    20. @Override
    21. public void onDisable() {
    22. getLogger().info("TeamCubed has been disabled!");
    23.  
    24. }
    25.  
    26. }


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

    GyllieGyllie

    i had the same problem, can you paste in the code of one of your command classes so i can check if it is the same thing
     
  11. Offline

    CodePlaysMC

    Sorry for not making this post solved, but my problem has been solved quite a while ago. Sorry. XD
     
Thread Status:
Not open for further replies.

Share This Page