Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-146

Needed: Fast, efficient offline player lookup by name (in local data, no calls to Mojang).

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None

      I'm only interested in players who've played on my server before, and there doesn't seem to be a good option for powering slash commands which target offline players now. It used to be the case that server.getOfflinePlayer(name) was fast, but now it's too slow.

      One of my plugins includes lots of slash commands which should reasonably be able to target offline players, and searching linearly through all the players returned by server.getOfflinePlayers() is just wrecking performance - very large servers with tens of thousands of lifetime players are complaining of lag and even crashes (due to Spigot getting tired of waiting) when using these commands.

      I've temporarily worked around this by caching players who've played in the last two weeks in memory (just their names and UUIDs), but it's not a great solution - sometimes, especially for admin scenarios, targeting an offline player who hasn't been on the server recently is needed.

      Can we please get a fast, efficient player lookup by name which only looks at local data (no web calls)? Something like server.getLocalOfflinePlayer(name) or server.getSeenOfflinePlayer(name)? I know I can bend over backward and refactor my code to make every player lookup async with a callback, but I hope you will agree this scenario (looking up a previous player who's currently offline by name) is common enough to warrant support in the platform! Common scenarios include sending messages to be read later, ignoring a player who's logged off already, and sending a friend request to be answered later.

      I'm also open to suggestions, if anyone can recommend a better way of doing this without any platform change. So far I've tried:

      1. server.getOfflinePlayer(name)
      2. searching through the players returned by server.getOfflinePlayers()
      3. caching name/uuid pairs of recent players in a hash map

      Only 3 gets me reasonable performance, but it limits users to targeting recent players. Expanding it to cache all players isn't an option due to the RAM that would be needed for the cache (in very large servers, which are the only servers who notice the lag problem I'm trying to solve).

      I don't think a SQL or file cache managed by the plugin is a good alternative either, just because it's so heavyweight. That's a lot of work just to get offline player targeting which works for large servers, too much for every plugin dev with that requirement to implement, in my opinion.

      Thanks for reading my lengthy post!

            Unassigned Unassigned
            BigScary Ryan Hamshire
            Votes:
            9 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: