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

Allow hidePlayer and showPlayer and similar methods to be run async

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • None
    • None
    • None
    • This server is running CraftBukkit version 3648-Spigot-19641c7-7c44152 (MC: 1.19.3) (Implementing API version 1.19.3-R0.1-SNAPSHOT)
    • Yes

      The API methods Player#hidePlayer and Player#showPlayer (and their entity equivalents) cannot be run from an async thread without errors occuring, telling me "PlayerShowEvent cannot be triggered async" and "IllegalStateException: Async player tracker clear".

      I did not expect those errors to appear, as I thought that these methods only request spigot to do the hiding or showing in the next possible moment. Also, even when doing the operation async, spigot only needs to send an entity destroy packet and intercept any packets regarding that entity from being sent. Both of which should be possible in an async thread, which lead me to believe it was safe to call (note: that is exactly what I did before with ProtocolLib, but I want to use API calls as much as possible for greater compatibility). Moreover, hiding and showing entities is a functionality that is often called on a lot of entities nearly simultaneously, which makes sync execution a performance issue.

      I understand that apparently Spigot wants to call an event before showing or hiding a player, but then I would request that internally, the hidePlayer and showPlayer calls are queued to be batch executed in the next tick, instead of me creating a lot of custom scheduler tasks for lots of entities.

      Even if all that is not possible, I would suggest changing the methods to fail fast on async calling to get a more descriptive error message like "hidePlayer cannot be called from an async thread"

            Unassigned Unassigned
            Photon Photon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: