Klasse NotesAPI

java.lang.Object
me.kzlyth.api.notes.NotesAPI

public class NotesAPI extends Object
API for managing player notes in Zenith-Mod.

This API provides methods to create, retrieve, search, and delete notes including:

  • Getting notes by player (UUID or name)
  • Getting notes by ID
  • Adding new notes
  • Removing notes by ID
  • Clearing all notes for a player
  • Searching notes by content
  • Getting notes by staff member
  • Getting notes within a time range (days ago)

Database Compatibility: All methods in this API are fully compatible with H2, SQLite, MySQL, and MariaDB databases. The API automatically adapts to the configured database type from the configuration file.

Example usage:


 ZenithAPI api = ZenithAPI.getInstance();
 if (api != null) {
     NotesAPI notesAPI = api.getNotesAPI();
     
     UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
     
     // Get all notes for a player
     notesAPI.getNotes(uuid).thenAccept(notes -> {
         getLogger().info("Player has " + notes.size() + " notes");
         for (Note note : notes) {
             getLogger().info("Note #" + note.getId() + ": " + note.getNote());
         }
     });
     
     // Add a new note
     notesAPI.addNote(uuid, "Player was caught cheating", "Admin").thenAccept(success -> {
         if (success) {
             getLogger().info("Note added successfully");
         }
     });
     
     // Search notes by content
     notesAPI.searchNotesByContent("cheating").thenAccept(results -> {
         getLogger().info("Found " + results.size() + " notes containing 'cheating'");
     });
 }
 
