Class BanManager
- All Implemented Interfaces:
ChatPluginManager
Ban
s and interacts with the storage.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
ban
(OfflinePlayer player, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans a player.abstract void
banIP
(InetAddress ipAddress, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans an IP address.abstract void
banIP
(OfflinePlayer player, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans a player by their IP address.abstract String
formatActiveMessage
(boolean active, Language language) Formats a ban's active message using the message set in the specified language's messages file.abstract String
formatGlobalMessage
(boolean global, Language language) Formats a ban's global message using the message set in the specified language's messages file.abstract String
formatKickMessage
(KickType type, Language language) Formats a ban's kick message using the message set in the specified language's messages file.abstract String
formatSilentMessage
(boolean silent, Language language) Formats a ban's silent message using the message set in the specified language's messages file.abstract String
formatTypeMessage
(BanType type, Language language) Formats a ban's type message using the message set in the specified language's messages file.abstract Ban
getActiveBan
(int id) Gets the active ban for the specified ID.abstract Ban
getActiveBan
(InetAddress ipAddress, String server) Gets the active ban for the specified IP address and server.abstract Ban
getActiveBan
(OfflinePlayer player, String server) Gets the active ban for the specified player and server.Gets the active bans' list.getActiveBans
(InetAddress ipAddress) Gets the active bans' list for the specified IP address.getActiveBans
(OfflinePlayer player) Gets the active bans' list for the specified player.abstract Ban
getBan
(int id) Gets a ban from the database.static BanManager
Gets this manager's instance.boolean
isBanned
(InetAddress ipAddress, String server) Checks if an IP address is banned in the specified server.boolean
isBanned
(OfflinePlayer player, String server) Checks if a player is banned in the specified server.boolean
Checks if bans should be global by default.boolean
Checks if this manager is enabled.abstract void
Unbans a player based on their ban's ID.abstract void
unban
(OfflinePlayer player, String server, String whoUnbanned) Unbans a player.abstract void
unbanIP
(InetAddress ipAddress, String server, String whoUnbanned) Unbans an IP address.Methods inherited from class me.remigio07.chatplugin.api.common.punishment.PunishmentManager
formatReason, getAnticheatStorageCount, getNextID, getStaffStorageCount, getStorageCount, load, setAnticheatStorageCount, setStaffStorageCount, setStorageCount
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface me.remigio07.chatplugin.api.common.util.manager.ChatPluginManager
checkAvailability, isReloadable, reload, unload
-
Constructor Details
-
BanManager
public BanManager()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Checks if this manager is enabled.Found at: "ban.enabled" in
ConfigurationType.CONFIG
- Specified by:
isEnabled
in interfaceChatPluginManager
- Overrides:
isEnabled
in classPunishmentManager
- Returns:
- Whether this manager is enabled
-
getActiveBans
Gets the active bans' list.Do not modify the returned list.
- Returns:
- Active bans' list
-
isDefaultGlobal
public boolean isDefaultGlobal()Checks if bans should be global by default.Found at: "ban.default-global" in
ConfigurationType.CONFIG
- Returns:
- Whether bans should be global
-
isBanned
Checks if a player is banned in the specified server.Specify
null
asserver
to check global bans.- Parameters:
player
- Player to checkserver
- Origin server (ProxyManager.getServerID()
)- Returns:
- Whether the player is banned
-
isBanned
Checks if an IP address is banned in the specified server.Specify
null
asserver
to check global bans.- Parameters:
ipAddress
- IP address to checkserver
- Origin server (ProxyManager.getServerID()
)- Returns:
- Whether the IP address is banned
-
getInstance
Gets this manager's instance.- Returns:
- Manager's instance
-
ban
public abstract void ban(OfflinePlayer player, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans a player.- Parameters:
player
- Player to banstaffMember
- Who banned the playerreason
- Ban's reason, nullableserver
- Origin server (ProxyManager.getServerID()
)duration
- Duration, in milliseconds; -1 = permanentglobal
- Whether this ban is globalsilent
- Whether this ban is silent- Throws:
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()UnsupportedOperationException
- IfOfflinePlayer.isOnline()
&& !OfflinePlayer.isLoaded()
- See Also:
-
banIP
public abstract void banIP(OfflinePlayer player, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans a player by their IP address.- Parameters:
player
- Player to banstaffMember
- Who banned the playerreason
- Ban's reason, nullableserver
- Origin server (ProxyManager.getServerID()
)duration
- Duration, in milliseconds; -1 = permanentglobal
- Whether this ban is globalsilent
- Whether this ban is silent- Throws:
IllegalArgumentException
- If!
OfflinePlayer.hasPlayedBefore()
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()UnsupportedOperationException
- IfOfflinePlayer.isOnline()
&& !OfflinePlayer.isLoaded()
- See Also:
-
banIP
public abstract void banIP(InetAddress ipAddress, String staffMember, String reason, String server, long duration, boolean global, boolean silent) Bans an IP address.- Parameters:
ipAddress
- IP address to banstaffMember
- Who banned the IP addressreason
- Ban's reason, nullableserver
- Origin server (ProxyManager.getServerID()
)duration
- Duration, in milliseconds; -1 = permanentglobal
- Whether this ban is globalsilent
- Whether this ban is silent- Throws:
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()UnsupportedOperationException
- IfOfflinePlayer.isOnline()
&& !OfflinePlayer.isLoaded()
- See Also:
-
unban
Unbans a player.Specify
null
asserver
to disactive a global ban.- Parameters:
player
- Player to unbanserver
- Origin server (ProxyManager.getServerID()
)whoUnbanned
- Who unbanned the player- Throws:
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()UnsupportedOperationException
- IfOfflinePlayer.isOnline()
&& !OfflinePlayer.isLoaded()
- See Also:
-
unbanIP
Unbans an IP address.Specify
null
asserver
to disactive a global ban.- Parameters:
ipAddress
- IP address to unbanserver
- Origin server (ProxyManager.getServerID()
)whoUnbanned
- Who unbanned the IP address- Throws:
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()- See Also:
-
unban
Unbans a player based on their ban's ID.- Parameters:
id
- Ban's IDwhoUnbanned
- Who unbanned the player- Throws:
IllegalStateException
- If!
Environment.isProxy()
&&ProxyManager.isEnabled()
&&PlayerAdapter.getOnlinePlayers()
.isEmpty()- See Also:
-
getActiveBans
Gets the active bans' list for the specified player.Will return an empty list if the player is not banned in any server.
- Parameters:
player
- Player to check- Returns:
- Player's bans
-
getActiveBans
Gets the active bans' list for the specified IP address.Will return an empty list if the IP address is not banned in any server.
- Parameters:
ipAddress
- IP address to check- Returns:
- IP address' bans
-
getActiveBan
Gets the active ban for the specified player and server.Will return
null
if the player is not banned in that server.Specify
null
asserver
to check global bans.- Parameters:
player
- Player to checkserver
- Origin server (ProxyManager.getServerID()
)- Returns:
- Player's ban
-
getActiveBan
Gets the active ban for the specified IP address and server.Will return
null
if the IP address is not banned in that server.Specify
null
asserver
to check global bans.- Parameters:
ipAddress
- IP address to checkserver
- Origin server (ProxyManager.getServerID()
)- Returns:
- IP address' ban
-
getActiveBan
Gets the active ban for the specified ID.Will return
null
if the ban is not active.- Parameters:
id
- Ban's ID- Returns:
- Ban object
-
getBan
Gets a ban from the database.Will return
null
if the ban does not exist.This method is equivalent to
StorageConnector.getBan(int)
with the difference that it suppressesSQLException
s.- Parameters:
id
- Ban's ID- Returns:
- Ban object
-
formatTypeMessage
Formats a ban's type message using the message set in the specified language's messages file.- Parameters:
type
- Type to formatlanguage
- Language used to translate the message- Returns:
- Formatted type message
-
formatActiveMessage
Formats a ban's active message using the message set in the specified language's messages file.- Parameters:
active
- Whether the ban is activelanguage
- Language used to translate the message- Returns:
- Formatted type message
-
formatGlobalMessage
Formats a ban's global message using the message set in the specified language's messages file.- Parameters:
global
- Whether the ban is globallanguage
- Language used to translate the message- Returns:
- Formatted global message
-
formatSilentMessage
Formats a ban's silent message using the message set in the specified language's messages file.- Parameters:
silent
- Whether the ban is silentlanguage
- Language used to translate the message- Returns:
- Formatted silent message
-
formatKickMessage
Formats a ban's kick message using the message set in the specified language's messages file.- Parameters:
type
- Type to formatlanguage
- Language used to translate the message- Returns:
- Formatted kick message
-