Class BmAPI

java.lang.Object
me.confuser.banmanager.common.api.BmAPI

public class BmAPI extends Object
This is a static API for BanManager No methods are thread safe unless stated otherwise Note: The API does not handle permission checks for exemptions
  • Constructor Details

    • BmAPI

      public BmAPI()
  • Method Details

    • getPlayer

      public static PlayerData getPlayer(UUID uuid) throws SQLException
      Parameters:
      uuid - Player UUID
      Returns:
      PlayerData
      Throws:
      SQLException
    • getPlayer

      public static PlayerData getPlayer(String name) throws SQLException
      Parameters:
      name - Player name
      Returns:
      PlayerData
      Throws:
      SQLException
    • getPlayers

      public static List<PlayerData> getPlayers(me.confuser.banmanager.common.ipaddr.IPAddress ip) throws SQLException
      Parameters:
      ip - Player IP
      Returns:
      a list of PlayerData
      Throws:
      SQLException
    • getConsole

      public static PlayerData getConsole()
      Get the console for use as an actor
      Returns:
      PlayerData
    • toIp

      public static me.confuser.banmanager.common.ipaddr.IPAddress toIp(String ip)
      Convert an ip string of x.x.x.x to IPAddress
      Parameters:
      ip - IPv4 in x.x.x.x format
      Returns:
      IPv4 in number format
    • ban

      public static boolean ban(PlayerBanData ban) throws SQLException
      Permanently ban a player. You must handle kicking the player if they are online.
      Parameters:
      ban - PlayerBanData
      Returns:
      Returns true if ban successful
      Throws:
      SQLException
    • ban

      public static boolean ban(PlayerData player, PlayerData actor, String reason, boolean silent) throws SQLException
      Permanently ban a player. You must handle kicking the player if they are online.
      Parameters:
      player - Player to ban
      actor - Who the ban is by
      reason - Why they are banned
      silent - Whether the ban should be broadcast
      Returns:
      Returns true if ban successful
      Throws:
      SQLException
    • ban

      public static boolean ban(PlayerData player, PlayerData actor, String reason, boolean silent, long expires) throws SQLException
      Temporarily ban a player You must handle kicking the player if they are online.
      Parameters:
      player - Player to ban
      actor - Who the ban is by
      reason - Why they are banned
      expires - Unix Timestamp in seconds stating the time of when the ban ends
      Returns:
      Returns true if ban successful
      Throws:
      SQLException
    • unban

      public static boolean unban(PlayerBanData ban, PlayerData actor) throws SQLException
      Parameters:
      ban - The ban (can be retrieved via getBan)
      actor - Who is unbanning the player
      Returns:
      Returns true if the unban is successful
      Throws:
      SQLException
    • unban

      public static boolean unban(PlayerBanData ban, PlayerData actor, boolean silent) throws SQLException
      Parameters:
      ban - The ban (can be retrieved via getBan)
      actor - Who is unbanning the player
      silent - Whether the unban should be treated as silent
      Returns:
      Returns true if the unban is successful
      Throws:
      SQLException
    • isBanned

      public static boolean isBanned(UUID uuid)
      Thread safe
      Parameters:
      uuid - Player UUID
      Returns:
      Returns true if player is banned
    • isBanned

      public static boolean isBanned(String name)
      Thread safe
      Parameters:
      name - Player name
      Returns:
      Returns true if player is banned
    • getCurrentBan

      public static PlayerBanData getCurrentBan(String name)
      Thread safe
      Parameters:
      name - Player name
      Returns:
      Returns the active ban of a player; if the player is not banned this returns null
    • getCurrentBan

      public static PlayerBanData getCurrentBan(UUID uuid)
      Thread safe
      Parameters:
      uuid - Player UUID
      Returns:
      Returns the active ban of a player; if the player is not banned this returns null
    • getBanRecords

      public static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerBanRecord> getBanRecords(PlayerData player) throws SQLException
      Parameters:
      player - BanManager's player record
      Returns:
      An iterator of ban records
      Throws:
      SQLException
    • mute

      public static boolean mute(PlayerMuteData mute) throws SQLException
      Permanently mute a player. You must handle kicking the player if they are online.
      Parameters:
      mute - PlayerMuteData
      Returns:
      Returns true if the mute is successful
      Throws:
      SQLException
    • mute

      public static boolean mute(PlayerData player, PlayerData actor, String reason) throws SQLException
      Permanently mute a player. You must handle kicking the player if they are online.
      Parameters:
      player - Player to mute
      actor - Who the mute is by
      reason - Why they are muted
      Returns:
      Returns true if the mute is successful
      Throws:
      SQLException
    • mute

      public static boolean mute(PlayerData player, PlayerData actor, String reason, boolean silent) throws SQLException
      Permanently mute a player. You must handle kicking the player if they are online.
      Parameters:
      player - Player to mute
      actor - Who the mute is by
      reason - Why they are mutened
      silent - Whether the mute should be broadcast
      Returns:
      Returns true if mute is successful
      Throws:
      SQLException
    • mute

      public static boolean mute(PlayerData player, PlayerData actor, String reason, boolean silent, boolean isSoft) throws SQLException
      Permanently mute a player. You must handle kicking the player if they are online.
      Parameters:
      player - Player to mute
      actor - Who the mute is by
      reason - Why they are mutened
      silent - Whether the mute should be broadcast
      isSoft - Whether the player should be aware they are muted; they will still see their own messages but nobody else will
      Returns:
      Returns true if the mute is successful
      Throws:
      SQLException
    • mute

      public static boolean mute(PlayerData player, PlayerData actor, String reason, boolean silent, boolean isSoft, long expires) throws SQLException
      Temporarily mute a player You must handle kicking the player if they are online.
      Parameters:
      player - Player to mute
      actor - Who the mute is by
      reason - Why they are mutened
      silent - Whether the mute should be broadcast
      isSoft - Whether the player should be aware they are muted; they will still see their own messages but nobody else will
      expires - Unix Timestamp in seconds stating the time of when the mute ends
      Returns:
      Returns true if mute successful
      Throws:
      SQLException
    • mute

      public static boolean mute(IpMuteData mute) throws SQLException
      Mute an IP.
      Parameters:
      mute - IpMuteData
      Returns:
      Returns true if the mute is successful
      Throws:
      SQLException
    • unmute

      public static boolean unmute(PlayerMuteData mute, PlayerData actor) throws SQLException
      Parameters:
      mute - PlayerMuteData
      actor - Who unmuted the player
      Returns:
      Returns true if unmute successful
      Throws:
      SQLException
    • unmute

      public static boolean unmute(PlayerMuteData mute, PlayerData actor, boolean silent) throws SQLException
      Parameters:
      mute - PlayerMuteData
      actor - Who unmuted the player
      silent - Whether the unmute should be treated as silent
      Returns:
      Returns true if unmute successful
      Throws:
      SQLException
    • unmute

      public static boolean unmute(IpMuteData mute, PlayerData actor) throws SQLException
      Parameters:
      mute - IP Mute record
      actor - Who unmuted the ip
      Returns:
      Returns true if unmute is successful
      Throws:
      SQLException
    • unmute

      public static boolean unmute(IpMuteData mute, PlayerData actor, boolean silent) throws SQLException
      Parameters:
      mute - IP Mute record
      actor - Who unmuted the ip
      silent - Whether the unmute should be treated as silent
      Returns:
      Returns true if unmute is successful
      Throws:
      SQLException
    • isMuted

      public static boolean isMuted(UUID uuid)
      Thread safe
      Parameters:
      uuid - Player UUID
      Returns:
      Returns true if player muted
    • isMuted

      public static boolean isMuted(String name)
      Thread safe
      Parameters:
      name - Player Name
      Returns:
      Returns true if player muted
    • isMuted

      public static boolean isMuted(me.confuser.banmanager.common.ipaddr.IPAddress ip)
      Thread safe
      Parameters:
      ip - IP address
      Returns:
      Returns true if IP address muted
    • getCurrentMute

      public static PlayerMuteData getCurrentMute(String name)
      Thread safe
      Parameters:
      name -
      Returns:
      Returns the active mute of a player; if the player is not muted this returns null
    • getCurrentMute

      public static PlayerMuteData getCurrentMute(UUID uuid)
      Thread safe
      Parameters:
      uuid -
      Returns:
      Returns the active mute of a player; if the player is not muted this returns null
    • getMuteRecords

      public static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerMuteRecord> getMuteRecords(PlayerData player) throws SQLException
      Parameters:
      player - Player record
      Returns:
      Iterator of previous mutes
      Throws:
      SQLException
    • ban

      public static boolean ban(IpBanData ban) throws SQLException
      Permanently ban an ip. You must handle kicking the player if they are online.
      Parameters:
      ban - IpBanData
      Returns:
      Returns true if ban is successful
      Throws:
      SQLException
    • ban

      public static boolean ban(me.confuser.banmanager.common.ipaddr.IPAddress ip, PlayerData actor, String reason, boolean silent) throws SQLException
      Permanently ban an ip. You must handle kicking the player if they are online.
      Parameters:
      ip - IP to ban, use toIp to convert x.x.x.x to IPAddress
      actor - Who the ban is by
      reason - Why they are banned
      silent - Whether the ban should be broadcast
      Returns:
      Returns true if ban is successful
      Throws:
      SQLException
    • ban

      public static boolean ban(me.confuser.banmanager.common.ipaddr.IPAddress ip, PlayerData actor, String reason, boolean silent, long expires) throws SQLException
      Temporarily ban an ip You must handle kicking the player if they are online.
      Parameters:
      ip - IP to ban, use toIp to convert x.x.x.x to IPAddress
      actor - Who the ban is by
      reason - Why they are banned
      silent - Whether the ban should be broadcast
      expires - Unix Timestamp in seconds stating the time of when the ban ends
      Returns:
      Returns true if ban is successful
      Throws:
      SQLException
    • unban

      public static boolean unban(IpBanData ban, PlayerData actor) throws SQLException
      Parameters:
      ban - IP Ban record
      actor - Who unbanned the ip
      Returns:
      Returns true if unban is successful
      Throws:
      SQLException
    • unban

      public static boolean unban(IpBanData ban, PlayerData actor, boolean silent) throws SQLException
      Parameters:
      ban - IP Ban record
      actor - Who unbanned the ip
      silent - Whether the unban should be treated as silent
      Returns:
      Returns true if unban is successful
      Throws:
      SQLException
    • isBanned

      public static boolean isBanned(me.confuser.banmanager.common.ipaddr.IPAddress ip)
      Thread safe
      Parameters:
      ip - IP to ban, use toIp to convert x.x.x.x to IPAddress
      Returns:
      Returns true if ip is banned
    • getCurrentBan

      public static IpBanData getCurrentBan(me.confuser.banmanager.common.ipaddr.IPAddress ip)
      Thread safe
      Parameters:
      ip - IP to ban, use toIp to convert x.x.x.x to IPAddress
      Returns:
      Returns the active ban of an ip if the ip is not banned this returns null
    • getBanRecords

      public static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<IpBanRecord> getBanRecords(me.confuser.banmanager.common.ipaddr.IPAddress ip) throws SQLException
      Parameters:
      ip - IP to ban, use toIp to convert x.x.x.x to IPAddress
      Returns:
      Returns previous bans of an ip
      Throws:
      SQLException
    • warn

      public static boolean warn(PlayerData player, PlayerData actor, String reason, boolean read) throws SQLException
      Warn a player. You must handle the notification to the warned player yourself.
      Parameters:
      player - Player record
      actor - Player record of who warned the player
      reason - What the player was warned for
      read - Whether the player has already viewed the warning
      Returns:
      Returns true if warning is successful
      Throws:
      SQLException
    • warn

      public static boolean warn(PlayerData player, PlayerData actor, String reason, boolean read, boolean silent) throws SQLException
      Warn a player. You must handle the notification to the warned player yourself.
      Parameters:
      player - Player record
      actor - Player record of who warned the player
      reason - What the player was warned for
      read - Whether the player has already viewed the warning
      silent - Whether the warning should be broadcast
      Returns:
      Returns true if warning is successful
      Throws:
      SQLException
    • warn

      public static boolean warn(PlayerWarnData data) throws SQLException
      Warn a player. You must handle the notification to the warned player yourself.
      Parameters:
      data - PlayerWarnData
      Returns:
      Returns true if warning is successful
      Throws:
      SQLException
    • warn

      public static boolean warn(PlayerWarnData data, boolean silent) throws SQLException
      Warn a player. You must handle the notification to the warned player yourself.
      Parameters:
      data - PlayerWarnData
      silent - Whether the warning should be broadcast
      Returns:
      Returns true if warning is successful
      Throws:
      SQLException
    • getWarnings

      public static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerWarnData> getWarnings(PlayerData player) throws SQLException
      Retrieve past warnings of a player. This method is not thread safe and should not be called on the main thread.
      Parameters:
      player - Player record
      Returns:
      Iterator containing previous player warningss
      Throws:
      SQLException
    • getPlayerNames

      public static List<PlayerNameSummary> getPlayerNames(UUID uuid) throws SQLException
      Get all known names for a player (summary view with first/last seen). This method is not thread safe and should not be called on the main thread.
      Parameters:
      uuid - Player UUID
      Returns:
      List of PlayerNameSummary ordered by lastSeen descending (most recent first)
      Throws:
      SQLException
    • getPlayerHistory

      public static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerHistoryData> getPlayerHistory(UUID uuid, long since, int page) throws SQLException
      Get the full session history for a player. This method is not thread safe and should not be called on the main thread.
      Parameters:
      uuid - Player UUID
      since - Unix timestamp in seconds to get sessions since
      page - Page number (0-indexed, 10 results per page)
      Returns:
      Iterator of PlayerHistoryData ordered by join descending (most recent first), null if player not found
      Throws:
      SQLException
    • getPlayerNameAt

      public static String getPlayerNameAt(UUID uuid, long timestamp) throws SQLException
      Get the name a player was using at a specific timestamp. This method is not thread safe and should not be called on the main thread.
      Parameters:
      uuid - Player UUID
      timestamp - Unix timestamp in seconds
      Returns:
      The name at that time, or null if not found
      Throws:
      SQLException
    • getMessage

      public static Message getMessage(String key)
      Parameters:
      key - The message config node within messages.yml, e.g. "ban.notify"
      Returns:
      String
    • getLocalConnection

      public static me.confuser.banmanager.common.ormlite.support.ConnectionSource getLocalConnection()
    • toTimestamp

      public static long toTimestamp(String time, boolean future) throws Exception
      Throws:
      Exception