Wait on stop

Discussion in 'Spigot Plugin Development' started by ericevo, Aug 13, 2018.

  1. Hey all! today I want to do a shutdown-cooldown on my plugin.

    When the server do /stop, execute a command, wait 3 seconds and then shutdown it...

    Code (Text):
     public void onDisable() {
            plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "eb anunciarban §e⚠ §cServer  §b§n"+servername.toUpperCase()+"§f ha §4§lHAS SHUTDOWN"

    //wait 3 seconds...

    // continue shutdown
        }
     
    Thanks all :)
     
  2. /stop is a vanilla server command. It functions on its own and that won't change because of a plugin; maybe a modified server jar.
    Alternatively, you should setup a plugin command that simply starts a timer and then shuts the server down when that timer is finished. The best thing to use would be a BukkitRunnable and then stop the server, probably with something like #getServer()#shutdown()