Class BanUtils

java.lang.Object
fr.andross.banitem.BanUtils

public final class BanUtils extends Object
Utility class for the plugin.
Version:
3.4
Author:
Andross
  • 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 worlds
      section - section
      debug - 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 regions
      itemSection - the action section
      key - the current data key
      debug - 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 action
      itemName - the item name involved
      action - 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 player
      action - the action involved
      messages - 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 - sender
      message - 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 check
      itemName - name of the item
      action - action name
      data - additional data to check
      Returns:
      true if the player has the permission to bypass the ban, otherwise false
    • getCooldownString

      @NotNull public @NotNull String getCooldownString(long time)
      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 player
      item - the item
    • checkForUpdate

      public void checkForUpdate()
      Send a message if an update is available. This should be run async.
    • getWearScanner

      @NotNull public @NotNull WearScanner getWearScanner()
      Get the WearScanner handler.
      Returns:
      the wear scanner handler
    • getIllegalStackScanner

      @NotNull public @NotNull IllegalStackScanner getIllegalStackScanner()
      Get the IllegalStackScanner handler.
      Returns:
      the illegal stack scanner handler
    • getCommandsAliases

      @NotNull public @NotNull Map<String,String> getCommandsAliases()
      Get the sub commands aliases.
      Returns:
      the sub commands aliases
    • getMessagesCooldown

      @NotNull public @NotNull Map<UUID,Long> getMessagesCooldown()
      Get the messages cooldown map.
      Returns:
      map containing the cooldowns for messages
    • getLogging

      @NotNull public @NotNull Set<UUID> 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