Run code immediately after all plugins are loaded?

Discussion in 'Plugin Development' started by Carbunkulous, May 16, 2011.

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

    Carbunkulous

    I'm not sure if there is any event triggered, but does anyone know how to achieve this?
     
  2. Offline

    AOD_Batman

    I don't think this is possible... What are you trying to do?
     
  3. Offline

    Carbunkulous

    Cache all of the available worlds
     
  4. Offline

    Raphfrk

    You could use the scheduler and set it to delay by 2 (or maybe 1) tick.
     
  5. Offline

    AOD_Batman

    You can use the following to read the console and look for "Done":

    Code:
    CraftServer server = (CraftServer)getServer();
    ConsoleReader reader = server.getReader();
    
    either way seems like you're going to have to use the scheduler.

    I am dumb... *facepalm* Yes, there is a way to do it. "scheduleSyncDelayedTask" Below is an example:

    Code:
    public class OnDone extends JavaPlugin {
        private final Logger _mcLogger = Logger.getLogger("minecraft");
        private int onDoneRunnableTaskID;
    
        @Override
        public void onEnable() {
            onDoneRunnableTaskID = getServer().getScheduler().scheduleSyncDelayedTask(this, new OnDoneRunnable(this));
        }
    
        @Override
        public void onDisable() {
    
        }
    
        public void serverIsDone() {
            getServer().getScheduler().cancelTask(onDoneRunnableTaskID);
            _mcLogger.info("Just wanted to let you know... Thats a very nice server you've got there...");
            _mcLogger.info("It'd be a shame if something were to happen to it... D=");
        }
    
        public Logger getMinecraftLogger() {
            return _mcLogger;
        }
    }
    
    Code:
    public class OnDoneRunnable implements Runnable {
        private final OnDone _plugin;
    
        public OnDoneRunnable(OnDone plugin) {
            _plugin = plugin;
        }
    
        @Override
        public void run() {
            _plugin.serverIsDone();
        }
    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  6. Offline

    Carbunkulous

Thread Status:
Not open for further replies.

Share This Page