Seit:
1.2.3
Autor:
Zenith-Studios
  • Konstruktordetails

    • NotesAPI

      public NotesAPI(@NotNull @NotNull me.kzlyth.ZenithMod plugin, @NotNull @NotNull ZenithAPI api)
      Constructs a new NotesAPI instance.
      Parameter:
      plugin - The plugin instance
      api - The main API instance
  • Methodendetails

    • getNotes

      @NotNull public @NotNull CompletableFuture<List<me.kzlyth.data.models.Note>> getNotes(@NotNull @NotNull UUID uuid)
      Gets all notes for a player.

      Returns all notes associated with the specified player, ordered by timestamp (most recent first).

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       notesAPI.getNotes(uuid).thenAccept(notes -> {
           getLogger().info("Player has " + notes.size() + " notes");
           for (Note note : notes) {
               getLogger().info("Note #" + note.getId() + ": " + note.getNote());
               getLogger().info("Staff: " + note.getStaffName());
               getLogger().info("Date: " + new Date(note.getTimestamp()));
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with a list of notes
    • getNotes

      @NotNull public @NotNull CompletableFuture<List<me.kzlyth.data.models.Note>> getNotes(@NotNull @NotNull String playerName)
      Gets all notes for a player.

      This is an overloaded method that accepts a player name instead of UUID. The player name will be resolved to a UUID first.

      Example:

      
       notesAPI.getNotes("PlayerName").thenAccept(notes -> {
           getLogger().info("Player has " + notes.size() + " notes");
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with a list of notes, or an empty list if the player doesn't exist
    • getNoteById

      @NotNull public @NotNull CompletableFuture<me.kzlyth.data.models.Note> getNoteById(int noteId)
      Gets a specific note by its ID.

      Example:

      
       notesAPI.getNoteById(123).thenAccept(note -> {
           if (note != null) {
               getLogger().info("Note #" + note.getId() + ": " + note.getNote());
               getLogger().info("Player: " + note.getPlayerName());
               getLogger().info("Staff: " + note.getStaffName());
           } else {
               getLogger().info("Note not found");
           }
       });
       
      Parameter:
      noteId - The note ID to retrieve
      Gibt zurück:
      A CompletableFuture that completes with the note, or null if not found
    • addNote

      @NotNull public @NotNull CompletableFuture<Boolean> addNote(@NotNull @NotNull UUID uuid, @NotNull @NotNull String note, @NotNull @NotNull String staffName)
      Adds a new note for a player.

      Creates a new note entry associated with the specified player.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       notesAPI.addNote(uuid, "Player was caught cheating", "Admin").thenAccept(success -> {
           if (success) {
               getLogger().info("Note added successfully");
           } else {
               getLogger().warning("Failed to add note");
           }
       });
       
      Parameter:
      uuid - The UUID of the target player
      note - The note content
      staffName - The name of the staff member adding the note
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • addNote

      @NotNull public @NotNull CompletableFuture<Boolean> addNote(@NotNull @NotNull String playerName, @NotNull @NotNull String note, @NotNull @NotNull String staffName)
      Adds a new note for a player.

      This is an overloaded method that accepts a player name instead of UUID.

      Example:

      
       notesAPI.addNote("PlayerName", "Player was caught cheating", "Admin").thenAccept(success -> {
           if (success) {
               getLogger().info("Note added successfully");
           }
       });
       
      Parameter:
      playerName - The name of the target player
      note - The note content
      staffName - The name of the staff member adding the note
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • removeNote

      @NotNull public @NotNull CompletableFuture<Boolean> removeNote(int noteId)
      Removes a note by its ID.

      Example:

      
       notesAPI.removeNote(123).thenAccept(success -> {
           if (success) {
               getLogger().info("Note removed successfully");
           } else {
               getLogger().warning("Failed to remove note (note may not exist)");
           }
       });
       
      Parameter:
      noteId - The ID of the note to remove
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • clearNotes

      @NotNull public @NotNull CompletableFuture<Boolean> clearNotes(@NotNull @NotNull UUID uuid)
      Clears all notes for a player.

      Permanently removes all notes associated with the specified player. This action cannot be undone.

      Example:

      
       UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
       notesAPI.clearNotes(uuid).thenAccept(success -> {
           if (success) {
               getLogger().info("All notes cleared for player");
           } else {
               getLogger().warning("Failed to clear notes");
           }
       });
       
      Parameter:
      uuid - The UUID of the player
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • clearNotes

      @NotNull public @NotNull CompletableFuture<Boolean> clearNotes(@NotNull @NotNull String playerName)
      Clears all notes for a player.

      This is an overloaded method that accepts a player name instead of UUID.

      Example:

      
       notesAPI.clearNotes("PlayerName").thenAccept(success -> {
           if (success) {
               getLogger().info("All notes cleared for player");
           }
       });
       
      Parameter:
      playerName - The name of the player
      Gibt zurück:
      A CompletableFuture that completes with true if successful, false otherwise
    • searchNotesByContent

      @NotNull public @NotNull CompletableFuture<List<me.kzlyth.data.models.Note>> searchNotesByContent(@NotNull @NotNull String query)
      Searches notes by content.

      Returns all notes that contain the specified query string in their content. The search is case-insensitive and matches partial strings.

      Example:

      
       notesAPI.searchNotesByContent("cheating").thenAccept(results -> {
           getLogger().info("Found " + results.size() + " notes containing 'cheating'");
           for (Note note : results) {
               getLogger().info("Note #" + note.getId() + ": " + note.getNote());
               getLogger().info("Player: " + note.getPlayerName());
           }
       });
       
      Parameter:
      query - The search query string
      Gibt zurück:
      A CompletableFuture that completes with a list of matching notes
    • getNotesByStaff

      @NotNull public @NotNull CompletableFuture<List<me.kzlyth.data.models.Note>> getNotesByStaff(@NotNull @NotNull String staffName)
      Gets all notes created by a specific staff member.

      Returns all notes where the staff name matches the specified query exactly.

      Example:

      
       notesAPI.getNotesByStaff("Admin").thenAccept(notes -> {
           getLogger().info("Staff member has created " + notes.size() + " notes");
           for (Note note : notes) {
               getLogger().info("Note #" + note.getId() + " for " + note.getPlayerName());
           }
       });
       
      Parameter:
      staffName - The name of the staff member
      Gibt zurück:
      A CompletableFuture that completes with a list of notes created by the staff member
    • getNotesSinceDays

      @NotNull public @NotNull CompletableFuture<List<me.kzlyth.data.models.Note>> getNotesSinceDays(int days)
      Gets all notes created within the last N days.

      Returns all notes that were created within the specified number of days.

      Example:

      
       notesAPI.getNotesSinceDays(7).thenAccept(notes -> {
           getLogger().info("Found " + notes.size() + " notes created in the last 7 days");
           for (Note note : notes) {
               getLogger().info("Note #" + note.getId() + ": " + note.getNote());
               getLogger().info("Created: " + new Date(note.getTimestamp()));
           }
       });
       
      Parameter:
      days - The number of days to look back
      Gibt zurück:
      A CompletableFuture that completes with a list of notes created within the time range