Class PingManager
java.lang.Object
me.remigio07.chatplugin.api.server.util.manager.PingManager
- All Implemented Interfaces:
Runnable,ChatPluginManager
Manager that handles loaded players' pings.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringformatPing(int ms, Language language) Returns a string formatted with given ping'sPingManager.PingQuality's colors.formatPing(ChatPluginServerPlayer player) CallsformatPing(int, Language)specifying argumentsChatPluginServerPlayer.getPing()andChatPluginServerPlayer.getLanguage()of given player.intgetCachedPing(ChatPluginServerPlayer player) Returns a player's cached ping.static PingManagerGets this manager's instance.abstract PingManager.PingQualitygetPingQuality(int ms) Establishes whatPingManager.PingQualitya ping belongs to according to the response time, expressed in milliseconds.Gets the loaded ping qualities list.abstract intDeprecated.This method will return the ping directly from the player's connection class using reflection.longGets the update task's ID.longGets the timeout between ping updates, in milliseconds.booleanChecks if this manager is enabled.abstract voidrun()Automatic online players' ping updater, called once everygetUpdateTimeout()ms.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.remigio07.chatplugin.api.common.util.manager.ChatPluginManager
checkAvailability, isReloadable, load, reload, unload
-
Constructor Details
-
PingManager
public PingManager()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Description copied from interface:ChatPluginManagerChecks if this manager is enabled.- Specified by:
isEnabledin interfaceChatPluginManager- Returns:
- Whether this manager is enabled
-
getQualities
Gets the loaded ping qualities list.- Returns:
- Ping qualities
- See Also:
-
getUpdateTimeout
public long getUpdateTimeout()Gets the timeout between ping updates, in milliseconds.Found at: "ping.update-timeout-ms" in
ConfigurationType.CONFIG- Returns:
- Time between updates
-
getTimerTaskID
public long getTimerTaskID()Gets the update task's ID.You can interact with it through
TaskManager's methods.- Returns:
- Update task's ID
-
getCachedPing
Returns a player's cached ping.Latencies are cached in a map updated once every
getUpdateTimeout()ms. If you need a real time ping (just a little more precise), you can usegetRealTimePing(ChatPluginServerPlayer), but it's not recommended, as many calls of that method could be heavy to handle.- Parameters:
player- Player to get the ping for- Returns:
- Player's cached ping, in milliseconds
-
formatPing
CallsformatPing(int, Language)specifying argumentsChatPluginServerPlayer.getPing()andChatPluginServerPlayer.getLanguage()of given player.- Parameters:
player- Player to get the ping for- Returns:
- Formatted ping with colors
-
getInstance
Gets this manager's instance.- Returns:
- Manager's instance
-
run
public abstract void run()Automatic online players' ping updater, called once everygetUpdateTimeout()ms. -
getRealTimePing
Deprecated.This method will return the ping directly from the player's connection class using reflection. You should usegetCachedPing(ChatPluginServerPlayer)instead for a cached and less resource demanding ping request if performing multiple calls of this method.Gets a player's real time ping.- Parameters:
player- Player to get the ping for- Returns:
- Player's real time ping, in milliseconds
-
getPingQuality
Establishes whatPingManager.PingQualitya ping belongs to according to the response time, expressed in milliseconds.- Parameters:
ms- Ping to check- Returns:
- Resulting ping quality
-
formatPing
Returns a string formatted with given ping'sPingManager.PingQuality's colors.If you want just a player's ping in milliseconds, use
getCachedPing(ChatPluginServerPlayer).- Parameters:
ms- Latency, in millisecondslanguage- Language to get the message for- Returns:
- Formatted ping with colors
-