Package xyz.xenondevs.particle.utils
Class PlayerConnectionCache
java.lang.Object
xyz.xenondevs.particle.utils.PlayerConnectionCache
- All Implemented Interfaces:
org.bukkit.event.Listener
A cache for player connections to avoid calling reflective
methods for each packet.
- Author:
- ByteZ
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newPlayerConnectionCacheand registers itself as an event listener. -
Method Summary
Modifier and TypeMethodDescriptiongetConnection(org.bukkit.entity.Player player) Gets the PlayerConnection of the specifiedPlayerfrom the cache.voidhandlePlayerQuit(org.bukkit.event.player.PlayerQuitEvent event) Removes a leaving player from thecache.voidRegisters the currentPlayerConnectionCacheinstance as an eventListener.
-
Constructor Details
-
PlayerConnectionCache
public PlayerConnectionCache()Creates a newPlayerConnectionCacheand registers itself as an event listener. The plugin is retrieved from the PluginClassLoader.
-
-
Method Details
-
registerListener
public void registerListener()Registers the currentPlayerConnectionCacheinstance as an eventListener. -
getConnection
Gets the PlayerConnection of the specifiedPlayerfrom 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 targetPlayer- Returns:
- the PlayerConnection of the specified
Player
-
handlePlayerQuit
public void handlePlayerQuit(org.bukkit.event.player.PlayerQuitEvent event) Removes a leaving player from thecache.- Parameters:
event- ThePlayerQuitEventthat should be handled
-