Class FastBoardBase<T>

java.lang.Object
fr.mrmicky.fastboard.FastBoardBase<T>
Direct Known Subclasses:
FastBoard, FastBoard

public abstract class FastBoardBase<T> extends Object
Lightweight packet-based scoreboard API for Bukkit plugins. It can be safely used asynchronously as everything is at packet level.

The project is on GitHub.

Version:
2.0.2
Author:
MrMicky
  • Field Details

    • COLOR_CODES

      protected static final String[] COLOR_CODES
  • Constructor Details

    • FastBoardBase

      protected FastBoardBase(org.bukkit.entity.Player player)
      Creates a new FastBoard.
      Parameters:
      player - the owner of the scoreboard
  • Method Details

    • getTitle

      public T getTitle()
      Get the scoreboard title.
      Returns:
      the scoreboard title
    • updateTitle

      public void updateTitle(T title)
      Update the scoreboard title.
      Parameters:
      title - the new scoreboard title
      Throws:
      IllegalArgumentException - if the title is longer than 32 chars on 1.12 or lower
      IllegalStateException - if delete() was call before
    • getLines

      public List<T> getLines()
      Get the scoreboard lines.
      Returns:
      the scoreboard lines
    • getLine

      public T getLine(int line)
      Get the specified scoreboard line.
      Parameters:
      line - the line number
      Returns:
      the line
      Throws:
      IndexOutOfBoundsException - if the line is higher than size
    • updateLine

      public void updateLine(int line, T text)
      Update a single scoreboard line.
      Parameters:
      line - the line number
      text - the new line text
      Throws:
      IndexOutOfBoundsException - if the line is higher than size() + 1
    • removeLine

      public void removeLine(int line)
      Remove a scoreboard line.
      Parameters:
      line - the line number
    • updateLines

      public void updateLines(T... lines)
      Update all the scoreboard lines.
      Parameters:
      lines - the new lines
      Throws:
      IllegalArgumentException - if one line is longer than 30 chars on 1.12 or lower
      IllegalStateException - if delete() was call before
    • updateLines

      public void updateLines(Collection<T> lines)
      Update the lines of the scoreboard
      Parameters:
      lines - the new scoreboard lines
      Throws:
      IllegalArgumentException - if one line is longer than 30 chars on 1.12 or lower
      IllegalStateException - if delete() was call before
    • getPlayer

      public org.bukkit.entity.Player getPlayer()
      Get the player who has the scoreboard.
      Returns:
      current player for this FastBoard
    • getId

      public String getId()
      Get the scoreboard id.
      Returns:
      the id
    • isDeleted

      public boolean isDeleted()
      Get if the scoreboard is deleted.
      Returns:
      true if the scoreboard is deleted
    • size

      public int size()
      Get the scoreboard size (the number of lines).
      Returns:
      the size
    • delete

      public void delete()
      Delete this FastBoard, and will remove the scoreboard for the associated player if he is online. After this, all uses of updateLines(T...) and updateTitle(T) will throw an IllegalStateException
      Throws:
      IllegalStateException - if this was already call before
    • sendLineChange

      protected abstract void sendLineChange(int score) throws Throwable
      Throws:
      Throwable
    • toMinecraftComponent

      protected abstract Object toMinecraftComponent(T value) throws Throwable
      Throws:
      Throwable
    • serializeLine

      protected abstract String serializeLine(T value)
    • emptyLine

      protected abstract T emptyLine()
    • getScoreByLine

      protected int getScoreByLine(int line)
    • getLineByScore

      protected T getLineByScore(int score)
    • getLineByScore

      protected T getLineByScore(List<T> lines, int score)
    • sendObjectivePacket

      protected void sendObjectivePacket(FastBoardBase.ObjectiveMode mode) throws Throwable
      Throws:
      Throwable
    • sendDisplayObjectivePacket

      protected void sendDisplayObjectivePacket() throws Throwable
      Throws:
      Throwable
    • sendScorePacket

      protected void sendScorePacket(int score, FastBoardBase.ScoreboardAction action) throws Throwable
      Throws:
      Throwable
    • sendTeamPacket

      protected void sendTeamPacket(int score, FastBoardBase.TeamMode mode) throws Throwable
      Throws:
      Throwable
    • sendTeamPacket

      protected void sendTeamPacket(int score, FastBoardBase.TeamMode mode, T prefix, T suffix) throws Throwable
      Throws:
      Throwable