Util Detect if a player has your server added in their multiplayer list.

Discussion in 'Resources' started by Gamecube762, Aug 19, 2014.

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


    First off, as we know, its near impossible to grab most information from the client, this is one of them. We can't see what the client has in it's server list, but we can see if they have us in their server list by watching them.

    How it works:
    What we can do is watch both the ServerListPingEvent and PlayerJoinEvent and see what IPs connect. From the ServerListPingEvent, we know that they have the server in their multiplayer list from the client pinging ever server in the list. After that, all we need to do is watch PlayerJoinEvent so we know who the Player is.

    I created a simple plugin that does this and has a simple API for Developers to use to see who has the server in their multiplayer list.

    The plugin is on Bukkit Dev and Github for those who wants to test this. For those who want to make their own or wants to add their own adjustments, feel free to look at the Github.

    How to use this:
    1. Simply add the plugin as a Dependency or SoftDependency
    2. Check if the server has the plugin.
      1. public static boolean isMPListJoinAdded() {
      2. return (Bukkit.getPluginManager().getPlugin("MPListJoin") != null);
      3. }
    3. Grab the information you need:
      1. Player player = somePlayer;
      2. if (MPListJoin.playerUsedMPlist( player )) {
      3. player.sendMessage("Thank you for adding us to your favorites!");
      4. }
    Bukkit Dev Page
    Github Page
  2. Offline


    What if they direct connect?
  3. Offline


    They would need to open their multiplayer list first, from that the ping will reach the server. Any way the client connects after that to the server will still say that they have the server added to their list.
  4. Offline


    If it pings slowly, then the ping won't hit before they actually double click it
  5. Offline


    zombiekiller753 If the ping goes slowly, then so will the packet for connecting.
  6. Offline


    actually if your server is not in their list and they do a direct connect then the ping would not work because of the direct connect just sayin
  7. Offline


    tehface If so, then the plugin would say that the player doesn't have the server in their list and that would be correct.
    xTrollxDudex likes this.
  8. This is pretty clever, good job.​
    Gamecube762 likes this.
  9. Offline

    The Fancy Whale

    Interesting idea. Not perfect, but it is cool!
    Gamecube762 likes this.
  10. Offline


    (Just read the code)

    So, whenever a player pings the server, it adds them to a list, and when a player joins, it checks that list. Why doesn't the direct connect trigger that? It would seem you would have to ping the server to connect to it, though you don't need any of the data that the ping sends...... Also, 5 minutes is kind of a short amount of time, as I open my MP screen, do stuff, come back to it like 20 minutes later and join a game. I can see how there would be no way to fix this, which is a bummer.

    TL;DR: Great use of vanilla mechanics :3
  11. Offline


    Direct connect can trigger it since the option is under the multiplayer list, which pings all of the servers in the list(or all of the servers on the screen). From there, joining by Direct Connect, or double clicking on the server gives the same result.

    You have to hit the first trigger to activate the second, 1st being the Ping, 2nd being the join.

    5 minutes is a decent amount of time for any player who wants to go straight to a server. The time is configure-able with the config.

    It is noted on the Bukkit Dev Page that false positives could be generated from a player AFKing in the multiplayer list. Changing the time could help solve this, but it isn't an accurate solution. Adding an extreemly long time, or a line of code that disables the IP hold time, could generate false positives. While those would most likely be true, but the player could do anything with their server list, or a bot could ping your server and the IP will be held till a restart/reload.

    Anyways, thanks for the feedback, this is open to any ideas/changes!
    Phasesaber likes this.
  12. Offline


    Gamecube762 If the Direct connect triggers it, then how is it different than it being on the server list, since they both trigger it?
  13. Offline


    Phasesaber What the plugin is looking for is the ping from the client's multiplayer list, that will only happen if the server is in the list. Next thing it looks for is the PlayerJoin, of both happened, then it will mark that player as someone who has the server in their list.

    The plugin is designed to see if a client has the server in their multiplayer list. The exact methods that they use to ping and connect is up to them.
Thread Status:
Not open for further replies.

Share This Page