Package me.neznamy.tab.api.scoreboard
Interface ScoreboardManager
public interface ScoreboardManager
Interface allowing work with scoreboards, such as creating,
sending, toggling and modifying.
Instance can be obtained using TabAPI.getScoreboardManager().
This requires the scoreboard feature to be enabled in config,
the method will return null otherwise.
-
Method Summary
Modifier and TypeMethodDescriptionvoidannounceScoreboard(String scoreboard, int duration) Temporarily displays scoreboard to all players for specified amount of time (in milliseconds).createScoreboard(String name, String title, List<String> lines) Creates new scoreboard, registers and returns it.getActiveScoreboard(TabPlayer player) Returns player's currently displayed scoreboard.Returns map of registered scoreboards via config and API.booleanhasCustomScoreboard(TabPlayer player) Returnstrueif player has custom scoreboard set usingshowScoreboard(TabPlayer, Scoreboard),falseif not.booleanhasScoreboardVisible(TabPlayer player) Returnstrueif player has scoreboard enabled,falseif disabled (toggled) using either toggle command,toggleScoreboard(TabPlayer, boolean)orsetScoreboardVisible(TabPlayer, boolean, boolean).voidresetScoreboard(TabPlayer player) Hides custom scoreboard sent usingshowScoreboard(TabPlayer, Scoreboard)and re-enables internal display logic with conditions.voidsetScoreboardVisible(TabPlayer player, boolean visible, boolean sendToggleMessage) Sets scoreboard visibility of player to defined value.voidshowScoreboard(TabPlayer player, Scoreboard scoreboard) Displays scoreboard to defined player.voidtoggleScoreboard(TabPlayer player, boolean sendToggleMessage) Toggles scoreboard for specified player.
-
Method Details
-
createScoreboard
Creates new scoreboard, registers and returns it.nameis internal name of the scoreboard, which it will be registered with and further work where scoreboard name is used allowed.Scoreboard
titleis limited to 32 characters on <1.13. If needed, it will be cut to 32 character for those players (after replacing placeholders). RGB is supported using any of the supported formats. Placeholders are supported.lineswill display in the same order as contained in the list. Client can only see up to 15 lines at a time, however you can define more, if some of them only consist of placeholder that might be empty.- Parameters:
name- Internal name of the scoreboardtitle- The scoreboard titlelines- Lines of text in scoreboard (supports placeholders)- Returns:
- The new scoreboard with given parameters
- Throws:
NullPointerException- ifnameorlinesisnull
-
getRegisteredScoreboards
Map<String,Scoreboard> getRegisteredScoreboards()Returns map of registered scoreboards via config and API. Map key is name of scoreboard, which is defined either in config or usingcreateScoreboard(String, String, List). Map value is reference to the actual scoreboard.- Returns:
- map of registered scoreboards
-
showScoreboard
Displays scoreboard to defined player. This will disable all display condition checks until the scoreboard is unregistered usingresetScoreboard(TabPlayer). If the player already sees this scoreboard, nothing will happen.- Parameters:
player- Player to send scoreboard toscoreboard- Scoreboard to display- Throws:
NullPointerException- ifplayerorscoreboardisnull- See Also:
-
hasCustomScoreboard
Returnstrueif player has custom scoreboard set usingshowScoreboard(TabPlayer, Scoreboard),falseif not.- Parameters:
player- Player to check- Returns:
trueif player has custom scoreboard set using API,falseif not- See Also:
-
resetScoreboard
Hides custom scoreboard sent usingshowScoreboard(TabPlayer, Scoreboard)and re-enables internal display logic with conditions. If player does not have any forced scoreboard, nothing happens.- Parameters:
player- Player to hide custom scoreboard from- See Also:
-
hasScoreboardVisible
Returnstrueif player has scoreboard enabled,falseif disabled (toggled) using either toggle command,toggleScoreboard(TabPlayer, boolean)orsetScoreboardVisible(TabPlayer, boolean, boolean).- Parameters:
player- Player to get visibility status of- Returns:
trueif visible,falseif disabled- See Also:
-
setScoreboardVisible
Sets scoreboard visibility of player to defined value. If visibility status is same as player had before, nothing happens. If this call changes visibility, scoreboard is toggled. IfsendToggleMessageistrue, toggle message defined in configuration is sent.- Parameters:
player- Player to set visibility forvisible- New visibility statussendToggleMessage- whether to send toggle message if status changed or not- See Also:
-
toggleScoreboard
Toggles scoreboard for specified player. If player had scoreboard visible, hides it. If hidden, shows it. IfsendToggleMessageistrue, toggle message defined in configuration is sent.- Parameters:
player- Player to toggle scoreboard forsendToggleMessage- Whether to send toggle message or not- See Also:
-
announceScoreboard
Temporarily displays scoreboard to all players for specified amount of time (in milliseconds). Scoreboard name is either defined in config, or through API increateScoreboard(String, String, List).- Parameters:
scoreboard- Scoreboard from config or registered via APIduration- Duration in milliseconds- Throws:
IllegalArgumentException- if no scoreboard was found with such name ordurationis < 0.
-
getActiveScoreboard
Returns player's currently displayed scoreboard. This can be either with configuration, overridden with commands or the API. Will returnnullif player does not see any scoreboard due to not meeting any display condition.- Parameters:
player- player to get active scoreboard of- Returns:
- player's active scoreboard or
nullif player has no scoreboard
-