Modifier and Type | Method and Description |
---|---|
static void |
addChatTopNavigation(org.bukkit.command.CommandSender sender,
int fromIndex,
FancyMessage topMessage,
org.bukkit.command.Command cmd,
java.lang.String[] args,
java.lang.String intRegex,
int requestedPageOriginal,
boolean isLeft)
Adds top navigation chat links for moving back/forward
when pagination is used in a command.
|
static java.lang.String |
capitalize(java.lang.String txt)
Makes the given string capitalized with the first letter being uppercased.
|
static boolean |
CheckParentesis(java.lang.String str)
Checks whether the given string has a matching set of parenthesis (for our purposes, brackets only).
|
static java.lang.String[] |
compactQuotedArgs(java.lang.String[] args)
Takes command arguments that may contain quotes and will compact them,
so for example "hello dolly" will become a single argument.
|
static java.lang.String |
flatten(java.util.Collection<java.lang.String> l,
boolean... addCommas)
Returns a flat version of a list, similarly to how .toString() does it.
|
static java.lang.String |
flatten(java.lang.String[] l,
boolean... addCommas)
Returns a flat version of an array, similarly to how .toString() does it.
|
static java.lang.String |
flatten(java.lang.String[] l,
java.lang.String delimiter)
Returns a flat version of an array, similarly to how .toString() does it.
|
static java.util.List<java.lang.String> |
getListValueCompletions(java.lang.String param,
java.lang.String listName,
org.bukkit.command.Command command,
java.lang.String alias,
java.lang.String[] args)
Returns a list of possible completions for a command parameter
that should be one of the values stored in one in AdminAnything's lists,
for example in the list of disabled commands, muted commands etc.
|
static java.lang.String |
getMinecraftVersion()
Grabs the numerical version portion of the full server's version.
|
static java.lang.String |
getMinecraftVersion(java.lang.String serverVersion)
Grabs the numerical version portion of the full server's version.
|
static java.util.List<java.lang.String> |
getServerCommandCompletions(java.lang.String param,
org.bukkit.command.Command command,
java.lang.String alias)
Returns a list of possible completions for a command parameter
that should be one of the commands currently present on the server.
|
static int |
getUnixTimestamp()
Returns current unix timestamp.
|
static int |
getUnixTimestamp(java.lang.Long i)
Converts given timestamp in milliseconds to Unix Timestamp in seconds.
|
static java.lang.String |
implode(java.util.List<?> listInputArray,
java.lang.String glueString)
Method to join list elements of type string
|
static java.lang.String |
implode(java.lang.Object[] inputArray,
java.lang.String glueString)
Method to join array elements of type string
|
static boolean |
is64Bit()
Checks whether we're on 64-bit or 32-bit processor architecture.
|
static void |
logDebug(java.lang.String msg,
AdminAnything aa)
Logs a debug message into the console if debug is enabled in AdminAnything.
|
static java.util.List<java.lang.String> |
makeListMutable(java.lang.Iterable<java.lang.String> theList)
Takes an unmodifiable list and turns it into a modifiable one.
|
static java.lang.String[] |
shortenStringArray(java.lang.String[] orig,
java.lang.Integer len)
Copies the original array into a new array, shortening it to the given length.
|
static Utils |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static Utils[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static Utils[] values()
for (Utils c : Utils.values()) System.out.println(c);
public static Utils valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic static int getUnixTimestamp()
// ... as used in /aa_mutecommand ...
// check if this class should still be muted
if ((mutedClasses.get(newMutedClass) + maxMuteCheckTimeout) > Utils.getUnixTimestamp()) {
lastClassMuted = true;
}
public static int getUnixTimestamp(java.lang.Long i)
// ... as used in the commandPreprocessor event listener ... Aa_mutecommand.lastMuteTimestamp = Utils.getUnixTimestamp(0L);
i
- Integer timestamp in milliseconds to convert.public static java.lang.String getMinecraftVersion()
String serverVersion = Utils.getMinecraftVersion();
public static java.lang.String getMinecraftVersion(java.lang.String serverVersion)
Utils.getMinecraftVersion(Bukkit.getServer().getBukkitVersion());
serverVersion
- An optional version string to extract the version from.public static java.lang.String flatten(java.util.Collection<java.lang.String> l, boolean... addCommas)
// the following line could also be written as: HashSet<String> cmds = new HashSet<String>(); ArrayList<String> cmds = new ArrayList<String>(); cmds.add("ban"); cmds.add("say"); cmds.add("pardon"); // prints out: "you have requested to disable the following commands: ban, say, pardon" System.out.println("you have requested to disable the following commands: " + Utils.flatten(cmds, true));
l
- The list to convert into a string.addCommas
- If this parameter is set, commas will be used to join list elements together.public static java.lang.String flatten(java.lang.String[] l, boolean... addCommas)
String[] cmds = new String[3]; cmds[0] = "ban"; cmds[1] = "say"; cmds[2] = "pardon"; // prints out: "you have requested to disable the following commands: ban, say, pardon" System.out.println("you have requested to disable the following commands: " + Utils.flatten(cmds, true));
l
- The array to convert into a string.addCommas
- If this parameter is set, commas will be used to join array elements together.public static java.lang.String flatten(java.lang.String[] l, java.lang.String delimiter)
String[] cmds = new String[2]; cmds[0] = "minecraft"; cmds[1] = "ban"; // prints out: "the plugin command was minecraft:ban" System.out.println("the plugin command was " + Utils.flatten(cmds, ":"));
l
- The array to convert into a string.delimiter
- The actual delimiter to use when joining array elements together.public static java.util.List<java.lang.String> makeListMutable(java.lang.Iterable<java.lang.String> theList)
theList
- The list we want to clone and make modifiable.public static java.lang.String[] compactQuotedArgs(java.lang.String[] args)
String[] args = new String[3]; args[0] = "command"; args[1] = "\"hello"; args[2] = "dolly\""; // newArgs will be: ["command", "\"hello dolly\""] String[] newArgs = Utils.compactQuotedArgs(args);
args
- A String[] array with all of the command's arguments.public static void logDebug(java.lang.String msg, AdminAnything aa)
msg
- The message to log.aa
- Instance of AdminAnything
.public static java.lang.String[] shortenStringArray(java.lang.String[] orig, java.lang.Integer len)
String[] cmds = new String[3]; cmds[0] = "ban"; cmds[1] = "say"; cmds[2] = "pardon"; // cmds2 will be ["ban", "say"] String[] cmds2 = Utils.shortenStringArray(cmds, 2);
orig
- Original array to copy from.len
- Length to which we want to shorten the original array.public static boolean CheckParentesis(java.lang.String str)
// as used in the Permissions class
String query = "(I open but I won't close";
if (!Utils.CheckParentesis(query)) {
Bukkit.getLogger().severe("[AdminAnything] Invalid permissions query check passed to the checkPerms() method: " + query);
return false;
}
str
- The actual query string to count matching brackets for.public static void addChatTopNavigation(org.bukkit.command.CommandSender sender, int fromIndex, FancyMessage topMessage, org.bukkit.command.Command cmd, java.lang.String[] args, java.lang.String intRegex, int requestedPageOriginal, boolean isLeft)
sender
- The person who's running the command that has paginated results.fromIndex
- An index from which we start to show our current set of messages.topMessage
- The actual FancyMessage to add pagination links to.cmd
- A reference to the command that was ran.args
- A reference to arguments of the command that was ran.intRegex
- Regex for checking whether a number is integer.requestedPageOriginal
- Original page requested.isLeft
- Whether to generate left (previous) navigation arrow in chat (true) or right (next) arrow (false).public static java.util.List<java.lang.String> getServerCommandCompletions(java.lang.String param, org.bukkit.command.Command command, java.lang.String alias)
// as used in the aa_actions class (from the tabcomplete package)
\@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String alias, String[] args) {
if (args.length > 1) {
return null;
}
return Utils.getServerCommandCompletions(args[0], command, alias);
} // end method
param
- The actual command parameter (argument) we're trying to tab-complete.command
- The command we're trying to tab-complete this parameter for.alias
- The alias with which the command we're trying to tab-complete this parameter for was called.public static java.util.List<java.lang.String> getListValueCompletions(java.lang.String param, java.lang.String listName, org.bukkit.command.Command command, java.lang.String alias, java.lang.String[] args)
// as used in the aa_delredirect class (from the tabcomplete package)
\@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String alias, String[] args) {
// no completion if we have too many arguments
if (args.length > 1) {
return null;
}
return Utils.getListValueCompletions(args[0], "redirects", command, alias);
} // end method
param
- The actual command parameter (argument) we're trying to tab-complete.command
- The command we're trying to tab-complete this parameter for.alias
- The alias with which the command we're trying to tab-complete this parameter for was called.public static java.lang.String implode(java.lang.Object[] inputArray, java.lang.String glueString)
inputArray
- Array which contains stringsglueString
- String between each array elementpublic static java.lang.String implode(java.util.List<?> listInputArray, java.lang.String glueString)
listInputArray
- List<String> which contains stringsglueString
- String between each array elementpublic static boolean is64Bit()
public static java.lang.String capitalize(java.lang.String txt)
txt
- The actual text to have capitalized.