restart dont work.... Why? (custom command)

Discussion in 'Bukkit Help' started by michidk, May 24, 2012.

Thread Status:
Not open for further replies.
  1. Why dont this work?
    In eclipse there aren't any warns and errors.
    If i run /restart (ingame, with client, not console),
    the serer dont react, and in the console arent errors.
    Sry for my bad English.... I'm German [sheep]

        public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args){
            Player p = (Player)sender;
                if ((cmd.getName().equalsIgnoreCase("restart"))&&(p.hasPermission("test.restart"))){
                    this.getServer().broadcastMessage(ChatColor.DARK_AQUA + "+++++++" + ChatColor.DARK_RED + "restart in 30 seconds" + ChatColor.DARK_AQUA + "+++++++");
                    int timer = 60;
                    while (timer >= 0) {
                        try {
                        } catch (InterruptedException e) {
                    this.getServer().broadcastMessage(ChatColor.DARK_AQUA + "+++++++" + ChatColor.DARK_RED + "restart in 10 seconds" + ChatColor.DARK_AQUA + "+++++++");
                    int timer2 = 60;
                    while (timer2 >= 0) {
                        try {
                        } catch (InterruptedException e) {
                    this.getServer().broadcastMessage(ChatColor.DARK_AQUA + "+++++++" + ChatColor.DARK_RED + "RESTART!" + ChatColor.DARK_AQUA + "+++++++");
                    this.getServer().broadcastMessage(ChatColor.DARK_AQUA + "Worlds save!");
                    for (Player p2 : Bukkit.getServer().getOnlinePlayers()) {
                            p2.kickPlayer(ChatColor.DARK_RED + "Come back in 3 Minutes");
                    this.getServer().broadcastMessage(ChatColor.DARK_AQUA + "Server is stopping!");
            return true; 
  2. Offline


    Make sure you telling bukkit to register the restart command to the class that you have your onCommand method in and that you have it in your plugin.yml
  3. Thanks for fast answer..
    want you mean with register???

    thats my plugin.yml:
    name: ZeroTools
    version: 1.0
    description: This Plugin has some nice Tools.
    main: me.michidk.test.test
    author: michidk
        description: restarts the Server
        permission: test.restart
    the command works...
    it prints ingame: "restart in 30 sekonds"
    but then the server is freezed
  4. Offline


    You're making the whole server sleep for 20 seconds, that's not good :O
    Use bukkits scheduler.
  5. Lolmewn
    Oh... but i have the same on a reload command, and only the plugins sleep...
    But how i use the bukkit schduler?
  6. Offline


    Basically it's getServer().getScheduler(), you can look it up too on the wiki.
  7. Offline


    Instead of writing a horribly coded plugin, I suggest you use a simple batch script on OS level to perform tasks such as this. It's easier, more reliable, and doesn't unnecessarily add to bukkit's plugin list. Needless to say, a script on OS level would also work should Minecraft (or java) crash or bug out.
  8. but i cant run bash scripts on the sevrer...

    have anyone else a idea?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 26, 2016
  9. Offline


    What do you mean, you can't?

    If your (crude) attempt at a plugin would have worked, how would the server restart then? By magic? Or are you using some wrapper? If the latter, it should have a restart option anyway.
  10. ok. if i talk to my hoster, i can run it...
    but how i write into the consol?

    if i stop the server, it restarts automatic.
Thread Status:
Not open for further replies.

Share This Page