Record Class IPBanEntry
java.lang.Object
java.lang.Record
me.github.simonplays15.betterbansystem.core.ban.IPBanEntry
- All Implemented Interfaces:
IIPBanEntry
public record IPBanEntry(String ip, String source, Date created, Object expires, String reason)
extends Record
implements IIPBanEntry
Represents an entry for an IP ban.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The IIPBanEntryAdapter class is a Gson TypeAdapter for serializing and deserializing IIPBanEntry objects. -
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 IIPBanEntry
Finds an IP ban entry given the IP address.static @NotNull List<IIPBanEntry>
Retrieves all IP ban entries.final int
hashCode()
Returns a hash code value for this object.ip()
Returns the value of theip
record component.reason()
Returns the value of thereason
record component.static void
removeEntry
(@NotNull IIPBanEntry entry) Removes an entry from the IP ban list.static void
removeFromJson
(String ipAddress) Removes an entry from a JSON file based on the provided IP address.static void
saveToJson
(IIPBanEntry entry) Saves the given IP ban entry to a JSON file or a database.source()
Returns the value of thesource
record component.@NotNull String
toString()
Returns a string representation of the IPBanEntry object.
-
Constructor Details
-
IPBanEntry
Creates a new IPBanEntry object and checks if the associated file exists. If the file does not exist, it will attempt to create a new file and output a log message if successful.- Parameters:
file
- The associated file for this IPBanEntry.
-
-
Method Details
-
saveToJson
Saves the given IP ban entry to a JSON file or a database.- Parameters:
entry
- The IP ban entry to save.
-
removeEntry
Removes an entry from the IP ban list.- Parameters:
entry
- The IP ban entry to be removed.
-
removeFromJson
Removes an entry from a JSON file based on the provided IP address.- Parameters:
ipAddress
- The IP address of the entry to be removed.
-
getAllEntries
Retrieves all IP ban entries.- Returns:
- A list of IPBanEntry objects representing the ban entries.
-
findEntry
Finds an IP ban entry given the IP address.- Parameters:
ipAddress
- The IP address to search for.- Returns:
- The IP ban entry matching the given IP address, or null if no match is found.
-
toString
Returns a string representation of the IPBanEntry 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. -
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)
. -
ip
Returns the value of theip
record component.- Specified by:
ip
in interfaceIIPBanEntry
- Returns:
- the value of the
ip
record component
-
source
Returns the value of thesource
record component.- Specified by:
source
in interfaceIIPBanEntry
- Returns:
- the value of the
source
record component
-
created
Returns the value of thecreated
record component.- Specified by:
created
in interfaceIIPBanEntry
- Returns:
- the value of the
created
record component
-
expires
Returns the value of theexpires
record component.- Specified by:
expires
in interfaceIIPBanEntry
- Returns:
- the value of the
expires
record component
-
reason
Returns the value of thereason
record component.- Specified by:
reason
in interfaceIIPBanEntry
- Returns:
- the value of the
reason
record component
-