Making two servers talk to each other

Discussion in 'Plugin Development' started by HeyAwesomePeople, Nov 11, 2014.

Thread Status:
Not open for further replies.
  1. Hello devs,

    I was wondering if it is possible to use say Json or something in order for one minecraft server to ping another. What I am trying to accomplish is getting the numbers of players in a game and if a game is running on a certain server. For example, the game lobby would ping the hunger games server to check for a game, and if so, how many are alive. If this is possible, could someone please explain to me how?

    Thanks,
    HeyAwesomePeople
     
  2. Offline

    Skionz

    HeyAwesomePeople You would probably do this with sockets. You could also use a MySQL database but it would be messy.
     
  3. Offline

    guitargun

    HeyAwesomePeople

    if I am not mistaken a lobby with different "servers" is runned through bungee cord what will result in a different place to ask this.
    if you mean 2 different servers that are hosted on different places there is something you can do but it requires more then only java and bukkit knowledge.

    the idea with this system is that once someone uses a command or so the plugin executes a SQL command in the code to a database. Triggers on a website detect this execution. if the 2nd server can reach that database for those triggers you are set. Then the triggers run a command to the server itself (I forgot what that is called) that uses a console command and that can display in your 2nd server.

    overall you will need 1 plugin, 1 database (if better ways than that use it), 1 website for the triggers (or something that can detect it).

    your plugin has to contain 2 commands or actions (at least).
    1. from server to database (the way you set the triggers)
    2. from database/trigger part to server (the way you can display it)

    I am not familiar with the trigger part so don't ask me how to.
     
  4. Offline

    Crud41

    When I want two servers to talk to one another, I always use sock puppets. They are very entertaining.
     
    Funergy, leon3001 and Gamecube762 like this.
  5. Offline

    Gamecube762

    I was doing it wrong all this time! I thought it was Glove Puppets!
     
    Crud41 and leon3001 like this.
  6. Offline

    leon3001

    Glove Puppets are sooooo 2012.
     
    Gamecube762 likes this.
  7. Offline

    guitargun

    and ofc people now better ways. guess my java knowledge is not enough for this shit.
     
  8. Offline

    RainoBoy97

    Use either Java Sockets or Redis :)
     
    Garris0n likes this.
  9. Offline

    Crud41


    Yes. That is why I suggested sock puppets.
     
    FerusGrim likes this.
  10. Offline

    Funergy

    HeyAwesomePeople Skionz
    I use MySQL :p. I've heard some servers use MongoDB like Hypixel. but I don't know how to use it tho.
    SuperOriginal
    That tutorial is old. he is using the 1.6 protocol of pinging servers. You need to find how to use the newer protocol
    EDIT: fireblast709 doesn't like that youtuber (He would probably love to explain why xD)
     
  11. Offline

    guitargun

    first thing to do when I am home. grab my books and look for those things :D
     
  12. Offline

    Funergy

    guitargun I always do researches on the internet :p
     
  13. Offline

    Skionz

    Funergy Sockets are probably the most efficient way.
     
    CubieX and Konato_K like this.
  14. Offline

    Funergy

    Skionz Yeah. but I never found how to use the 1.7 protocol
     
  15. Offline

    Garris0n

    Redis would be best, really. Have all the servers report their player count or something. MySQL isn't particularly well-suited for this as it's not in-memory and you don't really need a bunch of player counts to be saved to disk, sockets feel a bit messy, and redis's pub/sub would be useful for other sorts of communication.
     
  16. Offline

    thomasb454

    [OFFTOPIC]
    Skionz
    Actually - I made a rather good system for my server - SQL back-end. :p
    [/OFFTOPIC]
     
  17. Redis is a very fast and efficient option, taking 10 ms or less to run commands on a local server. This may be my resort as I have no clue how to use sockets.
    I am also looking into using Bungee's API to do it, since the servers will be linked with Bungee
     
  18. Offline

    Konato_K

    HeyAwesomePeople Then use the plugin messaging channel (that is part of bukkit) in the BungeeCord channel, but I believe there is no support for bungeecord in these forums.
     
  19. HeyAwesomePeople use "ServerSocket" and "Socket". your minecraftserver should try to open a socket to the server which is connecting all the different minecraftserver, you want to connect to another, to another. the server which handles the connections should have the serversocket and handles everything about the connection and the communication. everytime you have a change on your minecraftserver, send the change to the server and the server will send the change to all other minecraftservers. here is a simple example for a connection with "ServerSocket" and "Socket": https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
     
  20. Offline

    CubieX

    Sockets have nothing to do with Bukkit. The version of Bukkit is irrelevant. Sockets are sockets.
    Or did you mean Java?
    There are some pretty straight-forward examples on the net for this.
    Using sockets is an efficient way to exchange fast changing information between servers.
     
  21. Offline

    Funergy

    CubieX Pinging Minecraft servers has changed in the server protocol. I've used the tutorial from Pogostick29 and he used the 1.6 version <---- with this you CAN ping the player count but you can't ping the motd with it. thats why we need to update our code to the newer protocol
     
  22. Offline

    mythbusterma

    Funergy

    If the other server has a different socket that reports the players, like he is intending, that is completely irrelevant. Also, please don't mention those awful tutorials on these forums.
     
  23. Offline

    Skionz

    I touched sockets for the first time today and have come to the conclusion that they are the easiest. They don't feel very messy and are pretty efficient. In this case they would probably be the clear choice.
     
  24. Offline

    Funergy

  25. Offline

    CubieX

    I don't understand what you mean. If you use Java sockets to connect two servers, you can execute code on the other server to your hearts desire. You only need to make a plugin for each server or a configurable one that can send and receive data via java sockets.
    You do not need to use "Pingping Minecraft servers" protocol (whatever that is...). Just listen for incoming commands via a server socket from one server and send player count or whatever information you like back to the client. (the querying server).
    The minigame plugin also nees an API for providing the alive player count to your own plugin though.
    "Pinging" a server for alive players in a game that's provided by a plugin is not possible with a simple minecraft server ping. You can only get the total player count on that server. But afaik nothig plugin related.

    If this doesn't make sense to you, then please clarify what exactly you want. Because I can't see the connection between any minecraft related protocol and java sockets. :confused:
     
  26. Offline

    Funergy

    CubieX
    I don't even...
    I was just missunderstanding his question
    <!---End of conversation--->
     
Thread Status:
Not open for further replies.

Share This Page