Class PlayerConnectionCache

java.lang.Object
xyz.xenondevs.particle.utils.PlayerConnectionCache
All Implemented Interfaces:
org.bukkit.event.Listener

public final class PlayerConnectionCache extends Object implements org.bukkit.event.Listener
A cache for player connections to avoid calling reflective methods for each packet.
Author:
ByteZ
  • Constructor Details

    • PlayerConnectionCache

      public PlayerConnectionCache()
      Creates a new PlayerConnectionCache and registers itself as an event listener. The plugin is retrieved from the PluginClassLoader.
  • Method Details

    • registerListener

      public void registerListener()
      Registers the current PlayerConnectionCache instance as an event Listener.
    • getConnection

      public Object getConnection(org.bukkit.entity.Player player)
      Gets the PlayerConnection of the specified Player from the cache. If the cache doesn't contain the PlayerConnection yet it uses reflective calls to retrieve the connection and adds it to the cache (If the player is online).
      Parameters:
      player - the target Player
      Returns:
      the PlayerConnection of the specified Player
    • handlePlayerQuit

      public void handlePlayerQuit(org.bukkit.event.player.PlayerQuitEvent event)
      Removes a leaving player from the cache.
      Parameters:
      event - The PlayerQuitEvent that should be handled