Interface BanManager


public interface BanManager
A service that manages bans.
Since:
0.1.0
  • Method Details

    • find

      @Contract(pure=true) Optional<BanEntry.Profile> find(UUID uuid)
      Gets the active ban on a player identity.

      An expired entry must not be returned; implementations are free to discard it.

      Parameters:
      uuid - the player identity
      Returns:
      the active ban, or empty when nothing bans the identity
      Since:
      0.1.0
    • find

      @Contract(pure=true) Optional<BanEntry.Address> find(InetAddress address)
      Gets the active ban on a client address.

      An expired entry must not be returned; implementations are free to discard it.

      Parameters:
      address - the client address
      Returns:
      the active ban, or empty when nothing bans the address
      Since:
      0.1.0
    • findByName

      @Contract(pure=true) Optional<BanEntry> findByName(String name)
      Gets the active ban recorded under a name, matched case-insensitively.

      Only entries carrying a recorded name can match, so this never resolves an address.

      Parameters:
      name - the player name
      Returns:
      the active ban, or empty
      Since:
      0.1.0
    • findAny

      @Contract(pure=true) default Optional<BanEntry> findAny(UUID uuid, @Nullable InetAddress address)
      Gets whatever bans a connecting player, whether that is their identity or the address they connect from.
      Parameters:
      uuid - the player identity
      address - the address the client connects from, or null when unknown
      Returns:
      the active ban, or empty when the player may connect
      Since:
      0.1.0
    • isBanned

      @Contract(pure=true) default boolean isBanned(UUID uuid)
      Checks whether a player identity is currently banned.
      Parameters:
      uuid - the player identity
      Returns:
      true when the identity is banned
      Since:
      0.1.0
    • isBanned

      @Contract(pure=true) default boolean isBanned(InetAddress address)
      Checks whether a client address is currently banned.
      Parameters:
      address - the client address
      Returns:
      true when the address is banned
      Since:
      0.1.0
    • ban

      boolean ban(BanEntry entry)
      Records a ban, replacing any existing entry for the same target.
      Parameters:
      entry - the ban to record
      Returns:
      true when the target was not already banned
      Since:
      0.1.0
    • pardon

      boolean pardon(UUID uuid)
      Lifts the ban on a player identity.
      Parameters:
      uuid - the player identity
      Returns:
      true when a ban was actually lifted
      Since:
      0.1.0
    • pardon

      boolean pardon(InetAddress address)
      Lifts the ban on a client address.
      Parameters:
      address - the client address
      Returns:
      true when a ban was actually lifted
      Since:
      0.1.0
    • bans

      @Contract(pure=true) Stream<BanEntry> bans()
      Gets the active bans.
      Returns:
      the bans, most recently issued first; expired entries are excluded
      Since:
      0.1.0
    • profileBans

      @Contract(pure=true) default Stream<BanEntry.Profile> profileBans()
      Gets the active bans issued against a player identity.
      Returns:
      the bans, most recently issued first; expired entries are excluded
      Since:
      0.1.0
    • ipBans

      @Contract(pure=true) default Stream<BanEntry.Address> ipBans()
      Gets the active bans issued against a client address.
      Returns:
      the bans, most recently issued first; expired entries are excluded
      Since:
      0.1.0
    • totalBans

      @Contract(pure=true) int totalBans()
      Gets how many targets are currently banned.
      Returns:
      the number of active bans
      Since:
      0.1.0
    • disconnectMessage

      @Contract(pure=true) Component disconnectMessage(BanEntry entry)
      Builds the message shown on the disconnect screen of a banned player.

      This is the single place the message is produced: callers must not assemble their own, so that an implementation replacing this one is actually the message players see.

      Parameters:
      entry - the ban
      Returns:
      the disconnect message
      Since:
      0.1.0