Interface ModuleListLocalization
- All Superinterfaces:
ModuleLocalization, ModuleSimple
- All Known Subinterfaces:
AutoModule, BrandModule, SidebarModule
A module whose text is a list rather than a single line, stepping to the next entry each
time it fires, as used by rotating messages such as the MOTD or auto broadcasts.
-
Method Summary
Modifier and TypeMethodDescriptiongetAvailableMessages(FPlayer fPlayer) The lines a player may currently be shown.default @Nullable StringgetCurrentMessage(FPlayer fPlayer) The line a player is on right now, without advancing the rotation.default @Nullable StringgetNextMessage(FPlayer fPlayer, boolean random) Advances the rotation and returns the next line.default @Nullable StringgetNextMessage(FPlayer fPlayer, boolean random, List<String> messages) Advances the rotation over an explicit list, keeping a position separate from the module's own.intgetPlayerIndexOrDefault(int id, int defaultIndex) The line a player is currently on.joinMultiList(List<MultilineString> values) Flattens a list of blocks into a list of lines, joining the lines of each block with a line.intnextInt(int start, int end) Picks a random index, used when the rotation is set to random order.voidsavePlayerIndex(int id, int playerIndex) Remembers the line a player is now on.Methods inherited from interface ModuleLocalization
cooldown, cooldownOrThrow, localization, permissions, sound, soundOrThrowMethods inherited from interface ModuleSimple
children, config, isDisable, name, onDisable, onEnable, permission
-
Method Details
-
getAvailableMessages
-
getPlayerIndexOrDefault
int getPlayerIndexOrDefault(int id, int defaultIndex) The line a player is currently on.- Parameters:
id- the rotation id, which is the player id mixed with the list being rotateddefaultIndex- what to return when the player has no position yet- Returns:
- the stored index, or the default
-
nextInt
int nextInt(int start, int end) Picks a random index, used when the rotation is set to random order.- Parameters:
start- the lower bound, inclusiveend- the upper bound, exclusive- Returns:
- the random index
-
savePlayerIndex
void savePlayerIndex(int id, int playerIndex) Remembers the line a player is now on.- Parameters:
id- the rotation idplayerIndex- the new index
-
joinMultiList
Flattens a list of blocks into a list of lines, joining the lines of each block with a line.- Parameters:
values- the blocks- Returns:
- one string per block
-
getCurrentMessage
-
getNextMessage
-
getNextMessage
Advances the rotation over an explicit list, keeping a position separate from the module's own.- Parameters:
fPlayer- the player the text is forrandom- whether to jump to a random line instead of the next onemessages- the lines to rotate through- Returns:
- the next line, or null if the list is empty
-