Customizable formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# CommandManager
|
||||
Scripting-based Spigot/Bukkit command manager
|
||||
|
||||
Feel free to use and PR enhancements/customizations! If you're a nice person, you can give me credit :P
|
||||
Feel free to use and PR enhancements/customizations! If you're a nice person, you can give me credit.
|
||||
|
||||
@@ -86,6 +86,12 @@ public class CommandManager {
|
||||
public static boolean debugOutput = false;
|
||||
public static boolean errors = false;
|
||||
|
||||
public static String helpDescriptionFormatting = "<EFBFBD>b";
|
||||
public static String helpUsageFormatting = "<EFBFBD>6";
|
||||
public static String helpPageHeaderFormatting = "<EFBFBD>a";
|
||||
public static String helpInvalidPageFormatting = "<EFBFBD>c";
|
||||
public static String noPermissionFormatting = "<EFBFBD>c";
|
||||
|
||||
public static boolean registerCommand(String cmdSourceCode, Object commandHandler, JavaPlugin plugin) {
|
||||
if (cmdSourceCode == null || commandHandler == null || plugin == null) {
|
||||
return false;
|
||||
|
||||
@@ -209,7 +209,7 @@ public class Executable implements CommandExecutor {
|
||||
}else{
|
||||
ExecutableDefinition def = defs.get(0);
|
||||
if (!sender.hasPermission(def.getPermission())) {
|
||||
sender.sendMessage("<EFBFBD>cYou do not have permission to execute this command.");
|
||||
sender.sendMessage(CommandManager.noPermissionFormatting + "You do not have permission to execute this command.");
|
||||
return true;
|
||||
}
|
||||
if (def.getLength() != args.length) {
|
||||
@@ -239,14 +239,14 @@ public class Executable implements CommandExecutor {
|
||||
private void printPage(CommandSender sender, int page) {
|
||||
page--;
|
||||
if (page < 0 || page >= help.size()) {
|
||||
sender.sendMessage("<EFBFBD>cNon-existant page (" + (page + 1) + ").\nThere are " + help.size() + " pages.");
|
||||
sender.sendMessage(CommandManager.helpInvalidPageFormatting + "Non-existant page (" + (page + 1) + ").\nThere are " + help.size() + " pages.");
|
||||
}else{
|
||||
HelpPageCommand[] pageData = help.get(page);
|
||||
sender.sendMessage("<EFBFBD>a### Help Page " + (page + 1) + "/" + (help.size()) + " ###");
|
||||
sender.sendMessage(CommandManager.helpPageHeaderFormatting + "### Help Page " + (page + 1) + "/" + (help.size()) + " ###");
|
||||
for (HelpPageCommand c : pageData) {
|
||||
if (c != null) {
|
||||
sender.sendMessage("<EFBFBD>6" + c.usage);
|
||||
sender.sendMessage("<EFBFBD>b" + c.description);
|
||||
sender.sendMessage(CommandManager.helpUsageFormatting + c.usage);
|
||||
sender.sendMessage(CommandManager.helpDescriptionFormatting + c.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user