NoteAPI
The Note functions adds a noteboard function to the player's scoreboard, allowing for notes to appear for a set duration before returning their view to the regular scoreboard (or none, if they don't have one visible).
Imports:
import com.adamantdreamer.ui.noteboard.Note; import com.adamantdreamer.ui.noteboard.Unique;
The following creates a basic note, and will appear up for 5 seconds once shown to a player:
Note hello = new Note("Hello", null, Note.Priority.NORMAL, 5); hello.add("This is a test."); hello.add("This is line 2."); hello.show(Player);
Notes work on a queue automatically. If a note from any plugin is already being viewed by a particular player, the new one will enter a queue based on it's priority (-100 to 100, default priorities are in the Note.Priority), with the highest priority appearing first. Once the note appears, the duration will start before closing the note for that player and showing them the next one. A duration of 0 means a note will stay displayed until note.close(); is called.
The null value in this example above is a Unique. Unique's are not required, but can be used to make sure no two notes of the same type don't appear in the same player's queue. In the following example, the second note would override the first one (either as the current visible one, or inside the queue if another was visible). If the boolean inside the unique was false, the new note would just be ignored as long as the original was in the queue.
Unique unique1 = new Unique(true);<i> Note note1 = new Note("Hello", unique1, Note.Priority.NORMAL, 20); Note note2 = new Note("Hello 2", unique1, Note.Priority.NORMAL, 20); note1.show(player); note2.show(player);
Notes can also be added with variables, that can be changed without making adjustments to the individual lines:
Note note3 = new Note("Test", null, Note.Priority.HIGH, 30); note3.add("This is a test."); note3.addVar("{Hello} World!", "Greetings"); note3.show(player); // This would show up as "Hello World!" to the player. If you were to wait 10 seconds, and run the following code: note3.setVar("Greetings", "Goodby"); // it would change that line to "Goodby World!", updating the display to anyone currently viewing the note, // anyone who has the note in their queue, and anyone who is shown the note later.
Working with standard scoreboards:
- Notes will temporally override the player's current scoreboard. Once the last note in their queue closes, their prior scoreboard will reappear.
- If the scoreboard is changed or shown to a player while they are viewing a note, it may change to the scoreboard for a second before their note re-appears. The new scoreboard will be stored as the player's default and shown once the last note closes.
Comments