McMyAdmin - send restart command through plugin?

Discussion in 'Plugin Development' started by Kepler_, Jun 26, 2013.

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

    Kepler_

    I'm using this line of code to try to restart the server, but it's not working:
    Code:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender() , "restart");
    Is there a permission I need to set up in McMyAdmin to allow the plugin to run the command, or something else? Thanks!
     
  2. Offline

    MCForger

    Kepler_
    There is not any permission node needed for running a command through ConsoleSender as its treated an OP.
    May we see some more code as that line of code looks fine to me.
     
  3. Offline

    Kepler_

    Code:
        public void run(Plugin plugin){
            long delay = 20*15;
            Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                public void run() {
                    if ((double)Runtime.getRuntime().freeMemory() / (double)Runtime.getRuntime().totalMemory() < .05){
                        for (Player p : Bukkit.getOnlinePlayers()){
                            p.kickPlayer("Restarting server because of high memory usage");
                        }
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender() , "restart");
                    }
                }
            }, delay, delay);
        }
    I run this method in the server's onEnable method.

    -edit-
    you know what, it turns out i forgot to run this method in the onEnable event... that tends to make code not work.
     
  4. Offline

    MCForger

    Kepler_
    Oh lol.
    Well happens to all of us once in a while!
     
  5. Offline

    PhonicUK

    If you want to use dispatch command to invoke MCMAs commands, you need to do it via mcmas "pushcommand" command.

    So to invoke MCMAs restart, you'd do "pushcommand restart"
     
Thread Status:
Not open for further replies.

Share This Page