public final class AA_API
extends java.lang.Object
Constructor and Description |
---|
AA_API(AdminAnything aa)
Constructor, stores an instance of
AdminAnything ,
so this API can work with it. |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
__(java.lang.String identifier,
java.lang.Object... params)
Returns translation for the given identifier, and optionally
a set of parameters.
|
static boolean |
checkGroupPerm(org.bukkit.command.CommandSender sender,
java.lang.String perm)
Checks whether the given CommandSender's primary group has the requested permission assigned.
|
static boolean |
checkGroupPerm(java.lang.String worldName,
java.lang.String groupName,
java.lang.String perm)
Checks whether the given group in the given world has the requested permission assigned.
|
static boolean |
checkPerms(org.bukkit.command.CommandSender sender,
java.lang.String permsQuery,
boolean showResultToSender)
Uses a query parsing algorithm to check for one or many permission nodes given
via the permsQuery parameter.
|
static boolean |
classMapContainsKey(java.lang.String key)
Checks for existence of a command location key in the class map.
|
static boolean |
commandMapContainsKey(java.lang.String key)
Checks whether the command map contains the given key.
|
static boolean |
configContainsKey(java.lang.String key)
Checks whether the given key is present in the plugin configuration.
|
static void |
generateConsoleWarning(java.lang.String warningText)
Generates a console warning.
|
static java.lang.String |
getAaDataDir()
Returns the data folder for AdminAnything.
This is used in various warning messages in console to inform Admins where to search for files they need to update (for example to turn off statistics etc.) Example: |
static java.lang.String |
getAaName()
Returns name of the AdminAnything plugin.
|
static java.lang.String |
getAaVersion()
Gets the plugin version
Example: |
static java.util.Map<java.lang.String,org.bukkit.command.Command> |
getAugmentedCommandMap()
Augments and returns a temporary copy of a commandMap with manually-crafter commands from permdescriptions.yml file,
or rather mostly sub-commands of a single command (/plugman help, /plugman info...),
so these can be shown in /aa_playercommands and /aa_listcommands.
|
static java.lang.String |
getAvailableNewVersion()
Returns the newVersionAvailable value, be it null
or a real new version string.
|
static java.util.Collection<java.lang.String> |
getBanIpCommandsList()
Loads list of IP ban commands from the config file, since different MC versions
tend to use different ban-ip commands and the server could even have its own flavor
of ban-ip from a plugin.
|
static java.util.Collection<java.lang.String> |
getBuiltInCommands()
Get list of built-in commands for a Spigot server.
|
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getChatJoinActionsMap()
Gets map of actions to be added to the chat next to player's
username when they join the server, if enabled.
|
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getChatLeaveActionsMap()
Gets map of actions to be added to the chat next to player's
username when they leave the server, if enabled.
|
static java.lang.String |
getClassMapKey(java.lang.String key)
Retrieves a key from the class map cache.
|
static java.lang.String |
getCleanPluginName(java.lang.String pluginWithCommand,
boolean returnRealPluginName)
Returns a clear name of the plugin from a string which may contain the plugin along with
a command (essentials:ban) or along with a core alias (Core -> minecraft:ban).
|
static java.lang.String[] |
getClearCommand(java.lang.String cmd)
Returns a clear command name from the command given.
|
static java.util.List<java.lang.String> |
getCommandContainingPlugins(java.lang.String command,
boolean... extendCorePluginNames)
Returns a list of plugin names that contain the given command.
|
static java.util.Map<java.lang.String,org.bukkit.command.Command> |
getCommandMapCopy()
Returns a copy of the entry set for the command map.
|
static org.bukkit.command.Command |
getCommandMapKey(java.lang.String key)
Retrieves an actual command from the command map according to the given command name.
|
static java.util.Set<java.lang.String> |
getCommandsConfigurationKeys(java.lang.String which,
boolean deep)
Retrieves a list of keys from the configuration of the commands
to be redirected, muted, overridden etc.
|
static java.lang.String |
getCommandsConfigurationValue(java.lang.String which,
java.lang.String key)
Retrieves a value to be used in place of the original command
which was ignored, muted, overridden etc.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getCommandsConfigurationValues(java.lang.String which)
Retrieves a list of values from the configuration of the commands
to be redirected, muted, overridden etc.
|
static java.lang.Iterable<java.lang.String> |
getCommandsKeySet()
Retrieves a set of all commands for AdminAnything.
|
static java.util.List<java.lang.String> |
getCommandsList(java.lang.String which)
Gets an unmodifiable list of the requested type of commands
(i.e.
|
static boolean |
getConfigBoolean(java.lang.String key)
Returns a boolean value from AA's configuration.
|
static java.lang.Iterable<java.lang.String> |
getConfigSectionKeys(java.lang.String key)
Returns keys of a configuration section from AA's configuration.
|
static java.lang.String |
getConfigString(java.lang.String key)
Returns a string value from AA's configuration.
|
static java.lang.String |
getConfigString(java.lang.String key,
java.lang.String def)
Returns a string value from AA's configuration.
|
static boolean |
getDebug()
Gets this plugin's debug state.
|
static org.bukkit.configuration.file.FileConfiguration |
getManualPermDescriptionsConfig()
Returns current configuration of manual permissions and commands for plugins that don't provide these
in their plugin.yml file.
|
static double |
getMaxRecordsPerPage()
Gets the maximum records (lines) per page displayable in various AdminAnything listings,
such as list of commands, permissions or conflicts.
|
static java.util.Map<java.lang.String,java.lang.Boolean> |
getMutesMap()
Gets an unmodifiable map of muted commands.
|
static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getNickClickActionsMap()
Gets map of actions to be added to the chat next to player's
username when a chat message is sent, if enabled.
|
static java.util.List<java.lang.String> |
getPlayerAvailableCommands(org.bukkit.entity.Player p)
Gets all commands available to a single player in their current world.
|
static java.lang.String[] |
getPlayerPermGroups(org.bukkit.entity.Player p)
Returns all permission groups in which a player is present.
|
static java.lang.String |
getPlayerPrimaryPermGroup(org.bukkit.entity.Player p)
Retrieves player's primary group name.
|
static java.lang.Iterable<java.lang.String> |
getPluginCommands(java.lang.String plugin)
Retrieves a list of all commands for the given plugin.
|
static java.lang.String |
getPluginForCommand(java.lang.String key,
org.bukkit.command.Command value)
Returns name of the plugin to which the given command belongs.
|
static org.bukkit.plugin.Plugin |
getPluginIgnoreCase(java.lang.String pluginName)
Returns plugin name from the cache of lowercased plugins
as opposed to the Bukkit.getPluginManager().getPlugin() case-sensitive getting.
|
static java.lang.Iterable<java.lang.String> |
getServerCommands()
Retrieves a list of all commands on the server.
|
static java.lang.Iterable<java.lang.String> |
getServerPlugins()
Retrieves a set of all plugin names on the server.
|
static java.lang.Iterable<java.lang.String> |
getServerPlugins(java.lang.String... prependBy)
Retrieves a set of all plugin names on the server, prepended by the given string prefix.
|
static boolean |
getVirtualPermsCaseSensitive()
Check whether virtual permissions should consider letter case
when checking them against player's permissions.
|
static java.lang.String |
guessPluginFromClass(java.lang.Class<?> clazz)
Returns the plugin name from the given class,
which should be one of the command is was
just being executed.
|
static boolean |
isAaCoreCommand(java.lang.String[] cmd)
Checks whether the given command is AdminAnything's internal command.
|
static boolean |
isFeatureEnabled(java.lang.String featureConfigKey)
Checks whether a feature in AdminAnything is enabled via config.
|
static boolean |
isListenerRegistered(java.lang.String listenerName)
Checks whether a named listener is already registered with AdminAnything.
|
static boolean |
isPlayerInPermGroup(org.bukkit.entity.Player p,
java.lang.String group)
Checks whether a player is in the given permission group.
|
static boolean |
isVaultEnabled()
Checks whether Vault is enabled on the server.
|
static boolean |
isWarmingUp()
Returns TRUE if the initial warmup of AdminAnything is not yet passed,
FALSE otherwise.
|
static void |
loadCommandsListFromConfig(java.lang.String which)
Loads the requested commands list which will then
be used in various parts of this plugin.
|
static void |
loadJoinLeaveClickLinks()
Loads join and click event links that will be displayed in chat
next to player username's if enabled in config.
|
static void |
loadNickClickLinks()
Loads nick click links that will be displayed in chat
next to player username's if enabled in config.
|
static java.lang.String |
parsePluginJARLocation(java.lang.Class<?> commandClass)
Attempts to retrieve a location of the plugin's class file
within the currently loaded JAR archives structure.
|
static boolean |
pluginHasFullApiAccess(java.lang.String pluginName)
Checks whether the given plugin has full access to AdminAnything's API,
including all data adjusting event calls (i.e.
|
static void |
startRequiredListener(java.lang.String listenerName)
Registers a listener if that listener was not registered already.
|
static void |
startRequiredListener(java.lang.String listenerName,
org.bukkit.event.Listener listenerClassInstance)
Registers a listener if that listener was not registered already.
|
public AA_API(AdminAnything aa)
AdminAnything
,
so this API can work with it. Not publicly available and only ever called from the main
AdminAnything class' constructor.aa
- Instance of AdminAnything
.public static java.lang.String getAaName()
Bukkit.getLogger().warning("[" + AA_API.getAaName() + "] Something's gone wrong :-P");
public static boolean getConfigBoolean(java.lang.String key)
boolean chatNickClicksFeature = AA_API.getConfigBoolean("features.chatnicklinks.enabled");
key
- The config key we want to return a boolean value for.public static java.lang.String getConfigString(java.lang.String key)
String chatNickClicksColor = AA_API.getConfigString("chatNickClickActions." + key + ".color");
key
- The config key we want to return a string value for.public static java.lang.String getConfigString(java.lang.String key, java.lang.String def)
String listCommandsSeparator = AA_API.getConfigString("listCommandsSeparator", " ");
key
- The config key we want to return a string value for.def
- Default value if string is not found in the configuration.public static java.lang.Iterable<java.lang.String> getConfigSectionKeys(java.lang.String key)
for (final String key : AA_API.getConfigSectionKeys("chatNickClickActions")) {
// do something with the configuration key name ("key" variable) here
}
key
- The configuration section the keys for we want to return.public static java.lang.String getAaDataDir()
virtualPermissionsList.save(new File(AA_API.getAaDataDir(), "perms.yml"));
public static java.lang.String getAaVersion()
Bukkit.getLogger().log("info", "You are running AdminAnything, version " + AA_API.getAaVersion());
public static boolean isFeatureEnabled(java.lang.String featureConfigKey)
if (AA_API.isFeatureEnabled("listcommands")) {
Bukkit.getLogger().log("info", "Listing of commands is enabled in AdminAnything.");
}
featureConfigKey
- The feature name in the config file (for example "addperm" to check
the "features.addperm.enabled" key).public static double getMaxRecordsPerPage()
if (recordsNumber > AA_API.getMaxRecordsPerPage()) {
Bukkit.getLogger().log("info", "Pagination should be enabled here, as we've requested more records than we allow per one page.");
}
public static boolean getDebug()
if (AA_API.getDebug()) {
Bukkit.getLogger().log("debug", "AdminAnything debug information line.");
}
public static java.util.Collection<java.lang.String> getBuiltInCommands()
if (AA_API.getBuiltInCommands().contains("ban")) {
Bukkit.getLogger().log("info", "/ban is a Minecraft built-in server command.");
}
public static java.lang.Iterable<java.lang.String> getCommandsKeySet()
for (final String cmd : AA_API.getCommandsKeySet()) {
// register tab listener for the command in question
// note: exception handling omitted for brevity
final Class<?> cl = Class.forName("com.martinambrus.adminAnything.tabcomplete." + cmd.substring(0, 1).toUpperCase() + cmd.substring(1));
TabCompleter tc = (TabCompleter) cl.getConstructor().newInstance();
((JavaPlugin) plugin).getCommand(cmd).setTabCompleter(tc);
}
public static boolean configContainsKey(java.lang.String key)
if (AA_API.configContainsKey("listcommandsDefaults.showdescriptions")) {
// config contains a default setting for showing/hiding command descriptions
// when using /aa_listcommands
}
public static boolean pluginHasFullApiAccess(java.lang.String pluginName)
pluginName
- Name of the plugin to check for. Letter case is ignored.public static java.util.Collection<java.lang.String> getBanIpCommandsList()
public static void loadJoinLeaveClickLinks()
public static void loadNickClickLinks()
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getChatJoinActionsMap()
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getChatLeaveActionsMap()
public static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getNickClickActionsMap()
public static boolean isListenerRegistered(java.lang.String listenerName)
if (!AA_API.isListenerRegistered("chatJoinLeaveClicks")) {
// register an event listener to display join and leave click links next to nicknames
// in chat
}
listenerName
- Name of the listener to check for.public static void startRequiredListener(java.lang.String listenerName)
// register an event listener to display join and leave click links next to nicknames in chat AA_API.startRequiredListener("chatJoinLeaveClicks");
listenerName
- ClassName of the listener to register. This class will then be loaded
from com.martinambrus.adminAnything.listeners.[[ listenerName ]]public static void startRequiredListener(java.lang.String listenerName, org.bukkit.event.Listener listenerClassInstance)
AA_API.startRequiredListener("yourListenerName", yourListenerClassInstance);
listenerName
- An arbitrary name of the listener to register. AA uses its feature names
to register event listeners this way.listenerClassInstance
- The actual instance of the listener class we'd like to register.public static void generateConsoleWarning(java.lang.String warningText)
AA_API.generateConsoleWarning("You shouldn't eat yellow snow!");
warningText
- The actual text to display in console.public static boolean checkPerms(org.bukkit.command.CommandSender sender, java.lang.String permsQuery, boolean showResultToSender)
if (aa_plugin_instance.getPluginUtils().checkPerms(sender, "my_permission", true) {
// do your stuff
// ... if the commandSender (sender) OR their permission groups do not have the relevant permission,
// an error message will be displayed to the sender
}
if (aa_plugin_instance.getPluginUtils().checkPerms(sender, "my_permission", true, true) {
// do your stuff
// ... if the commandSender (sender) themselves does not have the relevant permission,
// an error message will be displayed to them
}
if (aa_plugin_instance.getPluginUtils().checkPerms(sender, "(perm1 OR perm2) AND perm3", false) {
// do your stuff
// ... in this case, no error message is displayed to the command sender (last parameter is false)
// and you can handle this case with your own logic
}
sender
- The org.bukkit.command.CommandSender CommandSender who we're checking the permission(s) for.permsQuery
- An SQL-like query containing all the parameters that we need to check for.showResultToSender
- If TRUE, a message will be sent out to the player / console for who we're checking these permissions.public static boolean checkGroupPerm(org.bukkit.command.CommandSender sender, java.lang.String perm)
if (AA_API.checkGroupPerm(sender, "my_permission") {
// do your stuff
}
sender
- The org.bukkit.command.CommandSender CommandSender whose group we're checking the permission(s) for.perm
- The actual permission we're checking for.public static boolean checkGroupPerm(java.lang.String worldName, java.lang.String groupName, java.lang.String perm)
if (AA_API.checkGroupPerm("world", "default", "my_permission") {
// do your stuff
}
worldName
- Name of the world for the perm group check.groupName
- Name of the group we're performing the check for.perm
- The actual permission we're checking.public static boolean isVaultEnabled()
if (AA_API.isVaultEnabled()) {
// Vault is enabled, we should hook in to check player permissions
}
public static boolean isPlayerInPermGroup(org.bukkit.entity.Player p, java.lang.String group)
if (AA_API.isPlayerInPermGroup( playerInstance, "owners" )) {
// player is in the "Owners" group, let's roll...
}
p
- Player for which we want to check presence in the permision group.group
- The actual permission group name to check if the player is in.public static java.lang.String[] getPlayerPermGroups(org.bukkit.entity.Player p)
p
- The player to check groups for.public static java.lang.String getPlayerPrimaryPermGroup(org.bukkit.entity.Player p)
p
- Player to retrieve primary group info for.public static boolean commandMapContainsKey(java.lang.String key) throws java.rmi.AccessException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.reflect.InvocationTargetException
if (AA_API.commandMapContainsKey("essentials:ban")) {
// essentials:ban found to be a real command from the command map
// and we can immediately execute it
}
key
- The actual command name we want to look up in the command map.java.lang.IllegalAccessException
- When access is denied to org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.SecurityException
- When private fields cannot be accessed due to a security restriction.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.rmi.AccessException
- When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of commandMap.public static org.bukkit.command.Command getCommandMapKey(java.lang.String key) throws java.rmi.AccessException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.reflect.InvocationTargetException
// ban ZathrusWriter using essentials' ban command AA_API.getCommandMapKey("essentials:ban").execute(Bukkit.getConsoleSender(), "ban", "ZathrusWriter");
key
- The command name we want to retrieve the actual command for.java.lang.IllegalAccessException
- When access is denied to the org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.SecurityException
- When private fields cannot be accessed due to a security restriction.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.rmi.AccessException
- When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of org.bukkit.command.CommandMap.public static java.util.Map<java.lang.String,org.bukkit.command.Command> getCommandMapCopy() throws java.rmi.AccessException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.reflect.InvocationTargetException
for (final Entry<String, Command> pair : AA_API.getCommandMapCopy().entrySet()) {
// pair.getKey() will contain the command name of each command registered via CommandMap on the server
// pair.getValue() will contain the actual command registered via CommandMap
}
java.lang.IllegalAccessException
- When access is denied to the org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.SecurityException
- When private fields cannot be accessed due to a security restriction.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.rmi.AccessException
- When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of org.bukkit.command.CommandMap.public static java.util.Map<java.lang.String,org.bukkit.command.Command> getAugmentedCommandMap() throws java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.rmi.AccessException, java.lang.IllegalAccessException
java.lang.IllegalAccessException
- When access is denied to the commandMap
or knownCommands
field.java.lang.NoSuchMethodException
- When there is a get() method missing from the knownCommands
field.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on knownCommands
with invalid commandMap
parameter.java.rmi.AccessException
- When we don't have the permission to access the knownCommands
field of commandMap
.public static java.lang.String[] getClearCommand(java.lang.String cmd)
// will hold "ban" String clearBan = AA_API.getClearCommand("minecraft:ban")[0];
cmd
- The actual command to return stripped of dots and colons.public static java.lang.String getPluginForCommand(java.lang.String key, org.bukkit.command.Command value) throws java.io.InvalidClassException
for (final Entry<String, Command> pair : AA_API.getCommandMapCopy().entrySet()) {
Bukkit.getLogger().log("info", "Command '" + pair.getKey() + "' is from the plugin '" + AA_API.getPluginForCommand(pair.getKey(), pair.getValue()) + "'");
}
key
- The commands name to lookup a plugin name for.value
- The actual command we're trying to lookup a plugin for. Used for a short-circuited
version of plugin checking when org.bukkit.command.Command Command} is actually
an instance of org.bukkit.command.PluginCommand PluginCommand}, from which the plugin
name retrieval is trivial.java.io.InvalidClassException
- When this plugin's class file is not found in the current classLoader.public static java.util.List<java.lang.String> getCommandContainingPlugins(java.lang.String command, boolean... extendCorePluginNames) throws java.rmi.AccessException, java.lang.IllegalAccessException, java.io.InvalidClassException, java.lang.NoSuchMethodException, java.lang.SecurityException, java.lang.reflect.InvocationTargetException
for (final String pluginName : AA_API.getCommandContainingPlugins("ban")) {
Bukkit.getLogger().log("info", "Command 'ban' found in plugin '" + pluginName);
}
command
- The actual command we need to check all plugins for.extendCorePluginNames
- If true, an extended name with a "Core -> " prefix is returned in the listing, otherwise
only the clear command name will be returned.java.rmi.AccessException
- AccessException When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of org.bukkit.command.CommandMap.java.lang.IllegalAccessException
- When access is denied to the org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.io.InvalidClassException
- When a class for any of the server plugins cannot be found within the current classLoader.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.lang.SecurityException
- When private fields cannot be accessed due to a security restriction.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.public static boolean isAaCoreCommand(java.lang.String[] cmd)
if (AA_API.isAaCoreCommand("aa_reload")) {
Bukkit.getLogger().log("info", "Command /aa_reload() is indeed an AdminAnything core command :)");
}
cmd
- The command to check.public static java.lang.String guessPluginFromClass(java.lang.Class<?> clazz) throws java.io.InvalidClassException
Bukkit.getLogger().log("info", "Requested class originates from plugin '" + AA_API.guessPluginFromClass(somePluginCommandClass) + "'");
clazz
- Class of the command being executed.java.io.InvalidClassException
- When this plugin's class file is not found in the current classLoader.public static java.lang.Iterable<java.lang.String> getServerCommands() throws java.rmi.AccessException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
- When access is denied to the org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.rmi.AccessException
- When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of org.bukkit.command.CommandMap.public static java.lang.Iterable<java.lang.String> getPluginCommands(java.lang.String plugin) throws java.rmi.AccessException, java.lang.IllegalAccessException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.io.InvalidClassException
plugin
- The plugin name for which to retrieve commands.java.lang.IllegalAccessException
- When access is denied to the org.bukkit.command.CommandMap or org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.NoSuchMethodException
- When there is a get() method missing from the org.bukkit.command.SimpleCommandMap.knownCommands field.java.lang.reflect.InvocationTargetException
- When we try to invoke get() on org.bukkit.command.SimpleCommandMap.knownCommands with invalid org.bukkit.command.CommandMap parameter.java.rmi.AccessException
- When we don't have the permission to access the org.bukkit.command.SimpleCommandMap.knownCommands field of org.bukkit.command.CommandMap.java.io.InvalidClassException
- When this plugin's class file is not found in the current classLoader.public static void loadCommandsListFromConfig(java.lang.String which) throws java.security.InvalidParameterException
// loads the list of all disabled commands AA_API.loadCommandsListFromConfig("removals");
which
- Says which list (for which feature) we want to load.java.security.InvalidParameterException
- When the given which parameter does not conform to any known list of commands.public static java.util.List<java.lang.String> getCommandsList(java.lang.String which) throws java.security.InvalidParameterException
Bukkit.getLogger().log("info", "Commands currently disabled via AdminAnything: " + Utils.flatten(AA_API.getCommandsList("removals"), true));
which
- Says which list (for which feature) we want to return.java.security.InvalidParameterException
- When the given which parameter does not conform to any known list of commands.public static java.util.Map<java.lang.String,java.lang.Object> getCommandsConfigurationValues(java.lang.String which) throws java.security.InvalidParameterException
if (AA_API.getCommandsConfigurationValues("virtualperms").containsKey("customban")) {
Bukkit.getLogger().log("info", "The 'customban' virtual permission was successfully located on this server.");
}
which
- The actual configuration file to return the value set for.java.security.InvalidParameterException
- When the given which parameter does not conform to any known list of commands.public static java.util.Set<java.lang.String> getCommandsConfigurationKeys(java.lang.String which, boolean deep) throws java.security.InvalidParameterException
// as used in /aa_delredirect
final Set<String> redirects = AA_API.getCommandsConfigurationKeys("redirects", false);
if (redirects.size() == 0) {
sender.sendMessage(ChatColor.GREEN + "No commands are currently being redirected via " + AA_API.getAaName() + ".");
}
which
- The actual configuration file to return the keys set for.deep
- When set to TRUE, configuration keys including heir subkeys will be returned.
When set to FALSE, only first-level keys will be returned.java.security.InvalidParameterException
- When the given which parameter does not conform to any known list of commands.public static java.lang.String getCommandsConfigurationValue(java.lang.String which, java.lang.String key) throws java.security.InvalidParameterException
if (!AA_API.getCommandsConfigurationValue("removals", "ban").equals("")) {
sender.sendMessage(ChatColor.GREEN + "The command 'ban' is currently disabled.");
}
which
- The actual configuration file to look in for the value.key
- The configuration key (i.e. our command) we want to return a replacement for.java.security.InvalidParameterException
- When the given which parameter does not conform to any known list of commands.public static boolean getVirtualPermsCaseSensitive()
public static java.util.Map<java.lang.String,java.lang.Boolean> getMutesMap()
public static org.bukkit.plugin.Plugin getPluginIgnoreCase(java.lang.String pluginName)
// realPluginName will be set to "AdminAnything" for this one String realPluginName = AA_API.getPluginIgnoreCase("ADminAnyThINg");
pluginName
- Name of the plugin (in any text case, i.e. plugin / Plugin / PLuGIn)
we wish to retrieve the original name for.public static java.lang.String parsePluginJARLocation(java.lang.Class<?> commandClass) throws java.io.InvalidClassException
// usage in Commands class Command value = [value_from_a_method_call]; String commandLocationParsed = this.plugin.getPluginUtils().parsePluginJARLocation(value.getClass()); // then we can actually get a plugin name from this command's class location String pluginName = this.plugin.getPluginUtils().getPluginNameViaClassPathsMap(commandLocationParsed);
commandClass
- The actual command class that has executed the command.java.io.InvalidClassException
- When this command's class cannot be found within the current class loader.public static boolean classMapContainsKey(java.lang.String key)
if (AA_API.classMapContainsKey(someRandomAdminAnythingCommandClassMapLocation)) {
pluginName = AA_API.getClassMapKey(someRandomAdminAnythingCommandClassMapLocation);
}
key
- The key we want to check for in the class map.public static java.lang.String getClassMapKey(java.lang.String key)
if (AA_API.classMapContainsKey(someRandomAdminAnythingCommandClassMapLocation)) {
pluginName = AA_API.getClassMapKey(someRandomAdminAnythingCommandClassMapLocation);
}
key
- The key we want to get from the class map.public static java.lang.String getCleanPluginName(java.lang.String pluginWithCommand, boolean returnRealPluginName)
// essentials will be set to "essentials" String essentials = AA_API.getCleanPluginName("essentials:ban"); // ban will be set to "ban" String ban = aa_plugin_instance.getPluginUtils().getCleanPluginName("Core -> ban");
pluginWithCommand
- The actual command with a colon or the AA_API.__("general.core") + " ->" prefix.public static java.lang.Iterable<java.lang.String> getServerPlugins()
public static java.lang.Iterable<java.lang.String> getServerPlugins(java.lang.String... prependBy)
prependBy
- A single-dimensional array with a string to prepend to each plugin name.
Used when tab-completing plugin names from the /aa_listcommands command,
where we need to prefix plugin names with pl:, plug: or plugin:public static java.lang.String getAvailableNewVersion()
String newVersion = AA_API.getAvailableNewVersion();
if (newVersion != null) {
Bukkit.getLogger().log("info", "New AdminAnything version (" + newVersion + ") was released. Download your copy today!");
}
public static org.bukkit.configuration.file.FileConfiguration getManualPermDescriptionsConfig()
public static boolean isWarmingUp()
public static java.util.List<java.lang.String> getPlayerAvailableCommands(org.bukkit.entity.Player p)
p
- The player to retrieve commands for.public static java.lang.String __(java.lang.String identifier, java.lang.Object... params)
identifier
- The actual identifier from the .properties file to work with.params
- Optional parameters used to format translations with placeholders.