Run code after Bukkit says 'done'

Discussion in 'Plugin Development' started by Minnymin3, May 25, 2013.

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

    Minnymin3

    Is there some sort of event or something that triggers when Bukkit finishes initializing? I want to cycle through stuff that could have been added by addons for one of my plugins after I know that all the plugins would have been initialized.

    (sorry if this makes no sense its 1:30 am for me)
     
  2. Offline

    caseif

    Not sure if that's possible, but you could potentially define loadafter in the plugin.yml so your plugin loads after the ones you want to get hanges from.

    As for your 1:30AM comment, yeah, same for me. I think I'm just gonna head to bed now...
     
  3. Offline

    Minnymin3

    I actually need to do the complete opposite :( I need the plugin to load before all other plugins so that addons can add to a list defined in my plugin... I thought of making a schedular but thats very, very, very, very hacky and finicky.
    Think its possible to make multiple plugins run from one jar? :p
     
  4. Offline

    Wingzzz

    Basically go ahead and mess with these:
    Code:java
    1. package com.github.pixelwingz;
    2.  
    3. import org.bukkit.plugin.java.JavaPlugin;
    4.  
    5. public class Core extends JavaPlugin {
    6.  
    7. @Override
    8. public void onEnable() {
    9. if(this.isInitialized()) {
    10. // do something
    11. }
    12.  
    13. if(this.isEnabled()) {
    14. // do something
    15. }
    16. }
    17.  
    18. }

    These are useful in your situation of wanting to only do something if the plugin is enabled/initialized and you could possibly have one plugin cycle through and wait till all other plugins are enabled/initialized till it does something.

    EDIT: I read that wrong... You can basically define in your plugin.yml when to load either on startup or after the world has been loaded...
    Code:yml
    1. load: STARTUP
    2. # or
    3. load: POSTWORLD
    4.  
     
  5. Offline

    Minnymin3

    OHHHH GOT AN IDEA
    I could make a task that repeats itself every second and checks to see if all the plugins are enabled (somehow I think its possible) and if not then repeat the task and if not then repeat the task
     
  6. Offline

    Wingzzz

    Pretty much have 1 plugin Bukkit.getPluginManager().getPlugin("plugin-name"); and just loop through all plugins and check them and once they're all done your pl can do whatever it is needed.
     
  7. Offline

    Minnymin3

    YAY thatl work il do that tomorrow cuz im tired and gonna get some sleep zzzzz
     
  8. Offline

    Wingzzz

    Minnymin3
    Nothing like some 1:47am code excitement to spark the dreams :)
     
    AngryNerd and Minnymin3 like this.
  9. Offline

    blablubbabc

    You could also try to run a delayed scheduled sync task with 1 tick delay. Bukkkit will run it right after finishing all the plugin loading stuff.. I use it to display messages after all other plugin loading messages and it works pretty well :)
     
  10. Offline

    Minnymin3

    OO thats awesome! That will help SO MUCH! thanks
     
Thread Status:
Not open for further replies.

Share This Page