Class HytaleBanProvider
- All Implemented Interfaces:
AccessProvider, BanProvider
BanProvider that stores the bans in a JSON file.- Since:
- 06.08.2016
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe file the server keeps its bans in unless the configuration names another.Fields inherited from interface BanProvider
NO_REASON, UNDESCRIBED_BAN -
Constructor Summary
ConstructorsConstructorDescriptionHytaleBanProvider(Path path) Creates a provider for the ban list in the given file. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the ban and stores it.A ban that has run out, asBan.isInEffect()reports, counts as no ban.getBans()getDisconnectReason(UUID uuid) booleanA ban that has run out, asBan.isInEffect()reports, counts as no ban.voidload()Reads the bans from storage.booleanApplies the change and stores it.booleanRemoves any ban on the player and stores the change.voidsave()Writes the bans to storage.Methods inherited from class BlockingDiskFile
syncLoad, syncSave
-
Field Details
-
BAN_FILE_PATH
The file the server keeps its bans in unless the configuration names another.- See Also:
-
-
Constructor Details
-
HytaleBanProvider
Creates a provider for the ban list in the given file.The server already runs one over the file its configuration names. Get it from
AccessControlModule.getBanProvider(). Two providers over one file each hold their own copy of it, so the one that saves last discards the bans of the other.- Parameters:
path- the file to store the bans in
-
-
Method Details
-
hasBan
Description copied from interface:BanProviderA 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
BanProvider.getBan(UUID)returns nothing for.- Specified by:
hasBanin interfaceBanProvider- Parameters:
uuid- theUUIDof the player to check- Returns:
trueif the player has a ban, or an entry that denies them
-
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- Specified by:
getDisconnectReasonin interfaceBanProvider- Parameters:
uuid- TheUUIDof the player to check.- Returns:
- the disconnect reason,
Optional.empty()for no reason.
-
getBan
Description copied from interface:BanProviderA ban that has run out, asBan.isInEffect()reports, counts as no ban.A provider that holds a ban it cannot describe returns
nullhere andtruefromBanProvider.hasBan(UUID), so use that to ask whether a player is kept out.- Specified by:
getBanin interfaceBanProvider- 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
Description copied from interface:BanProviderAdds 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.- Specified by:
addBanin interfaceBanProvider- Parameters:
ban- the ban to add- Returns:
trueif the ban was added
-
removeBan
Description copied from interface:BanProviderRemoves any ban on the player and stores the change.A return of
truemeans the removal is stored. If the store fails, throw, and leave the provider as it was.- Specified by:
removeBanin interfaceBanProvider- Parameters:
uuid- theUUIDof the player to unban- Returns:
trueif the player had a ban
-
getBans
- Specified by:
getBansin interfaceBanProvider- Returns:
- a snapshot of every ban that is in effect and that this provider can read
-
load
public void load()Description copied from interface:BanProviderReads the bans from storage. The module calls this when the server starts, and again on a provider that replaces this one.- Specified by:
loadin interfaceBanProvider
-
save
public void save()Description copied from interface:BanProviderWrites 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.
- Specified by:
savein interfaceBanProvider
-
modify
Applies the change and stores it. If the store fails, the bans go back to what they were and the failure reaches the caller, so a change is either stored or dropped, never held in memory alone.- Parameters:
function- makes the change and reports whether it changed anything. A return ofnullcounts as no change, and a throw puts the bans back as well.- Returns:
trueif the change was made and stored
-