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 ClassesModifier and TypeClassDescriptionstatic classThe IBanEntryAdapter class is a TypeAdapter for serializing and deserializing IBanEntry objects using Gson. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreated()Returns the value of thecreatedrecord component.final booleanIndicates whether some other object is "equal to" this one.expires()Returns the value of theexpiresrecord component.static IBanEntryFinds an entry in the list of all entries by UUID.Retrieves all ban entries from the database and/or file.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.reason()Returns the value of thereasonrecord component.static voidremoveEntry(@NotNull IBanEntry entry) Removes an entry from the ban list.static voidremoveFromJson(UUID targetUUID) Removes a specific UUID from a JSON file.static voidsaveToJson(IBanEntry entry) Saves an IBanEntry object to a JSON file or a database table.source()Returns the value of thesourcerecord component.@NotNull StringtoString()Returns the string representation of the BanEntry object.uuid()Returns the value of theuuidrecord component.
-
Constructor Details
-
BanEntry
public BanEntry(UUID uuid, String name, String source, Date created, Object expires, String reason) Creates an instance of aBanEntryrecord class.- Parameters:
uuid- the value for theuuidrecord componentname- the value for thenamerecord componentsource- the value for thesourcerecord componentcreated- the value for thecreatedrecord componentexpires- the value for theexpiresrecord componentreason- the value for thereasonrecord component
-
-
Method Details
-
saveToJson
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
Removes an entry from the ban list.- Parameters:
entry- The ban entry to remove.
-
removeFromJson
Removes a specific UUID from a JSON file.- Parameters:
targetUUID- The UUID to be removed from the JSON file.
-
getAllEntries
Retrieves all ban entries from the database and/or file.- Returns:
- A list of IBanEntry objects representing all ban entries.
-
findEntry
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
Returns the string representation of the BanEntry object. The format of the string is: "BanEntry{uuid=, name=' ', source=' ', created= , expires= , reason=' '}" -
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. -
equals
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 withObjects::equals(Object,Object). -
uuid
Returns the value of theuuidrecord component. -
name
Returns the value of thenamerecord component. -
source
Returns the value of thesourcerecord component. -
created
Returns the value of thecreatedrecord component. -
expires
Returns the value of theexpiresrecord component. -
reason
Returns the value of thereasonrecord component.
-