Class ScoreboardManager
java.lang.Object
me.remigio07.chatplugin.api.server.scoreboard.ScoreboardManager
- All Implemented Interfaces:
ChatPluginManager
Manager that handles
Scoreboard
s.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Pattern
Pattern representing the allowed scoreboard IDs. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addScoreboard
(Scoreboard scoreboard) Adds a scoreboard togetScoreboards()
.abstract Scoreboard
createScoreboard
(Configuration configuration) Reads a scoreboard from the specified configuration.abstract Scoreboard.Builder
createScoreboardBuilder
(String id, boolean abbreviateLongText, List<PlaceholderType> placeholderTypes) Creates a new scoreboard builder.static ScoreboardManager
Gets this manager's instance.getScoreboard
(String id) Gets a scoreboard fromgetScoreboards()
by its ID.Gets the list of loaded scoreboards.getTimer()
Gets the timer used to schedule scoreboard updates.boolean
Checks if this manager is enabled.boolean
isValidScoreboardID
(String scoreboardID) Checks if the specified String is a valid scoreboard ID.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.remigio07.chatplugin.api.common.util.manager.ChatPluginManager
checkAvailability, isReloadable, load, reload, unload
-
Field Details
-
SCOREBOARD_ID_PATTERN
Pattern representing the allowed scoreboard IDs.Regex:
^[a-zA-Z0-9-_]{2,36}$
- See Also:
-
-
Constructor Details
-
ScoreboardManager
public ScoreboardManager()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Checks if this manager is enabled.Found at: "settings.enabled" in
ConfigurationType.DEFAULT_SCOREBOARD
- Specified by:
isEnabled
in interfaceChatPluginManager
- Returns:
- Whether this manager is enabled
-
getScoreboards
Gets the list of loaded scoreboards.Do not modify the returned list.
- Returns:
- Loaded scoreboards' list
-
addScoreboard
Adds a scoreboard togetScoreboards()
.Note: the scoreboard will be removed on
ChatPluginManager.unload()
.- Parameters:
scoreboard
- Scoreboard to add- Throws:
IllegalArgumentException
- IfScoreboard.getID()
is already in use, case insensitive
-
getScoreboard
Gets a scoreboard fromgetScoreboards()
by its ID.Will return
null
if the scoreboard is not loaded.- Parameters:
id
- Scoreboard's ID, case insensitive- Returns:
- Loaded scoreboard
-
getTimer
Gets the timer used to schedule scoreboard updates.- Returns:
- Timer used
-
isValidScoreboardID
Checks if the specified String is a valid scoreboard ID.- Parameters:
scoreboardID
- Scoreboard ID to check- Returns:
- Whether the specified scoreboard ID is valid
- See Also:
-
getInstance
Gets this manager's instance.- Returns:
- Manager's instance
-
createScoreboardBuilder
public abstract Scoreboard.Builder createScoreboardBuilder(String id, boolean abbreviateLongText, List<PlaceholderType> placeholderTypes) Creates a new scoreboard builder.- Parameters:
id
- Scoreboard's IDabbreviateLongText
- Whether to abbreviate long text (Scoreboard.shouldAbbreviateLongText()
)placeholderTypes
- Placeholders used to translate titles and lines (Scoreboard.getPlaceholderTypes()
)- Returns:
- New scoreboard builder
- Throws:
IllegalArgumentException
- If specified ID!
isValidScoreboardID(String)
-
createScoreboard
Reads a scoreboard from the specified configuration.The scoreboard's ID is obtained by removing
Configuration.getFile()
's extension and has to matchSCOREBOARD_ID_PATTERN
.- Parameters:
configuration
- Configuration to read- Returns:
- New scoreboard
- Throws:
IllegalArgumentException
- If at least one of the following is true:- scoreboard's ID
!
isValidScoreboardID(String)
- no valid lines have been specified at the "lines" section
- the
NumbersDisplayMode
at "settings.numbers.display-mode" is invalid - "settings.numbers.custom-text.colors.cycle-timeout" is not positive or invalid
- "settings.numbers.custom-text.colors.interpolations" is negative
- the list at "settings.numbers.custom-text.colors.gradient" is empty
- scoreboard's ID
NoSuchElementException
- If translations forLanguage.getMainLanguage()
are not presentIndexOutOfBoundsException
- If line indexes outside of range 0 - 14 are specifiedUnsupportedOperationException
- If!
NumbersDisplayMode.isSupported()
NumberFormatException
- If colors of the gradient use an invalid format
-