Solved craftbukkit beta builds

Discussion in 'Plugin Development' started by Freelix2000, Mar 9, 2014.

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

    Freelix2000

    Ever since the first craftbukkit beta build, every one of my plugins has blown up in a huge fiery explosion. I have already posted a thread about one of the problems, but I tagged it as Solved when I came to a solution that was acceptable only for my current projects. (That solution was moving all events to the main class) Here are the 2 main issues I am having:
    - Events only seem to work in the main class. My attempts to register events in other classes result in an IllegalArgumentException ("Plugin is already initialized!") and the events do not work
    - Using Bukkit's API for files do not work. No errors, it just doesn't create the config file, and if I create it without Bukkit API, it still doesn't write to it or read from it
    My code seemed to work just fine before the beta craftbukkits, and I have even looked into the code of other plugins and found that they are using the exact same code. I have tried changing the version of the API I use in the plugins, but if the server is running a beta craftbukkit, they don't work.
    Here's my code for registering events:
    Code:java
    1. Bukkit.registerEvents(new CLASS_NAME(), this);

    I put a line of that code in the onEnable() method for each of my classes. Here's my code for generating the config file:
    Code:java
    1. File file = new File(getDataFolder() + File.separator + "config.yml");
    2. if(!file.exists){
    3. getConfig().addDefault("something", "something");
    4. }

    I also tried loading the config as a YAMLConfiguration and using it defined as a custom YAMLConfiguration, but that didn't work either. If anyone with working plugins in the craftbukkit beta builds is willing to help, I will also provide one of my plugins decompiled so you can look over it. I really need help on this, because until I figure this out, my plugins are limited to plugins small enough to have all events in the main class, and I can't use files. =(

    EDIT: I fixed the config issue, I found that the reason nothing was working is because for the first time ever, I forgot to copy defaults and save... I usually never make such obvious mistakes, I feel like such an idiot. =P =D
     
  2. Offline

    XvBaseballkidvX

    I use this for registering events:
    Code:java
    1. PluginManager pm = this.getServer().getPluginManager();
    2. pm.registerEvents(new Class_Name(), this);

    Works just fine for me. As for the config problem, I just use Bukkit's default configuration file so I can't help you there.
    :(
     
  3. Offline

    Freelix2000

    That is still getting the same plugin manager, and I have already tried that. I'm also using the default Bukkit config file, and its not working either.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Freelix2000 There was a change in how plugins are loading. It now enforces that you only have one JavaPlugin class, and forbids you from instantiating more.
     
    Garris0n likes this.
  5. Offline

    Freelix2000

    I do only have one class that extends JavaPlugin. But, sometimes I do extend my main class, would that cause the plugin to fail to enable?
     
  6. Offline

    xTrollxDudex

  7. Offline

    Garris0n

    http://forums.bukkit.org/threads/updating-plugin-to-1-7.240140/#post-2305073

    Anyway, extending the Main class which is extending JavaPlugin is essentially extending JavaPlugin. You can't do that more than once or you end up instantiating your plugin again. Bukkit won't let you instantiate the same plugin more than once. Don't extend your main class (in fact, make it final just to remind you).
     
  8. Offline

    Freelix2000

    Garris0n
    Well, it seemed to work before the beta builds. I'll test it later to see if that is what is causing the problems. Thank you for the help, and although I don't have time to test now, I'm pretty sure this is the solution I have been looking for. Thanks again. =)
     
  9. Offline

    Garris0n

    It worked before the beta builds because Bukkit did let you instantiate the same plugin more than once. Either way, you shouldn't have been doing it then either, you just can't now.
     
  10. Offline

    Freelix2000

    Yeah... That was just one of the things I did as a noob when I started, it allowed easier access to methods in the main class, and it seemed to work so I just made a habit of doing it. Anyways, I tested it now, and it worked! I knew it would be a really simple fix, I was just waiting for someone smart enough to help me figure out what that fix was. This really helped a lot, because my own server relies on some very important custom plugins that didn't work. Thank you so much!
     
Thread Status:
Not open for further replies.

Share This Page