Package fr.mrmicky.fastboard
Class FastBoardBase<T>
java.lang.Object
fr.mrmicky.fastboard.FastBoardBase<T>
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.1.2
- Author:
- MrMicky
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFastBoardBase(org.bukkit.entity.Player player) Creates a new FastBoard. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGet if the server supports custom scoreboard scores (1.20.3+ servers only).voiddelete()Delete this FastBoard, and will remove the scoreboard for the associated player if he is online.protected abstract TgetId()Get the scoreboard id.getLine(int line) Get the specified scoreboard line.protected TgetLineByScore(int score) protected TgetLineByScore(List<T> lines, int score) getLines()Get the scoreboard lines.org.bukkit.entity.PlayerGet the player who has the scoreboard.getScore(int line) Get how a specific line's score is displayed.protected intgetScoreByLine(int line) getTitle()Get the scoreboard title.booleanGet if the scoreboard is deleted.voidremoveLine(int line) Remove a scoreboard line.voidremoveScore(int line) Reset a line's score back to default (blank).protected voidprotected abstract voidsendLineChange(int score) protected voidprotected voidsendScorePacket(int score, FastBoardBase.ScoreboardAction action) protected voidsendTeamPacket(int score, FastBoardBase.TeamMode mode) protected voidsendTeamPacket(int score, FastBoardBase.TeamMode mode, T prefix, T suffix) protected abstract StringserializeLine(T value) intsize()Get the scoreboard size (the number of lines).protected abstract ObjecttoMinecraftComponent(T value) voidupdateLine(int line, T text) Update a single scoreboard line.voidupdateLine(int line, T text, T scoreText) Update a single scoreboard line including how its score is displayed.voidupdateLines(Collection<T> lines) Update the lines of the scoreboardvoidupdateLines(Collection<T> lines, Collection<T> scores) Update the lines and how their score is displayed on the scoreboard.voidupdateLines(T... lines) Update all the scoreboard lines.voidupdateScore(int line, T text) Update how a specified line's score is displayed on the scoreboard.voidupdateScores(Collection<T> texts) Update how all lines' scores are displayed.voidupdateScores(T... texts) Update how all lines' scores are displayed.voidupdateTitle(T title) Update the scoreboard title.
-
Field Details
-
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
Get the scoreboard title.- Returns:
- the scoreboard title
-
updateTitle
Update the scoreboard title.- Parameters:
title- the new scoreboard title- Throws:
IllegalArgumentException- if the title is longer than 32 chars on 1.12 or lowerIllegalStateException- ifdelete()was call before
-
getLines
Get the scoreboard lines.- Returns:
- the scoreboard lines
-
getLine
Get the specified scoreboard line.- Parameters:
line- the line number- Returns:
- the line
- Throws:
IndexOutOfBoundsException- if the line is higher thansize
-
getScore
Get how a specific line's score is displayed. On 1.20.2 or below, the value returned isn't used.- Parameters:
line- the line number- Returns:
- the text of how the line is displayed
- Throws:
IndexOutOfBoundsException- if the line is higher thansize
-
updateLine
Update a single scoreboard line.- Parameters:
line- the line numbertext- the new line text- Throws:
IndexOutOfBoundsException- if the line is higher thansize() + 1
-
updateLine
Update a single scoreboard line including how its score is displayed. The score will only be displayed on 1.20.3 and higher.- Parameters:
line- the line numbertext- the new line textscoreText- the new line's score, if null will not change current value- Throws:
IndexOutOfBoundsException- if the line is higher thansize() + 1
-
removeLine
public void removeLine(int line) Remove a scoreboard line.- Parameters:
line- the line number
-
updateLines
Update all the scoreboard lines.- Parameters:
lines- the new lines- Throws:
IllegalArgumentException- if one line is longer than 30 chars on 1.12 or lowerIllegalStateException- ifdelete()was call before
-
updateLines
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 lowerIllegalStateException- ifdelete()was call before
-
updateLines
Update the lines and how their score is displayed on the scoreboard. The scores will only be displayed for servers on 1.20.3 and higher.- Parameters:
lines- the new scoreboard linesscores- the set for how each line's score should be, if null will fall back to default (blank)- Throws:
IllegalArgumentException- if one line is longer than 30 chars on 1.12 or lowerIllegalArgumentException- if lines and scores are not the same sizeIllegalStateException- ifdelete()was call before
-
updateScore
Update how a specified line's score is displayed on the scoreboard. A null value will reset the displayed text back to default. The scores will only be displayed for servers on 1.20.3 and higher.- Parameters:
line- the line numbertext- the text to be displayed as the score. if null, no score will be displayed- Throws:
IllegalArgumentException- if the line number is not in rangeIllegalStateException- ifdelete()was call before
-
removeScore
public void removeScore(int line) Reset a line's score back to default (blank). The score will only be displayed for servers on 1.20.3 and higher.- Parameters:
line- the line number- Throws:
IllegalArgumentException- if the line number is not in rangeIllegalStateException- ifdelete()was call before
-
updateScores
Update how all lines' scores are displayed. A value of null will reset the displayed text back to default. The scores will only be displayed for servers on 1.20.3 and higher.- Parameters:
texts- the set of texts to be displayed as the scores- Throws:
IllegalArgumentException- if the size of the texts does not match the current size of the boardIllegalStateException- ifdelete()was call before
-
updateScores
Update how all lines' scores are displayed. A null value will reset the displayed text back to default (blank). Only available on 1.20.3+ servers.- Parameters:
texts- the set of texts to be displayed as the scores- Throws:
IllegalArgumentException- if the size of the texts does not match the current size of the boardIllegalStateException- ifdelete()was call before
-
getPlayer
public org.bukkit.entity.Player getPlayer()Get the player who has the scoreboard.- Returns:
- current player for this FastBoard
-
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
-
customScoresSupported
public boolean customScoresSupported()Get if the server supports custom scoreboard scores (1.20.3+ servers only).- Returns:
- true if the server supports custom scores
-
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 ofupdateLines(T...)andupdateTitle(T)will throw anIllegalStateException- Throws:
IllegalStateException- if this was already call before
-
sendLineChange
- Throws:
Throwable
-
toMinecraftComponent
- Throws:
Throwable
-
serializeLine
-
emptyLine
-
getScoreByLine
protected int getScoreByLine(int line) -
getLineByScore
-
getLineByScore
-
sendObjectivePacket
- Throws:
Throwable
-
sendDisplayObjectivePacket
- Throws:
Throwable
-
sendScorePacket
- Throws:
Throwable
-
sendTeamPacket
- Throws:
Throwable
-
sendTeamPacket
protected void sendTeamPacket(int score, FastBoardBase.TeamMode mode, T prefix, T suffix) throws Throwable - Throws:
Throwable
-