Interface ModuleListLocalization

All Superinterfaces:
ModuleLocalization, ModuleSimple
All Known Subinterfaces:
AutoModule, BrandModule, SidebarModule

public interface ModuleListLocalization extends ModuleLocalization
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 Details

    • getAvailableMessages

      List<String> getAvailableMessages(FPlayer fPlayer)
      The lines a player may currently be shown.
      Parameters:
      fPlayer - the player the text is for
      Returns:
      the available lines
    • 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 rotated
      defaultIndex - 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, inclusive
      end - 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 id
      playerIndex - the new index
    • joinMultiList

      default List<String> joinMultiList(List<MultilineString> values)
      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

      default @Nullable String getCurrentMessage(FPlayer fPlayer)
      The line a player is on right now, without advancing the rotation.
      Parameters:
      fPlayer - the player the text is for
      Returns:
      the current line, or null if there are none
    • getNextMessage

      default @Nullable String getNextMessage(FPlayer fPlayer, boolean random)
      Advances the rotation and returns the next line.
      Parameters:
      fPlayer - the player the text is for
      random - whether to jump to a random line instead of the next one
      Returns:
      the next line, or null if there are none
    • getNextMessage

      default @Nullable String getNextMessage(FPlayer fPlayer, boolean random, List<String> messages)
      Advances the rotation over an explicit list, keeping a position separate from the module's own.
      Parameters:
      fPlayer - the player the text is for
      random - whether to jump to a random line instead of the next one
      messages - the lines to rotate through
      Returns:
      the next line, or null if the list is empty