Interface BanProvider
- All Superinterfaces:
AccessProvider
- All Known Implementing Classes:
HytaleBanProvider
The server runs a HytaleBanProvider, which stores the bans in a file. To keep the bans
somewhere else, such as a database that several servers share, implement this interface and
install it with AccessControlModule.setBanProvider(BanProvider).
A method of this interface can block on the storage. Call it off the world thread.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the ban and stores it.A ban that has run out, asBan.isInEffect()reports, counts as no ban.getBans()default CompletableFuture<Optional<Message>> getDisconnectReason(UUID uuid) booleanA ban that has run out, asBan.isInEffect()reports, counts as no ban.default voidload()Reads the bans from storage.booleanRemoves any ban on the player and stores the change.default voidsave()Writes the bans to storage.
-
Field Details
-
NO_REASON
-
UNDESCRIBED_BAN
-
-
Method Details
-
hasBan
A ban that has run out, asBan.isInEffect()reports, counts as no ban.This asks whether the player is kept out, so it counts a ban the provider holds but cannot describe, which
getBan(UUID)returns nothing for.- Parameters:
uuid- theUUIDof the player to check- Returns:
trueif the player has a ban, or an entry that denies them
-
getBan
A ban that has run out, asBan.isInEffect()reports, counts as no ban.A provider that holds a ban it cannot describe returns
nullhere andtruefromhasBan(UUID), so use that to ask whether a player is kept out.- Parameters:
uuid- theUUIDof the player to look up- Returns:
- the ban on the player, or
nullif the player has none this provider can read
-
addBan
Adds the ban and stores it. A player who already has a ban keeps it, unless that ban has run out, in which case the new ban replaces it.A return of
truemeans the ban is stored. If the store fails, throw, and leave the provider as it was.- Parameters:
ban- the ban to add- Returns:
trueif the ban was added
-
removeBan
-
getBans
- Returns:
- a snapshot of every ban that is in effect and that this provider can read
-
load
default void load()Reads the bans from storage. The module calls this when the server starts, and again on a provider that replaces this one. -
save
default void save()Writes the bans to storage. The module calls this when the server stops, and again on this provider when another replaces it.This is a flush of state that is already stored, never the point at which a change becomes durable. A provider stores each change as that change is made, so it does not need to do anything here.
-
getDisconnectReason
Description copied from interface:AccessProviderReturns anOptionalof typeMessagethat provides a disconnect reason.If the
Optionalcontains aMessage, the connection will be terminated with that message as the reason. An emptyOptionalwill be ignored and the connection proceeds.- Specified by:
getDisconnectReasonin interfaceAccessProvider- Parameters:
uuid- TheUUIDof the player to check.- Returns:
- the disconnect reason,
Optional.empty()for no reason.
-