Customizable formatting
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
@@ -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 = "<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) {
|
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;
|
||||||
|
|||||||
@@ -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("<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;
|
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("<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{
|
}else{
|
||||||
HelpPageCommand[] pageData = help.get(page);
|
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) {
|
for (HelpPageCommand c : pageData) {
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
sender.sendMessage("<EFBFBD>6" + c.usage);
|
sender.sendMessage(CommandManager.helpUsageFormatting + c.usage);
|
||||||
sender.sendMessage("<EFBFBD>b" + c.description);
|
sender.sendMessage(CommandManager.helpDescriptionFormatting + c.description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user