Class CSVBanDatabase

java.lang.Object
com.sk89q.commandbook.component.bans.CSVBanDatabase
All Implemented Interfaces:
BanDatabase, java.lang.Iterable<Ban>

public class CSVBanDatabase
extends java.lang.Object
implements BanDatabase
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.logging.Logger auditLogger  
    protected java.util.Set<Ban> bans
    A set of all bans.
    protected java.util.Map<java.lang.String,​Ban> ipBan
    Used to lookup bans by ip address
    protected java.util.Map<java.lang.String,​Ban> nameBan
    Deprecated.
    protected java.io.File storageFile  
    protected java.util.Map<java.util.UUID,​Ban> UUIDBan
    Used to lookup bans by UUID
  • Constructor Summary

    Constructors 
    Constructor Description
    CSVBanDatabase​(java.io.File banStorageDir)  
  • Method Summary

    Modifier and Type Method Description
    void ban​(java.util.UUID ID, java.lang.String name, java.lang.String address, org.bukkit.command.CommandSender source, java.lang.String reason, long end)
    Bans a UUID and or address.
    void ban​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason, long end)
    Bans a player by UUID and address.
    Ban getBanned​(java.lang.String address)
    Returns a Ban with the given address
    Ban getBanned​(java.util.UUID ID)
    Returns a Ban with the given UUID
    java.lang.String getBannedMessage​(java.lang.String address)
    Gets the ban message for a banned address.
    java.lang.String getBannedMessage​(java.util.UUID ID)
    Gets the ban message for a banned UUID.
    void importFrom​(BanDatabase bans)
    Imports the bans from another ban database.
    boolean isBanned​(java.net.InetAddress address)
    Checks if a player's address is banned.
    boolean isBanned​(java.util.UUID ID)
    Checks if a player's UUID is banned.
    java.util.Iterator<Ban> iterator()  
    boolean load()
    Load the ban database.
    void logKick​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason)
    Unbans a name.
    boolean save()
    Save the database.
    boolean unban​(java.util.UUID ID, java.lang.String address, org.bukkit.command.CommandSender source, java.lang.String reason)
    Unban a player and/or address.
    boolean unban​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason)
    Unban a player by UUID.
    boolean unbanName​(java.lang.String name, org.bukkit.command.CommandSender source, java.lang.String reason)
    Unbans a name.
    boolean unload()
    Unloads the database

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • auditLogger

      protected final java.util.logging.Logger auditLogger
    • storageFile

      protected final java.io.File storageFile
    • UUIDBan

      protected java.util.Map<java.util.UUID,​Ban> UUIDBan
      Used to lookup bans by UUID
    • nameBan

      @Deprecated protected java.util.Map<java.lang.String,​Ban> nameBan
      Deprecated.
      Used to lookup bans by name
    • ipBan

      protected java.util.Map<java.lang.String,​Ban> ipBan
      Used to lookup bans by ip address
    • bans

      protected final java.util.Set<Ban> bans
      A set of all bans. No ban in the lookup maps is not in here.
  • Constructor Details

    • CSVBanDatabase

      public CSVBanDatabase​(java.io.File banStorageDir)
  • Method Details

    • load

      public boolean load()
      Description copied from interface: BanDatabase
      Load the ban database.
      Specified by:
      load in interface BanDatabase
      Returns:
      whether the operation was fully successful
    • save

      public boolean save()
      Description copied from interface: BanDatabase
      Save the database.
      Specified by:
      save in interface BanDatabase
      Returns:
      whether the operation was fully successful
    • unload

      public boolean unload()
      Description copied from interface: BanDatabase
      Unloads the database
      Specified by:
      unload in interface BanDatabase
      Returns:
      whether the operation was fully successful
    • isBanned

      public boolean isBanned​(java.util.UUID ID)
      Description copied from interface: BanDatabase
      Checks if a player's UUID is banned.
      Specified by:
      isBanned in interface BanDatabase
      Parameters:
      ID - The UUID to check
      Returns:
      Whether the UUID is banned
    • isBanned

      public boolean isBanned​(java.net.InetAddress address)
      Description copied from interface: BanDatabase
      Checks if a player's address is banned.
      Specified by:
      isBanned in interface BanDatabase
      Parameters:
      address - The address to check
      Returns:
      Whether the given address is banned
    • getBannedMessage

      public java.lang.String getBannedMessage​(java.util.UUID ID)
      Description copied from interface: BanDatabase
      Gets the ban message for a banned UUID.
      Specified by:
      getBannedMessage in interface BanDatabase
      Parameters:
      ID - The ID to check
      Returns:
      The banned message for the given ID
    • getBannedMessage

      public java.lang.String getBannedMessage​(java.lang.String address)
      Description copied from interface: BanDatabase
      Gets the ban message for a banned address.
      Specified by:
      getBannedMessage in interface BanDatabase
      Parameters:
      address - The address to check
      Returns:
      The banned message for the given address
    • ban

      public void ban​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason, long end)
      Description copied from interface: BanDatabase
      Bans a player by UUID and address.
      Specified by:
      ban in interface BanDatabase
    • ban

      public void ban​(java.util.UUID ID, java.lang.String name, java.lang.String address, org.bukkit.command.CommandSender source, java.lang.String reason, long end)
      Description copied from interface: BanDatabase
      Bans a UUID and or address.
      Specified by:
      ban in interface BanDatabase
    • unbanName

      public boolean unbanName​(java.lang.String name, org.bukkit.command.CommandSender source, java.lang.String reason)
      Description copied from interface: BanDatabase
      Unbans a name. WARNING: This method only works for cases where the UUID for the record is null.
      Specified by:
      unbanName in interface BanDatabase
      Returns:
      whether the name was found
    • unban

      public boolean unban​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason)
      Description copied from interface: BanDatabase
      Unban a player by UUID. WARNING: This method will not unban a player's address
      Specified by:
      unban in interface BanDatabase
      Returns:
    • unban

      public boolean unban​(java.util.UUID ID, java.lang.String address, org.bukkit.command.CommandSender source, java.lang.String reason)
      Description copied from interface: BanDatabase
      Unban a player and/or address. First looks up by UUID, then if not found looks up by address.
      Specified by:
      unban in interface BanDatabase
      Returns:
    • logKick

      public void logKick​(org.bukkit.entity.Player player, org.bukkit.command.CommandSender source, java.lang.String reason)
      Description copied from interface: BanDatabase
      Unbans a name.
      Specified by:
      logKick in interface BanDatabase
    • importFrom

      public void importFrom​(BanDatabase bans)
      Description copied from interface: BanDatabase
      Imports the bans from another ban database.
      Specified by:
      importFrom in interface BanDatabase
    • getBanned

      public Ban getBanned​(java.util.UUID ID)
      Description copied from interface: BanDatabase
      Returns a Ban with the given UUID
      Specified by:
      getBanned in interface BanDatabase
      Parameters:
      ID - The UUID of the banned player.
      Returns:
      The applicable ban
    • getBanned

      public Ban getBanned​(java.lang.String address)
      Description copied from interface: BanDatabase
      Returns a Ban with the given address
      Specified by:
      getBanned in interface BanDatabase
      Parameters:
      address - The address given to the ban.
      Returns:
      The applicable ban
    • iterator

      public java.util.Iterator<Ban> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<Ban>