Class Ban

java.lang.Object
com.hypixel.hytale.server.core.modules.accesscontrol.ban.Ban

public final class Ban extends Object
A ban on one player.
Since:
07.08.2016
  • Field Details

    • CODEC

      @Nonnull public static final BuilderCodec<Ban> CODEC
      The codec used to parse Ban instances.
  • Constructor Details

    • Ban

      public Ban(@Nonnull UUID target, @Nonnull UUID by, @Nonnull Instant timestamp, @Nullable Instant expiresOn, @Nullable String reason)
      Default Constructor for a Ban instance.
      Parameters:
      target - the player the ban applies to
      by - the player who issued the ban
      timestamp - when the ban was issued
      expiresOn - when the ban runs out, or null for a ban that never does
      reason - why the ban was issued, or null to give no reason
  • Method Details

    • getTarget

      @Nonnull public UUID getTarget()
      Returns:
      the player the ban applies to
    • getBy

      @Nonnull public UUID getBy()
      Returns:
      the player who issued the ban
    • getTimestamp

      @Nonnull public Instant getTimestamp()
      Returns:
      when the ban was issued
    • getExpiresOn

      @Nullable public Instant getExpiresOn()
      Returns:
      when the ban runs out, or null for a ban that never does
    • getReason

      @Nullable public String getReason()
      Returns:
      why the ban was issued, or null if it gives no reason
    • getMetadata

      @Nullable public <T> T getMetadata(@Nonnull KeyedCodec<T> keyedCodec)
      Reads one value of the data that plugins keep on the ban.
      Parameters:
      keyedCodec - the key the value is stored under and the codec that reads it
      Returns:
      the value, or null if the ban carries none under that key
    • getMetadata

      @Nullable public <T> T getMetadata(@Nonnull String key, @Nonnull Codec<T> codec)
      Reads one value of the data that plugins keep on the ban.
      Parameters:
      key - the key the value is stored under
      codec - the codec that reads it
      Returns:
      the value, or null if the ban carries none under that key
    • withMetadata

      @Nonnull public <T> Ban withMetadata(@Nonnull KeyedCodec<T> keyedCodec, @Nullable T data)
      Returns a copy of the ban carrying one more value of the data that plugins keep on it. Add the copy to store it, because a ban a provider already holds does not take a change.

      Anything stored is written with the ban and read back with it, including on a server that no longer runs the plugin that wrote it. Every plugin shares this data, so name the key after your plugin. A KeyedCodec takes only the key format the codecs use, so pass the key and the codec to withMetadata(String, Codec, Object) to name one of your own.

      Parameters:
      keyedCodec - the key to store the value under and the codec that writes it
      data - the value to store, or null to leave the key out
      Returns:
      a copy of the ban carrying the value
    • withMetadata

      @Nonnull public <T> Ban withMetadata(@Nonnull String key, @Nonnull Codec<T> codec, @Nullable T data)
      Parameters:
      key - the key to store the value under
      codec - the codec that writes the value
      data - the value to store, or null to leave the key out
      Returns:
      a copy of the ban carrying the value
      See Also:
    • isInEffect

      public boolean isInEffect()
      Returns:
      true while the ban applies
    • getDisconnectReason

      @Nonnull public Message getDisconnectReason()
      Returns:
      the message to disconnect the target with