Solved "Plugin already initialized!" (Bukkit Dev Build bug?)

Discussion in 'Plugin Development' started by thepaperboy99, Jan 31, 2014.

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

    thepaperboy99

    Hello Bukkit, today after trying to update my plugin to the latest dev build, I have ran into an error which I do not know how to solve. Every other plugin works but mine, which I don’t get because I didn’t even change any code. The plugin only works on the beta build, but not the dev builds, would this be a bukkit bug? Any help is appreciated.


    Error:
    http://pastebin.com/TRttA9Tq

    Line 7:
    public class KitPVP extends JavaPlugin {
    Line 9:
    public static KitPVP instance = new KitPVP();

    Thanks!
     
  2. Offline

    The_Doctor_123

    There can be no more than one instance of JavaPlugin per plugin.
     
    L33m4n123 likes this.
  3. Offline

    Jaaakee224

  4. Offline

    thepaperboy99

    I know that, only the main class extends JavaPlugin. It all worked fine until I updated.
     
  5. Offline

    Cirno

    Never call new <javaPluginClass>();. Instead, in onEnable(), add "instance = this".
     
  6. Offline

    clienthax

    extends JavaPlugin implements Listener {

    public static someinstance instance = null;

    public void onEnable()
    {
    getServer().getPluginManager().registerEvents(this, this);
    instance = this;
     
  7. Offline

    The_Doctor_123

    You did not read what I said. I said "instance" not "class."
     
  8. Offline

    thepaperboy99

    This is my main class:

    Code:java
    1. package me.thepaperboy99.kitpvp;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class KitPVP extends JavaPlugin {
    8.  
    9. public static KitPVP instance = new KitPVP();
    10.  
    11. public static KitPVP getInstance(){
    12. return instance;
    13. }
    14.  
    15. public void onEnable(){
    16. setInstance();
    17. getServer().getPluginManager().registerEvents(new KitPVPListener(this), this);
    18. getCommand("killstats").setExecutor(new KitPVPCommands(this));
    19. getConfig().options().copyDefaults(true);
    20. saveConfig();
    21.  
    22. for(Player player : Bukkit.getOnlinePlayers()){
    23. Manager.getInstance().setup(player);
    24. Scoreboards.getInstance().update(player);
    25. }
    26.  
    27. Manager.getInstance().updateTop5();
    28.  
    29.  
    30. }
    31.  
    32. public void setInstance(){
    33. instance = this;
    34. Manager.getInstance().setInstance(this);
    35. Scoreboards.getInstance().setInstance(this);
    36. }
    37.  
    38.  
    39. public void deubg(String message){
    40. if(getConfig().getBoolean("debug")){
    41. System.out.println("[KitPvP Debug] " + message);
    42. }else{
    43. return;
    44. }
    45. }
     
  9. Offline

    Cirno

    ... Okay then... Here you go.
    Code:java
    1. package me.thepaperboy99.kitpvp;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class KitPVP extends JavaPlugin {
    8.  
    9. public static KitPVP instance;
    10.  
    11. public static KitPVP getInstance(){
    12. return instance;
    13. }
    14.  
    15. public void onEnable(){
    16. setInstance();
    17. getServer().getPluginManager().registerEvents(new KitPVPListener(this), this);
    18. getCommand("killstats").setExecutor(new KitPVPCommands(this));
    19. getConfig().options().copyDefaults(true);
    20. saveConfig();
    21.  
    22. for(Player player : Bukkit.getOnlinePlayers()){
    23. Manager.getInstance().setup(player);
    24. Scoreboards.getInstance().update(player);
    25. }
    26.  
    27. Manager.getInstance().updateTop5();
    28.  
    29.  
    30. }
    31.  
    32. public void setInstance(){
    33. instance = this;
    34. Manager.getInstance().setInstance(this);
    35. Scoreboards.getInstance().setInstance(this);
    36. }
    37.  
    38.  
    39. public void deubg(String message){
    40. if(getConfig().getBoolean("debug")){
    41. System.out.println("[KitPvP Debug] " + message);
    42. }else{
    43. return;
    44. }
    45. }
     
  10. Offline

    thepaperboy99

    Thanks! The way I did it worked up until this build, but thanks anyways. :)
     
  11. Offline

    The_Doctor_123

    It shouldn't have..
     
Thread Status:
Not open for further replies.

Share This Page