Customizable formatting

This commit is contained in:
NEMESIS13cz
2016-08-06 12:52:03 +02:00
parent a69328a436
commit d4388b9fd7
3 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
# CommandManager # CommandManager
Scripting-based Spigot/Bukkit command manager 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.
+6
View File
@@ -86,6 +86,12 @@ public class CommandManager {
public static boolean debugOutput = false; public static boolean debugOutput = false;
public static boolean errors = false; public static boolean errors = false;
public static String helpDescriptionFormatting = "§b";
public static String helpUsageFormatting = "§6";
public static String helpPageHeaderFormatting = "§a";
public static String helpInvalidPageFormatting = "§c";
public static String noPermissionFormatting = "§c";
public static boolean registerCommand(String cmdSourceCode, Object commandHandler, JavaPlugin plugin) { public static boolean registerCommand(String cmdSourceCode, Object commandHandler, JavaPlugin plugin) {
if (cmdSourceCode == null || commandHandler == null || plugin == null) { if (cmdSourceCode == null || commandHandler == null || plugin == null) {
return false; return false;
+5 -5
View File
@@ -209,7 +209,7 @@ public class Executable implements CommandExecutor {
}else{ }else{
ExecutableDefinition def = defs.get(0); ExecutableDefinition def = defs.get(0);
if (!sender.hasPermission(def.getPermission())) { if (!sender.hasPermission(def.getPermission())) {
sender.sendMessage("§cYou do not have permission to execute this command."); sender.sendMessage(CommandManager.noPermissionFormatting + "You do not have permission to execute this command.");
return true; return true;
} }
if (def.getLength() != args.length) { if (def.getLength() != args.length) {
@@ -239,14 +239,14 @@ public class Executable implements CommandExecutor {
private void printPage(CommandSender sender, int page) { private void printPage(CommandSender sender, int page) {
page--; page--;
if (page < 0 || page >= help.size()) { if (page < 0 || page >= help.size()) {
sender.sendMessage("§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{ }else{
HelpPageCommand[] pageData = help.get(page); HelpPageCommand[] pageData = help.get(page);
sender.sendMessage("§a### Help Page " + (page + 1) + "/" + (help.size()) + " ###"); sender.sendMessage(CommandManager.helpPageHeaderFormatting + "### Help Page " + (page + 1) + "/" + (help.size()) + " ###");
for (HelpPageCommand c : pageData) { for (HelpPageCommand c : pageData) {
if (c != null) { if (c != null) {
sender.sendMessage("§6" + c.usage); sender.sendMessage(CommandManager.helpUsageFormatting + c.usage);
sender.sendMessage("§b" + c.description); sender.sendMessage(CommandManager.helpDescriptionFormatting + c.description);
} }
} }
} }