Filled Auto Restart

Discussion in 'Plugin Requests' started by tcwolf12, May 16, 2016.

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

    tcwolf12

    Name:
    Auto-Restart
    What I'd Like:
    A very simple plugin that runs the command /stop at a configurable interval (say every 6 hours).
    The ability to configure it in game through commands.
    Ideas For Commands:
    /autore now (restart now)
    /autore in <time in m,s, or h> restarts in interval
    /autore interval <sets automatic interval in hours>
    /autore message <message to display with the count down till the server restarts>
    /autore prefix <prefix of the message>
    /autore warntime <seconds before the restart that the server will display the restart message in chat and start counting down>
    Permissions:
    Autore.Admin Allows the player to use autore commands.
    When I'd like it by:
    Hopefully two days from now.
    You do not have to worry about the restarting portion, that is handled by my server's start.command. I repeat this plugin only has to STOP the server, the script will automatically reboot it after that point in time!
    Also if there is a better way to do this please don't hesitate to let me know in the replies, thanks!
     
    Last edited: May 19, 2016
  2. Offline

    WolfMage1

    https://www.spigotmc.org/resources/autorestart.2538/
     
  3. Offline

    tcwolf12

    That plugin doesn't do what I need it to do I've already looked at it and it requires me to make may start up script do the restart and I'd like to have a plugin controlling it that way it's more flexible, also it isn't configureable in game.
    Edit: Just to clarify the script isn't being controlled by the plugin.
     
    Last edited: May 19, 2016
  4. Offline

    timtower Administrator Administrator Moderator

    @tcwolf12 It is configurable from in-game:
    Code:
    /autore help    Shows help screen
    /autore time    Shows exactly when is the next server restart
    /autore now     Restarts the server now!
    /autore reload  Reloads the config file (This will reset the timer!)
    /autore in      Sets the time the server will restart in.
    /autore pause   Pauses the server AutoRestart timer.
    /autore start   Starts the server AutoRestart timer.
    And that startup script is what multicraft does for you.
     
    WolfMage1 likes this.
  5. Offline

    tcwolf12

    I don't use multi craft, does your server have to be hosted by a hosting provider to do that?
     
  6. Offline

    I Al Istannen

    @tcwolf12
    "You do not have to worry about the restarting portion, that is handled by my server's start.command."
    Seems like you do have a startup script.

    Apart from that: If the server is shut down, the plugin is too and can't restart the server.
     
  7. Offline

    tcwolf12

    Well I was aware of that but my script is really simple and I've got no idea how to schedule a restart with out running the server in screen and I'm trying to avoid that.
    Further, Multicraft isn't a viable option for me either as it does not currently support OS X.
    As I said in the original post it only has to stop the server the rest is handled automatically by my start.command as it will just re-run itself when it detects the server's shutdown.
     
    Last edited: May 19, 2016
  8. Offline

    I Al Istannen

    @tcwolf12
    Well, the linked plugin seems to do this:
    Just try it.
     
    timtower likes this.
  9. Offline

    tcwolf12

    I did the plugin just throws an internal error. If it actually worked I would be happy with it but it seems to be a consistent error through out multiple releases.
    Code:
    [13:46:40 ERROR]: null
    
    org.bukkit.command.CommandException: Unhandled exception executing command 'autore' in plugin AutoRestart v2.5
    
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at org.bukkit.craftbukkit.v1_9_R2.CraftServer.dispatchCommand(CraftServer.java:645) ~[spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.PlayerConnection.handleCommand(PlayerConnection.java:1349) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.PlayerConnection.a(PlayerConnection.java:1184) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_45]
    
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_45]
    
        at net.minecraft.server.v1_9_R2.SystemUtils.a(SourceFile:45) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.MinecraftServer.D(MinecraftServer.java:726) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.DedicatedServer.D(DedicatedServer.java:399) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.MinecraftServer.C(MinecraftServer.java:665) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at net.minecraft.server.v1_9_R2.MinecraftServer.run(MinecraftServer.java:564) [spigot.jar:git-Spigot-4af49dc-23da8b0]
    
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
    
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.serversmc.autorestart.utils.TitleAPI
    
        at org.serversmc.autorestart.utils.Messenger.sendTitle(Messenger.java:13) ~[?:?]
    
        at org.serversmc.autorestart.utils.Messenger.popupTime(Messenger.java:62) ~[?:?]
    
        at org.serversmc.autorestart.commands.autore.CmdTime.execute(CmdTime.java:18) ~[?:?]
    
        at org.serversmc.autorestart.commands.CmdAutoRestart.onCommand(CmdAutoRestart.java:44) ~[?:?]
    
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-4af49dc-23da8b0]
    
    *Got one command to work*
    Doesn't even stop the server though.
     

    Attached Files:

    Last edited by a moderator: May 19, 2016
  10. Offline

    I Al Istannen

    @tcwolf12
    Oh. That seems unfortunate. Does it have an option to disable the title alert? If yes, try that. If not, I am sorry and wish you good luck.. :/
     
  11. Offline

    tcwolf12

    I tried that and that has failed as well, for now my server is using a plugin that could break at any time and has (in the past) caused crashes (the dev appears to no longer maintain it) which is why I started this thread. Thanks for the reply though it was worth a shot.
     
  12. Offline

    ipodtouch0218

    I'll take it up. It may take awhile for me to make it though.
     
  13. Offline

    tcwolf12

    Thank you for your help!
     
  14. Offline

    ipodtouch0218

    @tcwolf12

    Okay, I'm starting to struggle with this. I don't think I can figure it out with the Schedulers.
    I'm going to have to stop developing this.

    Sorry. :(
     
  15. Offline

    I Al Istannen

  16. Offline

    tcwolf12

    Does anyone know if running in screen impacts performance?
     
  17. Offline

    timtower Administrator Administrator Moderator

    Define "running in screen"
     
  18. Offline

    ipodtouch0218

    @I Al Istannen

    It's mostly about retrieving the time remaining for the shutdown.
    Since I don't see a function for this in the scheduler itself, do you think this will work?

    Code:
    while (timeRemaining >= 1) {
                BukkitScheduler restart = getServer().getScheduler();
            restart.scheduleSyncDelayedTask(this, new Runnable() {
                @Override
                public void run() {
                    timeRemaining--
                }
            }, 20L);
    }
    
    if (timeRemaining == 0) {
        Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),"stop");
    }
     
    Last edited: May 20, 2016
  19. Offline

    timtower Administrator Administrator Moderator

    @ipodtouch0218 You can have it running all the time, if the timeRemaining<=1 then it is probably shutting down.
     
  20. Offline

    tcwolf12

    Screen is a command line (BASH) program in which other scheduled scripts can interact with the running programs and "type" in characters to make those programs run commands at set intervals.
     
  21. Offline

    timtower Administrator Administrator Moderator

    Those are generally external programs that don't have access to the server itself, just the terminal, they don't impact at all.
     
  22. Offline

    tcwolf12

    Are you still developing this and if so could I get a completion estimate?
     
  23. Offline

    ipodtouch0218

    The only real way I could developthis with my current understanding of Java and Bukkit, I would need to make the interval and the /aurore in {time} in either seconds or minutes, not "1h, 2m, 3s"
     
  24. Offline

    timtower Administrator Administrator Moderator

    @ipodtouch0218 Start by putting the values in the config, we can help with the input later.
    Probably some regex stuff.
     
  25. Offline

    tcwolf12

    If you could make the input for /autore in {time} be in minutes that would be awesome as well because I can just use a calculator to get the other values and it doesn't really need a seconds function.
     
  26. Offline

    tcwolf12

  27. Offline

    tcwolf12

    Should I just modify the script and then post the code here?
     
  28. Offline

    tcwolf12

  29. Offline

    tcwolf12

  30. Offline

    I Al Istannen

    @tcwolf12
    Okay, I made this plugin. I think it works as you want it to. It is a bit more complex, but therefore more flexible.
    It has the same commands as you wanted, exept the warntime. The config has comments, but they will get deleted once you use the ingame commands, which alter it. This is a limitation of bukkit's YAML.

    The warntime is evaluated by a Javascript interpreter (yea, efficiency!). While this opens some security risks (to exploit you will have to edit the config OR use the command. The command is limited to 200 somewhat chars, so there isn't THAT much of a risk with it). If somebody is able to do this, you probably have bigger problems anyways.) and is not exactly efficient. Therefore it might hang the server for a second at startup (I could have probably fixed this, but hey, not worth the effort). After this the cache is populated async and you shouldn't notice it.

    The warntime is a boolean expression, and you have the parameter "{TIME}", which is the time left in seconds. So, if you want to send the warn message if ten seconds or less are left, use "{TIME} <= 10". If you want to execute it if the time is ten seconds or less or dividable by 5, use "{TIME} <= 10 || {TIME} % 10 == 0". You can chain as much as you want, to send the messages exactly when you want. And and is "&&". It supports probably everything JavaScript does, so you can look it up if you want.

    It has a help, but no tab completion.

    Requirements: Java 8

    Link: dropbox.

    EDIT: The plugin has an error if the current time + the interval exceeds 24:00. I have fixed it, but I am not able to publish it. A lightning stroke our house and fried the router. And, because we live fairly remote, the mobile internet is Edge and way to slow to do anything. Sorry. I don't know when I will be able to release the better working version.

    EDIT2: It actually worked. For a few seconds the phone internet decided to work and the new version should be available at the same link above.
     
    Last edited: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page