Sidebar is the base interface implemented by both PlayerSidebar and SharedSidebar. It provides the methods common to all sidebar types — managing the title and lines, controlling visibility, checking the sidebar type, and destroying it when you are done. When you have a Sidebar reference of unknown type, use the type-checking and cast helpers to work with it safely.
Title and lines
| Method | Returns | Description |
|---|---|---|
getTitle() | String | Current sidebar title |
setTitle(String title) | void | Update the sidebar title |
setLine(int line, String text) | void | Set the text at a line index (0–14) |
getLine(int line) | String (nullable) | Get text at a line index, or null |
removeLine(int line) | void | Remove a specific line |
clearLines() | void | Remove all lines |
0 to 14, giving a maximum of 15 lines.
Visibility
| Method | Returns | Description |
|---|---|---|
canView() | boolean | Whether the sidebar is allowed to be shown |
canView(boolean) | void | Enable or disable the sidebar from being shown |
isBeingViewed() | boolean | Whether the sidebar is currently visible to any player |
hasPlayer(Player) | boolean | Whether the given player is associated with this sidebar |
Type checking
| Method | Returns | Description |
|---|---|---|
isPlayerSidebar() | boolean | True if this is a PlayerSidebar |
isSharedSidebar() | boolean | True if this is a SharedSidebar |
asPlayerSidebar() | Optional<PlayerSidebar> | Cast helper |
asSharedSidebar() | Optional<SharedSidebar> | Cast helper |
Lifecycle
| Method | Returns | Description |
|---|---|---|
remove() | void | Permanently destroy this sidebar |
isRemoved() | boolean | Whether remove() has been called |