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 class
The 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 thecreated
record component.final boolean
Indicates whether some other object is "equal to" this one.expires()
Returns the value of theexpires
record component.static IBanEntry
Finds an entry in the list of all entries by UUID.Retrieves all ban entries from the database and/or file.final int
hashCode()
Returns a hash code value for this object.name()
Returns the value of thename
record component.reason()
Returns the value of thereason
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
saveToJson
(IBanEntry entry) Saves an IBanEntry object to a JSON file or a database table.source()
Returns the value of thesource
record component.@NotNull String
toString()
Returns the string representation of the BanEntry object.uuid()
Returns the value of theuuid
record component.
-
Constructor Details
-
BanEntry
public BanEntry(UUID uuid, String name, String source, Date created, Object expires, String reason) Creates an instance of aBanEntry
record class.- Parameters:
uuid
- the value for theuuid
record componentname
- the value for thename
record componentsource
- the value for thesource
record componentcreated
- the value for thecreated
record componentexpires
- the value for theexpires
record componentreason
- the value for thereason
record 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 theuuid
record component. -
name
Returns the value of thename
record component. -
source
Returns the value of thesource
record component. -
created
Returns the value of thecreated
record component. -
expires
Returns the value of theexpires
record component. -
reason
Returns the value of thereason
record component.
-