Package fr.andross.banitem
Class BanUtils
java.lang.Object
fr.andross.banitem.BanUtils
Utility class for the plugin.
- Version:
- 3.4
- Author:
- Andross
-
Method Summary
Modifier and TypeMethodDescriptionvoidSend a message if an update is available.voidcheckPlayerArmors(org.bukkit.entity.Player player) Used to check a player armor inventory.voidcheckPlayerIllegalStacks(@NotNull org.bukkit.entity.Player player) Used to check if a player has an illegal stacked item.voiddeleteItemFromInventoryView(@NotNull org.bukkit.entity.Player player) Method to check and delete banned item from the player opened inventory.@NotNull BanActionDatagetBanActionsForItem(@NotNull List<org.bukkit.World> worlds, @NotNull org.bukkit.configuration.ConfigurationSection itemSection, @NotNull String key, @NotNull Debug debug) Get ban actions data for a section.@NotNull Map<BanAction, BanActionData> getBanActionsFromItemSection(@NotNull List<org.bukkit.World> worlds, @Nullable org.bukkit.configuration.ConfigurationSection section, @NotNull Debug debug) Get a map of actions and actions data from a section.Get the sub commands aliases.@NotNull StringgetCooldownString(long time) Get a friendly string of remaining time.@NotNull IllegalStackScannerGet the IllegalStackScanner handler.This map contains the players who activated the log in game with /banitem log.Get the messages cooldown map.@NotNull WearScannerGet the WearScanner handler.voidgiveItemBack(@NotNull org.bukkit.entity.Player player, @NotNull org.bukkit.inventory.ItemStack item) Method to give an item back to the player, drop it if the inventory is full.booleanhasPermission(@NotNull org.bukkit.entity.Player player, @NotNull String itemName, @NotNull BanAction action, @Nullable BanData... data) Method to check if the player has the bypass permission for either the item (material name) or custom name.voidsendMessage(@NotNull org.bukkit.command.CommandSender sender, @Nullable String message) Sending a prefixed and colored (if player) message to sender.voidsendMessage(@NotNull org.bukkit.entity.Player player, @NotNull BanAction action, @Nullable List<String> messages) Sending the configured ban message to the player.voidsendMessage(@NotNull org.bukkit.entity.Player player, @NotNull String itemName, @NotNull BanAction action, @Nullable BanActionData data) This method is used to send a ban message to player, if configured.
-
Method Details
-
getBanActionsFromItemSection
@NotNull public @NotNull Map<BanAction,BanActionData> getBanActionsFromItemSection(@NotNull @NotNull List<org.bukkit.World> worlds, @Nullable @Nullable org.bukkit.configuration.ConfigurationSection section, @NotNull @NotNull Debug debug) Get a map of actions and actions data from a section.- Parameters:
worlds- list of worldssection- sectiondebug- debug- Returns:
- a map containing the ban actions and their respective data from the ConfigurationSection
-
getBanActionsForItem
@NotNull public @NotNull BanActionData getBanActionsForItem(@NotNull @NotNull List<org.bukkit.World> worlds, @NotNull @NotNull org.bukkit.configuration.ConfigurationSection itemSection, @NotNull @NotNull String key, @NotNull @NotNull Debug debug) Get ban actions data for a section.- Parameters:
worlds- list of worlds, used for regionsitemSection- the action sectionkey- the current data keydebug- debug- Returns:
- actions data from the section of the specific action
-
deleteItemFromInventoryView
public void deleteItemFromInventoryView(@NotNull @NotNull org.bukkit.entity.Player player) Method to check and delete banned item from the player opened inventory.- Parameters:
player- any player
-
sendMessage
public void sendMessage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String itemName, @NotNull @NotNull BanAction action, @Nullable @Nullable BanActionData data) This method is used to send a ban message to player, if configured. Mainly used for blacklist.- Parameters:
player- player involved in the actionitemName- the item name involvedaction- the ban action (used for log)data- the ban data (containing the messages)
-
sendMessage
public void sendMessage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull BanAction action, @Nullable @Nullable List<String> messages) Sending the configured ban message to the player. Replacing the placeholders if PlaceholderAPI enabled. Mainly used for blacklist and whitelist.- Parameters:
player- the involved playeraction- the action involvedmessages- the messages to send, if configured
-
sendMessage
public void sendMessage(@NotNull @NotNull org.bukkit.command.CommandSender sender, @Nullable @Nullable String message) Sending a prefixed and colored (if player) message to sender. This method is used only for plugin configuration (ex. plugin load, plugin command)- Parameters:
sender- sendermessage- message
-
hasPermission
public boolean hasPermission(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String itemName, @NotNull @NotNull BanAction action, @Nullable @Nullable BanData... data) Method to check if the player has the bypass permission for either the item (material name) or custom name.- Parameters:
player- player to checkitemName- name of the itemaction- action namedata- additional data to check- Returns:
- true if the player has the permission to bypass the ban, otherwise false
-
getCooldownString
Get a friendly string of remaining time.- Parameters:
time- time in millis- Returns:
- a friendly string of remaining time
-
checkPlayerArmors
public void checkPlayerArmors(org.bukkit.entity.Player player) Used to check a player armor inventory.- Parameters:
player- player
-
checkPlayerIllegalStacks
public void checkPlayerIllegalStacks(@NotNull @NotNull org.bukkit.entity.Player player) Used to check if a player has an illegal stacked item.- Parameters:
player- player
-
giveItemBack
public void giveItemBack(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull org.bukkit.inventory.ItemStack item) Method to give an item back to the player, drop it if the inventory is full.- Parameters:
player- the playeritem- the item
-
checkForUpdate
public void checkForUpdate()Send a message if an update is available. This should be run async. -
getWearScanner
Get the WearScanner handler.- Returns:
- the wear scanner handler
-
getIllegalStackScanner
Get the IllegalStackScanner handler.- Returns:
- the illegal stack scanner handler
-
getCommandsAliases
Get the sub commands aliases.- Returns:
- the sub commands aliases
-
getMessagesCooldown
Get the messages cooldown map.- Returns:
- map containing the cooldowns for messages
-
getLogging
This map contains the players who activated the log in game with /banitem log. Players which log mode is activated will receive the logs messages for the banned items, if set in config.- Returns:
- set of players uuid
-