Solved Communicate with RemoteToolkit

Discussion in 'Plugin Development' started by MinecraftShamrock, May 25, 2013.

Thread Status:
Not open for further replies.
  1. Hi there.
    I have a plugin for a custom gamemode.
    When the game is over the server has to restart.
    How can my plugin tell remoteToolkit that the server has to restart?

    UPDATE: The final result is that I can use getServer().shutdown(); to stop it and remote toolkit will restart it automatically.

    drdanick tagging you because you are the author of rtk

    Please help.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. Offline

    Pink__Slime

  3. Offline

    Timatooth

  4. Ok. Sorry

    Timatooth Well, I've seen the RTKInterface class in the api javadocs.
    But how can I call the methods in this class?
    I couldn't find the class in the RTKPlugin.jar or whatever it is called.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  5. Offline

    Timatooth

    I think the interface is used for extending the functionality of the RTK plugin, not interacting with it i.e calling methods.
    It looks like you might be left with just making a mini UDP/Telent class that sends the commands just like any other client software does (doesn't seem right) surely there is a better way.

    From brief skimming of code I think that's how the JSONAPI plugin does it https://github.com/alecgorge/jsonap...inecraft/jsonapi/McRKit/api/RTKInterface.java

    It's can do these methods via its HTTP api
     
  6. Timatooth Oh... ok.
    But would it actually be possible to simply do an severe output?
    Because remote toolkit automatically restarts the server when a severe output is done isn't it?
    So could I do something like this?
    Code:
    public void restartServer(JavaPlugin plugin) {
        //Doing severe output
        plugin.getLogger().severe("Doing a severe output to force a restart.");
    }
     
  7. Offline

    Timatooth

    Ha ha that's one way to cheat and do it! You might have to throw a mock exception rather than just logging a message as Level.SEVERE and let it go uncaught to notify bukkit assuming that's how RTK might 'see' them I'm not sure.
     
  8. Timatooth Do you mean, I should throw something like a simple NullPointerException?
    Or would it be enough to throw a "new Exception()" ?
     
  9. Offline

    LucasEmanuel

  10. LucasEmanuel But I need to restart the server. So I need to communicate with the wrapper.
    And in the RemoteToolkit plugin there are no API methods.
     
  11. Offline

    Timatooth

    I don't see how this helps. In these cases its quite easy to hook into when there is a open api present. I can't even find the source code for RTK I think it's closed/dev hasn't pushed code but a repo is there.

    MinecraftShamrock
    It feels 'wrong' but I think you would have to come up with a way to create a NPE. Any method that has an explicit throw new Exception(); in Java has to be surrounded in try/catch blocks for it to compile.

    Being me, I'd just use the java.io package and wire up some local UDP connection to issue the shutdown. I don't think it would be too hard.
     
  12. Offline

    LucasEmanuel

    Well the plugin doesn't need to have an API in order to hook into it, but after taking a closer look at RTK, you seem to have to do it the other way :)

    Yea sorry, it was just a little tip. Didn't realise how huge RTK was until now :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  13. Timatooth Thank you. I'll try both solutions :D
    Just one more question: In the remote toolkit settings I have to specify a severe-detection-level.
    If I throw an Exception would severe-detection-level 1 be enough?
     
  14. Offline

    Timatooth

    Another thought, do you need to call any rtk methods at all? getServer().stop(); will stop the server and won't the RTK automatically start it again?

    I haven't really used RTK but I just had a plugin that periodically stopped the server by doing just that. The server was started again by a simple shell script.
    Code:
    #pseudo command line script
    while True:
      echo "Server will start again in 5 seconds. Press CTRL + C to cancel"
      sleep 5
      java -Xms1024M -Xmx1024 -jar craft*.jar
    end while
     
    MinecraftShamrock likes this.
  15. Timatooth Haha :D Yes. That's the easiest way xD
    And it doesn't feel as wrong as throwing an exception :)
    Thank you.
     
  16. Offline

    drdanick

    Although this is solved, I will say there is actually a fully documented library which will allow you to communicate with the Toolkit's UDP API:

    http://drdanick.com/minecraft/RTKUDPAPI_R7.zip

    As well as the associated documentation: http://drdanick.com/minecraft/mcrdoc

    The only issue you may have is that you do need to supply a username and password. Future releases of the toolkit will not require this.
     
Thread Status:
Not open for further replies.

Share This Page