Little refactoring...

This commit is contained in:
extendedclip
2018-03-23 17:03:56 -04:00
parent 68fb8e7e65
commit af68dbcf8b
5 changed files with 130 additions and 132 deletions

View File

@@ -53,46 +53,44 @@ public class PlaceholderAPICommands implements CommandExecutor {
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0) {
Msg.msg(s, "PlaceholderAPI &7version &b&o"+plugin.getDescription().getVersion());
Msg.msg(s, "&fCreated by&7: &bextended_clip");
Msg.msg(s, "PlaceholderAPI &7version &b&o" + plugin.getDescription().getVersion(),
"&fCreated by&7: &bextended_clip");
return true;
} else {
if (args[0].equalsIgnoreCase("help")) {
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)");
Msg.msg(s, "&b/papi");
Msg.msg(s, "&fView plugin info/version info");
Msg.msg(s, "&b/papi list");
Msg.msg(s, "&fList all placeholder expansions that are currently active");
Msg.msg(s, "&b/papi info <placeholder name>");
Msg.msg(s, "&fView information for a specific expansion");
Msg.msg(s, "&b/papi parse <...args>");
Msg.msg(s, "&fParse a String with placeholders");
Msg.msg(s, "&b/papi parserel <player one> <player two> <...args>");
Msg.msg(s, "&fParse a String with relational placeholders");
Msg.msg(s, "&b/papi reload");
Msg.msg(s, "&fReload the config settings");
boolean enabled = plugin.getExpansionCloud() != null;
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)",
"&b/papi",
"&fView plugin info/version info",
"&b/papi list",
"&fList all placeholder expansions that are currently active",
"&b/papi info <placeholder name>",
"&fView information for a specific expansion",
"&b/papi parse <...args>",
"&fParse a String with placeholders",
"&b/papi parserel <player one> <player two> <...args>",
"&fParse a String with relational placeholders",
"&b/papi reload",
"&fReload the config settings");
if (s.isOp()) {
if (!enabled) {
Msg.msg(s, "&b/papi enablecloud");
Msg.msg(s, "&fEnable the expansion cloud");
if (plugin.getExpansionCloud() == null) {
Msg.msg(s, "&b/papi enablecloud",
"&fEnable the expansion cloud");
} else {
Msg.msg(s, "&b/papi disablecloud");
Msg.msg(s, "&fDisable the expansion cloud");
Msg.msg(s, "&b/papi ecloud");
Msg.msg(s, "&fView information about the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the PlaceholderAPI expansion cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> <page>");
Msg.msg(s, "&fList all available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
Msg.msg(s, "&b/papi disablecloud",
"&fDisable the expansion cloud",
"&b/papi ecloud",
"&fView information about the PlaceholderAPI expansion cloud",
"&b/papi ecloud status",
"&fView status of the PlaceholderAPI expansion cloud",
"&b/papi ecloud list <all/author> <page>",
"&fList all available expansions",
"&b/papi ecloud info <expansion name>",
"&fView information about a specific expansion on the cloud",
"&b/papi ecloud download <expansion name>",
"&fDownload a specific expansion from the cloud");
}
}
@@ -112,7 +110,6 @@ public class PlaceholderAPICommands implements CommandExecutor {
return eCloud.onCommand(s, c, label, args);
} else if (args[0].equalsIgnoreCase("enablecloud")) {
if (!s.isOp()) {
Msg.msg(s, "&cYou don't have permission to do that!");
return true;
@@ -182,7 +179,7 @@ public class PlaceholderAPICommands implements CommandExecutor {
if (ex.getPlugin() != null) {
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
}
if (ex.getPlaceholders() != null) {
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
for (String placeholder : ex.getPlaceholders()) {
@@ -274,7 +271,7 @@ public class PlaceholderAPICommands implements CommandExecutor {
Msg.msg(s, "&cIncorrect usage! &7/papi help");
}
}
return true;
}

View File

@@ -45,20 +45,20 @@ public class ExpansionCloudCommands implements CommandExecutor {
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 1) {
Msg.msg(s, "&bExpansion cloud commands");
Msg.msg(s, " ");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
Msg.msg(s, "&fList all/author specific available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
Msg.msg(s, "&b/papi ecloud refresh");
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
Msg.msg(s, "&b/papi ecloud clear");
Msg.msg(s, "&fClear the expansion cloud cache.");
Msg.msg(s, "&bExpansion cloud commands",
" ",
"&b/papi ecloud status",
"&fView status of the cloud",
"&b/papi ecloud list <all/author> (page)",
"&fList all/author specific available expansions",
"&b/papi ecloud info <expansion name>",
"&fView information about a specific expansion available on the cloud",
"&b/papi ecloud download <expansion name>",
"&fDownload a specific expansion from the cloud",
"&b/papi ecloud refresh",
"&fFetch the most up to date list of expansions available.",
"&b/papi ecloud clear",
"&fClear the expansion cloud cache.");
return true;
}
@@ -111,10 +111,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
if (args[1].equalsIgnoreCase("status")) {
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size()
+ " &bcloud expansions available to download on demand.");
Msg.msg(s, "&bA total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
+ " &bauthors have contributed to the expansion cloud.");
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bcloud expansions available to download",
"&bA total of &f" + plugin.getExpansionCloud().getCloudAuthorCount() + " &bauthors have contributed.");
return true;
} else if (args[1].equalsIgnoreCase("info")) {
@@ -143,12 +141,12 @@ public class ExpansionCloudCommands implements CommandExecutor {
Msg.msg(s, "&aExpansion: &f" + expansion.getName());
if (enabled) {
Msg.msg(s, "&aThis expansion is currently enabled!");
Msg.msg(s, "&bYour version&7: &f" + version);
Msg.msg(s, "&aThis expansion is currently enabled!",
"&bYour version&7: &f" + version);
}
Msg.msg(s, "&bCloud version&7: &f" + expansion.getVersion());
Msg.msg(s, "&bAuthor&7: &f" + expansion.getAuthor());
Msg.msg(s, "&bCloud version&7: &f" + expansion.getVersion(),
"&bAuthor&7: &f" + expansion.getAuthor());
String desc = expansion.getVersion();
@@ -223,8 +221,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
Msg.msg(s, "&b" + (expansion.getKey()+1) + "&7: &f" + expansion.getValue().getName() + " &8&m-- &r" + expansion.getValue().getLink());
}
Msg.msg(s, "&bDownload an expansion with &7/papi ecloud download <name>");
Msg.msg(s, "&bView more info on an expansion with &7/papi ecloud info <expansion>");
Msg.msg(s, "&bDownload an expansion with &7/papi ecloud download <name>",
"&bView more info on an expansion with &7/papi ecloud info <expansion>");
return true;
}

View File

@@ -50,20 +50,20 @@ public class ExpansionCloudCommands implements CommandExecutor {
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 1) {
Msg.msg(s, "&bExpansion cloud commands");
Msg.msg(s, " ");
Msg.msg(s, "&b/papi ecloud status");
Msg.msg(s, "&fView status of the cloud");
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
Msg.msg(s, "&fList all/author specific available expansions");
Msg.msg(s, "&b/papi ecloud info <expansion name>");
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
Msg.msg(s, "&b/papi ecloud download <expansion name>");
Msg.msg(s, "&fDownload a specific expansion from the cloud");
Msg.msg(s, "&b/papi ecloud refresh");
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
Msg.msg(s, "&b/papi ecloud clear");
Msg.msg(s, "&fClear the expansion cloud cache.");
Msg.msg(s, "&bExpansion cloud commands",
" ",
"&b/papi ecloud status",
"&fView status of the cloud",
"&b/papi ecloud list <all/author> (page)",
"&fList all/author specific available expansions",
"&b/papi ecloud info <expansion name>",
"&fView information about a specific expansion available on the cloud",
"&b/papi ecloud download <expansion name>",
"&fDownload a specific expansion from the cloud",
"&b/papi ecloud refresh",
"&fFetch the most up to date list of expansions available.",
"&b/papi ecloud clear",
"&fClear the expansion cloud cache.");
return true;
}
@@ -87,9 +87,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
if (args[1].equalsIgnoreCase("status")) {
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bexpansions available on the cloud.");
Msg.msg(s, "&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
+ " &7authors have contributed to the expansion cloud.");
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bexpansions available on the cloud.",
"&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount() + " &7authors have contributed to the expansion cloud.");
if (plugin.getExpansionCloud().getToUpdateCount() > 0) {
Msg.msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount()
+ " &eexpansions installed that have updates available.");
@@ -306,13 +305,13 @@ public class ExpansionCloudCommands implements CommandExecutor {
return true;
}
private void sms(Player p, String text, String hover, String link) {
private void sms(Player p, String text, String hover, String name) {
TextComponent message = new TextComponent( ChatColor.translateAlternateColorCodes('&', text) );
if (hover != null) {
message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', hover)).create() ) );
}
if (link != null) {
message.setClickEvent( new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/papi ecloud download " + link) );
if (name != null) {
message.setClickEvent( new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/papi ecloud download " + name) );
}
p.spigot().sendMessage( message );
}