Event after server-start?

Discussion in 'Plugin Development' started by pd9937, Jul 4, 2012.

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


    Hello everyone,
    My problem is the following: I am coding a plugin which needs to call the getServer().getWorld(String) method when it starts up. If I call this method at the OnEnable() function, I get a null pointer exception, because the server has not started up completely.

    So: Is there any event or function to implement that occurs right after the server has started up?

    Thanks in advice
  2. Offline


    WorldLoadEvent, this event is called when the world is loaded[1]. If that does not work for you, you can try WorldInitEvent but that will likely throw null pointers since its called when a world is initializing[2], not when its loaded.
    ferrybig likes this.
  3. Offline


    Maybe WorldInitEvent or WorldLoadEvent can do what you need.
  4. Offline


    Oh thank you both for this quick reply!
    I completely missed the WorldEvent package when I looked for a solution!
  5. Offline


    Glad to help
  6. Offline


    Hm really strange...

    The following code seems to produce no output at all (while mContext points to the JavaPlugin class):
    ... same with WorldInitEvent, all other EventHandlers work perfectly.
  7. Offline


    In the plugin.yml there is an option called "load" that you can add. By default it's set to "STARTUP" but you can set it to "POSTWORLD" so your plugin gets loaded after the world. Try doing that and then try the method in your onEnable
    Milkywayz likes this.
  8. you registered the methode?
  9. Offline


    Well, I did
    getServer().getPluginManager().RegisterEvents(mEventListener, this); at onEnable()

    Btw. how is it possible to let bukkit load more than 1 world into the world list? I only manage to get 1 world loaded... :(
  10. you mean the WorldCreator.create() methode?
Thread Status:
Not open for further replies.

Share This Page