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 classThe IIPBanEntryAdapter class is a Gson TypeAdapter for serializing and deserializing IIPBanEntry objects. -
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 IIPBanEntryFinds an IP ban entry given the IP address.static @NotNull List<IIPBanEntry>Retrieves all IP ban entries.final inthashCode()Returns a hash code value for this object.ip()Returns the value of theiprecord component.reason()Returns the value of thereasonrecord component.static voidremoveEntry(@NotNull IIPBanEntry entry) Removes an entry from the IP ban list.static voidremoveFromJson(String ipAddress) Removes an entry from a JSON file based on the provided IP address.static voidsaveToJson(IIPBanEntry entry) Saves the given IP ban entry to a JSON file or a database.source()Returns the value of thesourcerecord component.@NotNull StringtoString()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 theiprecord component.- Specified by:
ipin interfaceIIPBanEntry- Returns:
- the value of the
iprecord component
-
source
Returns the value of thesourcerecord component.- Specified by:
sourcein interfaceIIPBanEntry- Returns:
- the value of the
sourcerecord component
-
created
Returns the value of thecreatedrecord component.- Specified by:
createdin interfaceIIPBanEntry- Returns:
- the value of the
createdrecord component
-
expires
Returns the value of theexpiresrecord component.- Specified by:
expiresin interfaceIIPBanEntry- Returns:
- the value of the
expiresrecord component
-
reason
Returns the value of thereasonrecord component.- Specified by:
reasonin interfaceIIPBanEntry- Returns:
- the value of the
reasonrecord component
-