Interface PunishmentSelector
public interface PunishmentSelector
A starting point for selecting punishments with specific details from the database.
This provides a magnificent API for efficient database queries which is able to reach
astounding and unimaginable heights through dynamic query construction.
It is possible to select active and historical punishments. See
It is possible to select active and historical punishments. See
space.arim.libertybans.api.punish for a description of active and
historical punishments.- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescriptionspace.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getActivePunishmentById(long id) Gets an active punishment matching a specific ID, if a punishment with such ID exists.space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getActivePunishmentByIdAndType(long id, PunishmentType type) Gets an active punishment matching a specific ID and type, if one exists with matching type and ID.default space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getApplicablePunishment(UUID uuid, NetworkAddress address, PunishmentType type) Gets the first punishment, of a certain type, which is applicable to a UUID and IP address, where the UUID and address typically represent a connected player.space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getCachedMute(UUID uuid, NetworkAddress address) Gets a cached mute for an online player, including the player's UUID and address.space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getHistoricalPunishmentById(long id) Gets a historical punishment matching a specific ID, if a punishment with such ID exists.space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getHistoricalPunishmentByIdAndType(long id, PunishmentType type) Gets a historical punishment matching a specific ID and type, if a punishment with such ID and typeexists.Begins creating a selection order to retrieve punishments.default SelectionByApplicabilityBuilderselectionByApplicabilityBuilder(UUID uuid, InetAddress address) Begins creating a selection to retrieve punishments applicable to a certain user represented by a UUID and current IP address.selectionByApplicabilityBuilder(UUID uuid, NetworkAddress address) Begins creating a selection to retrieve punishments applicable to a certain user represented by a UUID and current IP address.
-
Method Details
-
selectionBuilder
SelectionOrderBuilder selectionBuilder()Begins creating a selection order to retrieve punishments. This may be used to retrieve punishments for a certain victim, group of victims, or all victims except a list of excluded.- Returns:
- a selection order builder
-
selectionByApplicabilityBuilder
Begins creating a selection to retrieve punishments applicable to a certain user represented by a UUID and current IP address.
Applicability is synonymous with enforceability, taking into account address strictness. For example, if a ban would prevent a player from joining the server, the ban is said to be applicable to the player's UUID and IP. It may be, the player's IP is banned, the player's UUID is banned, or the player has played on a banned IP and that IP is banned while strict address enforcement is enabled.
By default, the server's configured address strictness is used, but the caller can useSelectionByApplicabilityBuilder.addressStrictness(AddressStrictness)to change the setting.- Parameters:
uuid- the uuid of the user for whom to select applicable punishmentsaddress- the current or most recent address of the same user- Returns:
- a selection by applicability builder
-
selectionByApplicabilityBuilder
default SelectionByApplicabilityBuilder selectionByApplicabilityBuilder(UUID uuid, InetAddress address) Begins creating a selection to retrieve punishments applicable to a certain user represented by a UUID and current IP address.
Applicability is synonymous with enforceability, taking into account address strictness. For example, if a ban would prevent a player from joining the server, the ban is said to be applicable to the player's UUID and IP. It may be, the player's IP is banned, the player's UUID is banned, or the player has played on a banned IP and that IP is banned while strict address enforcement is enabled.
For maximum accuracy, the UUID and IP address pair should be taken from an actual user who has logged on before. Due to the specifics of how applicability is computed, some punishments may not be considered if the UUID and IP address have not been recorded in account history.
By default, the server's configured address strictness is used, but the caller can useSelectionByApplicabilityBuilder.addressStrictness(AddressStrictness)to change the setting.- Parameters:
uuid- the uuid of the user for whom to select applicable punishmentsaddress- the current or most recent address of the same user- Returns:
- a selection by applicability builder
-
getActivePunishmentById
space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getActivePunishmentById(long id) Gets an active punishment matching a specific ID, if a punishment with such ID exists.
When the type of the punishment is known,getActivePunishmentByIdAndType(long, PunishmentType)should be preferred.- Parameters:
id- the punishment ID- Returns:
- a future which yields the active punishment with the ID, if there is one
-
getActivePunishmentByIdAndType
space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getActivePunishmentByIdAndType(long id, PunishmentType type) Gets an active punishment matching a specific ID and type, if one exists with matching type and ID.
UnlikegetActivePunishmentById(long), this method may be more efficient when the type of the punishment is known beforehand.- Parameters:
id- the punishment IDtype- the punishment type- Returns:
- a future which yields the active punishment with the ID and type, if there is one
-
getHistoricalPunishmentById
space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getHistoricalPunishmentById(long id) Gets a historical punishment matching a specific ID, if a punishment with such ID exists.- Parameters:
id- the punishment ID- Returns:
- a future which yields the historical punishment with the ID, if there is one
-
getHistoricalPunishmentByIdAndType
space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getHistoricalPunishmentByIdAndType(long id, PunishmentType type) Gets a historical punishment matching a specific ID and type, if a punishment with such ID and typeexists.- Parameters:
id- the punishment IDtype- the punishment type- Returns:
- a future which yields the historical punishment with the ID, if there is one
-
getApplicablePunishment
default space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getApplicablePunishment(UUID uuid, NetworkAddress address, PunishmentType type) Gets the first punishment, of a certain type, which is applicable to a UUID and IP address, where the UUID and address typically represent a connected player.
SeeselectionByApplicabilityBuilder(UUID, NetworkAddress)for a description of applicability.
If multiple punishments are applicable, the one with the latest end date is returned.- Parameters:
uuid- the player's UUIDaddress- the player's current addresstype- the punishment type- Returns:
- a future which yields the first applicable punishment for the id and address, if there is one
-
getCachedMute
space.arim.omnibus.util.concurrent.ReactionStage<Optional<Punishment>> getCachedMute(UUID uuid, NetworkAddress address) Gets a cached mute for an online player, including the player's UUID and address.
The mute will be applicable to the combination of UUID and address, seegetApplicablePunishment(UUID, NetworkAddress, PunishmentType)for a description of applicability.
If the mute (or its absence) is cached, a completed future is returned. On the certain server platforms where chat occurs on the main thread, it is guaranteed a cached result is available.- Parameters:
uuid- the player's uuidaddress- the player's current address- Returns:
- a future yielding the player's applicable mute if present
-