Record Class BanEntry

java.lang.Object
java.lang.Record
me.github.simonplays15.betterbansystem.core.ban.BanEntry
All Implemented Interfaces:
IBanEntry

public record BanEntry(UUID uuid, String name, String source, Date created, Object expires, String reason) extends Record implements IBanEntry
BanEntry represents a single ban entry in a ban system. It implements the IBanEntry interface. This class provides methods to save, remove, retrieve and manipulate ban entries.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    The IBanEntryAdapter class is a TypeAdapter for serializing and deserializing IBanEntry objects using Gson.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BanEntry (UUID uuid, String name, String source, Date created, Object expires, String reason)
    Creates an instance of a BanEntry record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the created record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the expires record component.
    static IBanEntry
    findEntry (UUID targetUUID)
    Finds an entry in the list of all entries by UUID.
    static @NotNull List<IBanEntry>
    Retrieves all ban entries from the database and/or file.
    final int
    Returns a hash code value for this object.
    name()
    Returns the value of the name record component.
    Returns the value of the reason record component.
    static void
    removeEntry (@NotNull IBanEntry entry)
    Removes an entry from the ban list.
    static void
    removeFromJson (UUID targetUUID)
    Removes a specific UUID from a JSON file.
    static void
    Saves an IBanEntry object to a JSON file or a database table.
    Returns the value of the source record component.
    @NotNull String
    Returns the string representation of the BanEntry object.
    uuid()
    Returns the value of the uuid record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BanEntry

      public BanEntry (UUID uuid, String name, String source, Date created, Object expires, String reason)
      Creates an instance of a BanEntry record class.
      Parameters:
      uuid - the value for the uuid record component
      name - the value for the name record component
      source - the value for the source record component
      created - the value for the created record component
      expires - the value for the expires record component
      reason - the value for the reason record component
  • Method Details

    • saveToJson

      public static void saveToJson (IBanEntry entry)
      Saves an IBanEntry object to a JSON file or a database table. If a database is available, the entry is inserted into the "BANNED_PLAYERS_TABLE" table. If a database is not available, the entry is added to a JSON file.
      Parameters:
      entry - The IBanEntry object to be saved.
    • removeEntry

      public static void removeEntry (@NotNull @NotNull IBanEntry entry)
      Removes an entry from the ban list.
      Parameters:
      entry - The ban entry to remove.
    • removeFromJson

      public static void removeFromJson (UUID targetUUID)
      Removes a specific UUID from a JSON file.
      Parameters:
      targetUUID - The UUID to be removed from the JSON file.
    • getAllEntries

      @NotNull public static @NotNull List<IBanEntry> getAllEntries()
      Retrieves all ban entries from the database and/or file.
      Returns:
      A list of IBanEntry objects representing all ban entries.
    • findEntry

      public static IBanEntry findEntry (UUID targetUUID)
      Finds an entry in the list of all entries by UUID.
      Parameters:
      targetUUID - the UUID of the entry to find
      Returns:
      the found IBanEntry, or null if no entry is found
    • toString

      @Contract(pure=true) @NotNull public @NotNull String toString()
      Returns the string representation of the BanEntry object. The format of the string is: "BanEntry{uuid= , name=' ', source=' ', created= , expires= , reason=' '}"
      Specified by:
      toString in class Record
      Returns:
      the string representation of the BanEntry object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals (Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • uuid

      public UUID uuid()
      Returns the value of the uuid record component.
      Specified by:
      uuid in interface IBanEntry
      Returns:
      the value of the uuid record component
    • name

      public String name()
      Returns the value of the name record component.
      Specified by:
      name in interface IBanEntry
      Returns:
      the value of the name record component
    • source

      public String source()
      Returns the value of the source record component.
      Specified by:
      source in interface IBanEntry
      Returns:
      the value of the source record component
    • created

      public Date created()
      Returns the value of the created record component.
      Specified by:
      created in interface IBanEntry
      Returns:
      the value of the created record component
    • expires

      public Object expires()
      Returns the value of the expires record component.
      Specified by:
      expires in interface IBanEntry
      Returns:
      the value of the expires record component
    • reason

      public String reason()
      Returns the value of the reason record component.
      Specified by:
      reason in interface IBanEntry
      Returns:
      the value of the reason record component