Discussion in 'Spigot Plugin Development' started by gogobebe2, May 21, 2015.


Do you think this will work?

  1. Yes!

  2. No, I'll comment why.

    0 vote(s)
  1. I'm creating a minigame plugin and I thought of a small hack that might allow me to restart the server without stopping the server and editing the server bat file to make it loop back to the start and start it again.
    Wouldn't it be possible to do this:
    I use ping to make it sleep for 15 seconds before starting the server up again.
    Code (Text):
    Runtime r = Runtime.getRuntime();
    r.exec("ping -n 15 localhost>nul\njava -Xmx12288M -Xms512M -jar spigot.jar -log-strip-color");
    My questions:
    • Will it even work?
    • Is there a better way to do this?
    [Edit] I'm at school at the moment so I can't test my self. But if anyone wants to see if this little hack would work, feel free. I think it'd be really useful.
    #1 gogobebe2, May 21, 2015
    Last edited: May 22, 2015
  2. Have you tried it yourself? That might be the first best thing you can do ;).
    • Like Like x 1
    • Funny Funny x 1
  3. Lol. No, I'm at school. Can't yet.
    Thought I'd just create a thread quickly to see what people think.
  4. Let me know how your testing goes, quite a fine piece of code ya got there.
    • Optimistic Optimistic x 1
  5. Using a subprocess is fine but you need to add a shutdown hook which manually enforces System#exit if you want to ensure the parent process exits before yours begins
    • Informative Informative x 1
  6. Looks like a really ugly solution to me.

    Sure, it may work, but I can also slice bread with a fork if I want to. Not exactly an elegant method, though.
    • Like Like x 1
  7. How else are you supposed to slice your bread?
    • Funny Funny x 1
  8. I usually use my dremel :p
    • Funny Funny x 1
  9. Tested:
    Code (Text):
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (label.equals("test")) {
                Runtime r = Runtime.getRuntime();
                try {
                    r.exec("ping -c 15 localhost>nul; sh \"/home/william/Desktop/Plugin Development/Test server/\"");
                } catch (IOException e) {
                return true;
            return false;
    Didn't work. It just stopped the server and didn't restart.
    (This is in linux. Havn't tested with Windows.)

    How? Maybe explain in a bit more detail. I don't have any experiences in "hooks". (googling atm)

    How would you come to a solution then?
    #9 gogobebe2, May 22, 2015
    Last edited: May 22, 2015