Class BetterBanSystem

java.lang.Object
me.github.simonplays15.betterbansystem.core.BetterBanSystem

public abstract class BetterBanSystem extends Object
Represents the BetterBanSystem class.
  • Field Details

    • prefix

      public String prefix
      The prefix variable stores a string that represents a prefix for messages or commands.
    • config

      public BaseConfig config
      Represents the configuration settings for the BetterBanSystem.
  • Constructor Details

    • BetterBanSystem

      public BetterBanSystem (File dataFolder) throws RuntimeException
      Initializes the BetterBanSystem.
      Parameters:
      dataFolder - The data folder for storing configuration and data files.
      Throws:
      RuntimeException - if the runtime service is not Spigot or BungeeCord.
  • Method Details

    • getInstance

      @Contract(pure=true) public static BetterBanSystem getInstance()
      Returns the instance of the BetterBanSystem.
      Returns:
      The instance of the BetterBanSystem.
    • sendMessage

      public static void sendMessage (@NotNull @NotNull Object player, String message)
      Sends a message to a player.
      Parameters:
      player - the player object to send the message to
      message - the message to send
      Throws:
      IllegalArgumentException - if the player object is not an instance of org.bukkit.entity.Player or net.md_5.bungee.api.connection.ProxiedPlayer
    • sendMessage

      public static void sendMessage (Object player, String @NotNull ... messages)
      Sends one or more messages to the specified player.
      Parameters:
      player - The player object to send the messages to. Must not be null.
      messages - The messages to be sent. Can be one or more strings.
    • sendMessage

      public static void sendMessage (@NotNull @NotNull Object player, @NotNull @NotNull net.md_5.bungee.api.chat.TextComponent component)
      Sends a message to a player or console.
      Parameters:
      player - the player or console object to send the message to
      component - the text component to send
      Throws:
      IllegalArgumentException - if player object is not an instance of org.bukkit.entity.Player or net.md_5.bungee.api.connection.ProxiedPlayer
    • sendMessage

      public static void sendMessage (Object player, @NotNull @NotNull net.md_5.bungee.api.chat.TextComponent @NotNull ... components)
      Sends a message or multiple messages to a player.
      Parameters:
      player - the player or command sender to send the message(s) to
      components - the text components representing the message(s) to be sent
    • kickPlayer

      public static void kickPlayer (@NotNull @NotNull Object player, String message)
      Kicks the specified player with the given message.
      Parameters:
      player - The player object to kick. Must be an instance of either org.bukkit.entity.Player or net.md_5.bungee.api.connection.ProxiedPlayer.
      message - The message to be displayed to the kicked player.
    • getPlayer

      @Nullable public static @Nullable Object getPlayer (@NotNull @NotNull String playerName)
      Retrieves the player object based on the given player name.
      Parameters:
      playerName - the name of the player
      Returns:
      the player object if found, otherwise null
    • getPlayer

      @Nullable public static @Nullable Object getPlayer (@NotNull @NotNull UUID playerId)
      Retrieves the player with the specified UUID.
      Parameters:
      playerId - the UUID of the player to retrieve
      Returns:
      the player object with the specified UUID, or null if the player is not found or the runtime environment is not supported
    • hasPlayedBefore

      public static boolean hasPlayedBefore (@NotNull @NotNull Object offlinePlayer)
      Checks if the specified player has played before.
      Parameters:
      offlinePlayer - The player to check.
      Returns:
      True if the player has played before, false otherwise.
      Throws:
      IllegalArgumentException - If the player object is not an instance of org.bukkit.OfflinePlayer or net.md_5.bungee.api.connection.ProxiedPlayer.
    • getOfflinePlayer

      @Nullable public static @Nullable Object getOfflinePlayer (UUID uuid)
      Retrieves the OfflinePlayer object associated with the specified UUID.
      Parameters:
      uuid - The UUID of the player to fetch
      Returns:
      The OfflinePlayer object for the specified UUID, or null if it cannot be found.
    • getConsole

      public static Object getConsole()
      Retrieves the console object for the current runtime environment.
      Returns:
      The console object for the current runtime environment.
      Throws:
      RuntimeException - if the Spigot or BungeeCord library is not found.
    • getConsoleSender

      @NotNull public static @NotNull BaseCommandSender getConsoleSender()
      Retrieves the console sender for the current runtime environment.
      Returns:
      The console sender.
      Throws:
      IllegalArgumentException - If the console object is not an instance of org.bukkit.command.CommandSender or net.md_5.bungee.api.CommandSender.
    • dispatchCommand

      public abstract void dispatchCommand (String command)
      Dispatches a command for execution.
      Parameters:
      command - the command to be dispatched
    • getRunningPlugin

      public abstract Object getRunningPlugin()
      Retrieves the currently running plugin.
      Returns:
      The currently running plugin.
    • getDatabase

      public IDatabase getDatabase()
      Retrieves the database associated with this BetterBanSystem instance.
      Returns:
      The IDatabase instance representing the database.
    • getCommandHandler

      public BaseCommandHandler getCommandHandler()
      Retrieves the command handler for managing commands in the command-based system.
      Returns:
      The command handler, an instance of the BaseCommandHandler class.
    • getPrefix

      public String getPrefix()
    • loadLanguage

      public void loadLanguage (@NotNull @NotNull String language)
      Loads the specified language file. If the language parameter does not end with ".yml", it will be appended with ".yml". The language file will be loaded from the path specified in the data folder of the plugin.
      Parameters:
      language - The name of the language file to load.
      Throws:
      NullPointerException - if the language parameter is null.
    • loadPermissionsSystem

      public void loadPermissionsSystem (PermissionsHandlerType type)
      Loads the permissions system based on the specified PermissionsHandlerType.

      The permissions system is responsible for managing permissions in the system. It provides functionality for creating, modifying, and deleting permissions, as well as checking if a player has a specific permission.

      If the specified handler cannot be obtained, the method falls back to the default permissions handler based on the server runtime.

      The available types of permissions handlers are defined in the PermissionsHandlerType enum.

      Parameters:
      type - The type of the permissions handler to load. Possible values are SPIGOT, LUCKPERMS, BUNGEECORD, CLOUDNET, VAULT, and DEFAULT_PERMISSION_HANDLING.
      See Also:
    • reloadConfig

      public void reloadConfig()
      Reloads the configuration by loading the config file into the current config object.

      If the config is null, a new instance of BaseConfig is created. After that, the BaseConfig.load(File) method is called to load the config file.

    • saveConfig

      public void saveConfig()
      Saves the configuration to a file.
    • getDataFolder

      public File getDataFolder()
      Returns the data folder for the plugin.
      Returns:
      The data folder for the plugin.
    • getConfig

      public BaseConfig getConfig()
      Retrieves the BaseConfig object associated with this BetterBanSystem instance.
      Returns:
      The BaseConfig object used for storing configuration settings.
    • getLanguageFile

      public LanguageFile getLanguageFile()
      Retrieves the LanguageFile object associated with the BetterBanSystem instance. The LanguageFile object stores the messages and translations used by the plugin.
      Returns:
      The LanguageFile object.
    • getPermissionsManager

      public PermissionsManager getPermissionsManager()
      Retrieves the permissions manager associated with this instance of BetterBanSystem.
      Returns:
      The permissions' manager.
    • getPluginDescription

      public BasePluginDescription getPluginDescription()
      Returns the plugin description of the current instance.
      Returns:
      The plugin description.