Solved Kicking all players and Restarting server

Discussion in 'Plugin Development' started by ThatGuyWhoDied13, Nov 25, 2013.

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

    1Rogue


    You hook that into the shutdown when you run a restart command, then you have the command stop the server.
     
  2. 1Rogue would the file location be ./run.bat/
     
  3. Offline

    1Rogue


    It would be a relative location based on the server root.
     
  4. 1Rogue ok and I just put the code in my command and voila?
     
  5. Offline

    1Rogue


    Basically, yeah.
     
  6. Offline

    drdanick

    Using Runtime.exec to restart the server is not advised. What you would end up doing is launching an instance of Bukkit as a child process of Bukkit, and then orphaning it by (hopefuly) closing the parent process. The child process will most likely not have handles that point to your terminal in/out, and you would not receive any output, nor be able enter anything in to the new process' console (unless you somehow managed to launch a new terminal with the child process).

    Essentially, the easiest way of doing this properly without a lot of work is to have a script start up your server in a loop, allowing it to restart if it closes. Then you just simply shut the server down, and allow it to start up again. You can do this with a minimal amount of shell/batch scripting. If you want a little more flexibility, you can use RemoteToolkit, which provides an API to restart the server from a plugin (though it may be a bit much for your use case).
     
  7. Offline

    1Rogue


    The idea is not to run bukkit as a child process but to run the batch/shell script that would execute bukkit as a child process.
     
  8. 1Rogue drdanick I have already done this. I used a different script in my run.bat that when the server stops it restarts.
     
  9. Offline

    JPG2000

    @KevyPorterz First of all your original code has a useless if statement, Learn2If.

    Code:java
    1. //THIS IS YOUR POOPY CODE
    2. if (!player.isOp()) {
    3. } else {
    4. if (player.isOp()) {
    5.  
    6. }
    7. }
    8.  
    9. //ITS POOPY BECAUSE YOU DON'T NEED TO TEST IF PLAYER IS OP A SECOND TIME
    10. //USE DIS DAWG
    11. if (!player.isOp()) {
    12. } else {
    13. }


    In all seriousness, I don't think you understand control and if statements: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
     
  10. Offline

    drdanick

    Yes, but depending on the platform (at least with linux) the shell script interpreter is childed to the Bukkit process, and its file handles will not point to Bukkit's TTY, but to streams delegated by exec to facilitate communication between the parent and child. There are ways to fix this to work properly across all platforms, but it's not straightforward, hence why I suggested the script.


    JPG2000 It pays to be a little less condescending when nit picking code from someone new to these things :p
     
    JPG2000 likes this.
  11. Offline

    iiHeroo


    This code would give everyone permission to /restartserver if they're not OP ._.
     
  12. Offline

    JPG2000

    iiHeroo No, I didn't write //Restart you did :)

    Lol, I know Java and if statements, and he doesn't :D
     
  13. Offline

    iiHeroo


    That wasn't to you, and //Restart was there...
     
  14. Can this thread be locked I have solved this TnT
     
  15. Offline

    JPG2000

    iiHeroo No, my post doesn't have it///.

    And okay, my bad!
     
  16. Offline

    Garris0n

    Don't tag staff, report it. And there's no reason to lock it regardless.
     
  17. Garris0n It's annoying me, getting alerts for somthing tats solved
     
  18. Offline

    MayoDwarf

    Still, they won't lock it for that reason.
     
  19. Offline

    Wingzzz

    Simply go to the top of the thread and click "Unwatch thread" at the top right. (Visual) This will prevent any further notifications from the thread towards you.
     
Thread Status:
Not open for further replies.

Share This Page