Class BmAPI
java.lang.Object
me.confuser.banmanager.common.api.BmAPI
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanPermanently ban an ip.static booleanban(PlayerBanData ban) Permanently ban a player.static booleanban(PlayerData player, PlayerData actor, String reason, boolean silent) Permanently ban a player.static booleanban(PlayerData player, PlayerData actor, String reason, boolean silent, long expires) Temporarily ban a player You must handle kicking the player if they are online.static booleanban(me.confuser.banmanager.common.ipaddr.IPAddress ip, PlayerData actor, String reason, boolean silent) Permanently ban an ip.static booleanban(me.confuser.banmanager.common.ipaddr.IPAddress ip, PlayerData actor, String reason, boolean silent, long expires) Temporarily ban an ip You must handle kicking the player if they are online.static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerBanRecord> getBanRecords(PlayerData player) static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<IpBanRecord> getBanRecords(me.confuser.banmanager.common.ipaddr.IPAddress ip) static PlayerDataGet the console for use as an actorstatic PlayerBanDatagetCurrentBan(String name) Thread safestatic PlayerBanDatagetCurrentBan(UUID uuid) Thread safestatic IpBanDatagetCurrentBan(me.confuser.banmanager.common.ipaddr.IPAddress ip) Thread safestatic PlayerMuteDatagetCurrentMute(String name) Thread safestatic PlayerMuteDatagetCurrentMute(UUID uuid) Thread safestatic me.confuser.banmanager.common.ormlite.support.ConnectionSourcestatic MessagegetMessage(String key) static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerMuteRecord> getMuteRecords(PlayerData player) static PlayerDatastatic PlayerDatastatic me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerHistoryData> getPlayerHistory(UUID uuid, long since, int page) Get the full session history for a player.static StringgetPlayerNameAt(UUID uuid, long timestamp) Get the name a player was using at a specific timestamp.static List<PlayerNameSummary> getPlayerNames(UUID uuid) Get all known names for a player (summary view with first/last seen).static List<PlayerData> getPlayers(me.confuser.banmanager.common.ipaddr.IPAddress ip) static me.confuser.banmanager.common.ormlite.dao.CloseableIterator<PlayerWarnData> getWarnings(PlayerData player) Retrieve past warnings of a player.static booleanThread safestatic booleanThread safestatic booleanisBanned(me.confuser.banmanager.common.ipaddr.IPAddress ip) Thread safestatic booleanThread safestatic booleanThread safestatic booleanisMuted(me.confuser.banmanager.common.ipaddr.IPAddress ip) Thread safestatic booleanmute(IpMuteData mute) Mute an IP.static booleanmute(PlayerData player, PlayerData actor, String reason) Permanently mute a player.static booleanmute(PlayerData player, PlayerData actor, String reason, boolean silent) Permanently mute a player.static booleanmute(PlayerData player, PlayerData actor, String reason, boolean silent, boolean isSoft) Permanently mute a player.static booleanmute(PlayerData player, PlayerData actor, String reason, boolean silent, boolean isSoft, long expires) Temporarily mute a player You must handle kicking the player if they are online.static booleanmute(PlayerMuteData mute) Permanently mute a player.static me.confuser.banmanager.common.ipaddr.IPAddressConvert an ip string of x.x.x.x to IPAddressstatic longtoTimestamp(String time, boolean future) static booleanunban(IpBanData ban, PlayerData actor) static booleanunban(IpBanData ban, PlayerData actor, boolean silent) static booleanunban(PlayerBanData ban, PlayerData actor) static booleanunban(PlayerBanData ban, PlayerData actor, boolean silent) static booleanunmute(IpMuteData mute, PlayerData actor) static booleanunmute(IpMuteData mute, PlayerData actor, boolean silent) static booleanunmute(PlayerMuteData mute, PlayerData actor) static booleanunmute(PlayerMuteData mute, PlayerData actor, boolean silent) static booleanwarn(PlayerData player, PlayerData actor, String reason, boolean read) Warn a player.static booleanwarn(PlayerData player, PlayerData actor, String reason, boolean read, boolean silent) Warn a player.static booleanwarn(PlayerWarnData data) Warn a player.static booleanwarn(PlayerWarnData data, boolean silent) Warn a player.
-
Constructor Details
-
BmAPI
public BmAPI()
-
-
Method Details
-
getPlayer
- Parameters:
uuid- Player UUID- Returns:
- PlayerData
- Throws:
SQLException
-
getPlayer
- 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
Get the console for use as an actor- Returns:
- PlayerData
-
toIp
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
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 banactor- Who the ban is byreason- Why they are bannedsilent- 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 banactor- Who the ban is byreason- Why they are bannedexpires- Unix Timestamp in seconds stating the time of when the ban ends- Returns:
- Returns true if ban successful
- Throws:
SQLException
-
unban
- 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 playersilent- Whether the unban should be treated as silent- Returns:
- Returns true if the unban is successful
- Throws:
SQLException
-
isBanned
Thread safe- Parameters:
uuid- Player UUID- Returns:
- Returns true if player is banned
-
isBanned
Thread safe- Parameters:
name- Player name- Returns:
- Returns true if player is banned
-
getCurrentBan
Thread safe- Parameters:
name- Player name- Returns:
- Returns the active ban of a player; if the player is not banned this returns null
-
getCurrentBan
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
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
Permanently mute a player. You must handle kicking the player if they are online.- Parameters:
player- Player to muteactor- Who the mute is byreason- 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 muteactor- Who the mute is byreason- Why they are mutenedsilent- 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 muteactor- Who the mute is byreason- Why they are mutenedsilent- Whether the mute should be broadcastisSoft- 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 muteactor- Who the mute is byreason- Why they are mutenedsilent- Whether the mute should be broadcastisSoft- Whether the player should be aware they are muted; they will still see their own messages but nobody else willexpires- Unix Timestamp in seconds stating the time of when the mute ends- Returns:
- Returns true if mute successful
- Throws:
SQLException
-
mute
Mute an IP.- Parameters:
mute- IpMuteData- Returns:
- Returns true if the mute is successful
- Throws:
SQLException
-
unmute
- Parameters:
mute- PlayerMuteDataactor- 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- PlayerMuteDataactor- Who unmuted the playersilent- Whether the unmute should be treated as silent- Returns:
- Returns true if unmute successful
- Throws:
SQLException
-
unmute
- Parameters:
mute- IP Mute recordactor- Who unmuted the ip- Returns:
- Returns true if unmute is successful
- Throws:
SQLException
-
unmute
- Parameters:
mute- IP Mute recordactor- Who unmuted the ipsilent- Whether the unmute should be treated as silent- Returns:
- Returns true if unmute is successful
- Throws:
SQLException
-
isMuted
Thread safe- Parameters:
uuid- Player UUID- Returns:
- Returns true if player muted
-
isMuted
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
Thread safe- Parameters:
name-- Returns:
- Returns the active mute of a player; if the player is not muted this returns null
-
getCurrentMute
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
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 IPAddressactor- Who the ban is byreason- Why they are bannedsilent- 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 IPAddressactor- Who the ban is byreason- Why they are bannedsilent- Whether the ban should be broadcastexpires- Unix Timestamp in seconds stating the time of when the ban ends- Returns:
- Returns true if ban is successful
- Throws:
SQLException
-
unban
- Parameters:
ban- IP Ban recordactor- Who unbanned the ip- Returns:
- Returns true if unban is successful
- Throws:
SQLException
-
unban
- Parameters:
ban- IP Ban recordactor- Who unbanned the ipsilent- 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
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 recordactor- Player record of who warned the playerreason- What the player was warned forread- 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 recordactor- Player record of who warned the playerreason- What the player was warned forread- Whether the player has already viewed the warningsilent- Whether the warning should be broadcast- Returns:
- Returns true if warning is successful
- Throws:
SQLException
-
warn
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
Warn a player. You must handle the notification to the warned player yourself.- Parameters:
data- PlayerWarnDatasilent- 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
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 UUIDsince- Unix timestamp in seconds to get sessions sincepage- 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
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 UUIDtimestamp- Unix timestamp in seconds- Returns:
- The name at that time, or null if not found
- Throws:
SQLException
-
getMessage
- 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
- Throws:
Exception
-