LogoLogo
JavaDocsVersions
  • Introduction
  • Getting started
    • Dependencies
    • Your first server
  • Feature
    • Adventure
    • Player capabilities
    • Events
      • Implementation
      • Server list ping
    • Items
    • Entities
      • AI
    • Tags
    • Schedulers
    • Commands
    • Inventories
    • Player UUID
    • Player skin
    • Permissions
    • Advancements
    • Map rendering
      • GLFWMapRendering
    • Query system
    • Open to LAN
  • Thread Architecture
    • Thread safety in the JVM
    • Acquirable API
      • The inside
  • World
    • Instances
    • Chunk management
      • Anvil Loader
    • Blocks
    • Coordinates
    • Generation
    • Batch
  • Extension System
    • Extensions
Powered by GitBook
On this page
  • Sidebars (Scoreboards)
  • Sidebar Line
  • Notifications

Was this helpful?

Export as PDF
  1. Feature

Player capabilities

PreviousAdventureNextEvents

Last updated 1 year ago

Was this helpful?

Minestom features a number of interaction methods for players. Many of them are described below, however this list is not exhaustive.

It is worth reviewing the before this, because these systems depend heavily on Component.

Sidebars (Scoreboards)

Sidebars can be used to display up to 16 lines on a scoreboard for the player. They are created given a title as follows:

Sidebar#<init>(Component /* title */)

Sidebar titles do not support JSON chat components, however the provided component will be serialized using Adventure's legacy serializer.

Once created, a scoreboard can be added and removed from players as follows:

Sidebar#addViewer(Player);
Sidebar#removeViewer(Player);

Sidebar Line

Lines on a sidebar are made up of ScoreboardLines. They render on the scoreboard in order of their line number (score), where the vertically highest line represents the highest line number (score). If two lines have the same line number (score), they will be sorted alphabetically.

ScoreboardLines can be created using their constructor:

Sidebar.ScoreboardLine#<init>(String /* unique id*/, Component /* content */, int /* line */);

// For example
Sidebar.ScoreboardLine line = new Sidebar.ScoreboardLine(
        "some_line_0",
        Component.text("Hello, Sidebar!", NamedTextColor.RED),
        0
);

Once created, scoreboard lines may be added to Sidebars as follows:

Sidebar#createLine(Sidebar.ScoreboardLine);

Lines are indexed by their unique id, and can be modified with it:

Sidebar#getLine(String /* unique id */);
Sidebar#updateLineContent(String /* unique id */, Component /* new content */);
Sidebar#updateLineScore(String /* unique id */, Int /* new score */);

Notifications

Notifications are a system to send advancement completion toasts to a player as a form of communication.

Notification#<init>(Component /* title */, FrameType, ItemStack /* icon */);

// For example
Notification notification = new Notification(
        Component.text("Hello, Notifications!", NamedTextColor.GREEN),
        FrameType.GOAL,
        ItemStack.of(Material.GOLD_INGOT)
);

To send the notification, use one of the static methods on NotificationCenter:

NotificationCenter.send(Notification, Player);
NotificationCenter.send(Notification, Collection<Player>);

The example renders as the following:

They are a wrapper around Advancement, so you do not need to create any advancements to use them, just a Notification. See the page for more information on advancements.

Adventure API
Advancements