Class BetterBanSystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionRepresents the configuration settings for the BetterBanSystem.The prefix variable stores a string that represents a prefix for messages or commands. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
dispatchCommand
(String command) Dispatches a command for execution.Retrieves the command handler for managing commands in the command-based system.Retrieves the BaseConfig object associated with this BetterBanSystem instance.static Object
Retrieves the console object for the current runtime environment.static @NotNull BaseCommandSender
Retrieves the console sender for the current runtime environment.Retrieves the database associated with this BetterBanSystem instance.Returns the data folder for the plugin.static BetterBanSystem
Returns the instance of the BetterBanSystem.Retrieves the LanguageFile object associated with the BetterBanSystem instance.static @Nullable Object
getOfflinePlayer
(UUID uuid) Retrieves the OfflinePlayer object associated with the specified UUID.Retrieves the permissions manager associated with this instance of BetterBanSystem.static @Nullable Object
Retrieves the player object based on the given player name.static @Nullable Object
Retrieves the player with the specified UUID.Returns the plugin description of the current instance.abstract Object
Retrieves the currently running plugin.static boolean
hasPlayedBefore
(@NotNull Object offlinePlayer) Checks if the specified player has played before.static void
kickPlayer
(@NotNull Object player, String message) Kicks the specified player with the given message.void
loadLanguage
(@NotNull String language) Loads the specified language file.void
Loads the permissions system based on the specifiedPermissionsHandlerType
.void
Reloads the configuration by loading the config file into the currentconfig
object.void
Saves the configuration to a file.static void
sendMessage
(@NotNull Object player, @NotNull net.md_5.bungee.api.chat.TextComponent component) Sends a message to a player or console.static void
sendMessage
(@NotNull Object player, String message) Sends a message to a player.static void
sendMessage
(Object player, @NotNull net.md_5.bungee.api.chat.TextComponent @NotNull ... components) Sends a message or multiple messages to a player.static void
sendMessage
(Object player, String @NotNull ... messages) Sends one or more messages to the specified player.
-
Field Details
-
prefix
The prefix variable stores a string that represents a prefix for messages or commands. -
config
Represents the configuration settings for the BetterBanSystem.
-
-
Constructor Details
-
BetterBanSystem
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
Returns the instance of the BetterBanSystem.- Returns:
- The instance of the BetterBanSystem.
-
sendMessage
Sends a message to a player.- Parameters:
player
- the player object to send the message tomessage
- 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
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 tocomponent
- 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) tocomponents
- the text components representing the message(s) to be sent
-
kickPlayer
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
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
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
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
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
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
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
Dispatches a command for execution.- Parameters:
command
- the command to be dispatched
-
getRunningPlugin
Retrieves the currently running plugin.- Returns:
- The currently running plugin.
-
getDatabase
Retrieves the database associated with this BetterBanSystem instance.- Returns:
- The IDatabase instance representing the database.
-
getCommandHandler
Retrieves the command handler for managing commands in the command-based system.- Returns:
- The command handler, an instance of the BaseCommandHandler class.
-
getPrefix
-
loadLanguage
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
Loads the permissions system based on the specifiedPermissionsHandlerType
.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 currentconfig
object.If the
config
is null, a new instance ofBaseConfig
is created. After that, theBaseConfig.load(File)
method is called to load the config file. -
saveConfig
public void saveConfig()Saves the configuration to a file. -
getDataFolder
Returns the data folder for the plugin.- Returns:
- The data folder for the plugin.
-
getConfig
Retrieves the BaseConfig object associated with this BetterBanSystem instance.- Returns:
- The BaseConfig object used for storing configuration settings.
-
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
Retrieves the permissions manager associated with this instance of BetterBanSystem.- Returns:
- The permissions' manager.
-
getPluginDescription
Returns the plugin description of the current instance.- Returns:
- The plugin description.
-