mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 00:46:55 +01:00
Little refactoring...
This commit is contained in:
parent
68fb8e7e65
commit
af68dbcf8b
@ -142,42 +142,9 @@ public class PlaceholderAPI {
|
|||||||
* @return modified list with all placeholders set to the corresponding values
|
* @return modified list with all placeholders set to the corresponding values
|
||||||
*/
|
*/
|
||||||
public static List<String> setBracketPlaceholders(Player p, List<String> text) {
|
public static List<String> setBracketPlaceholders(Player p, List<String> text) {
|
||||||
if (text == null) return null;
|
return setPlaceholders(p, text, BRACKET_PLACEHOLDER_PATTERN);
|
||||||
List<String> temp = new ArrayList<>();
|
|
||||||
text.forEach(line -> {
|
|
||||||
temp.add(setBracketPlaceholders(p, line));
|
|
||||||
});
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set placeholders in the text specified
|
|
||||||
* placeholders are matched with the pattern {<placeholder>} when set with this method
|
|
||||||
* @param player Player to parse the placeholders for
|
|
||||||
* @param text text to parse the placeholder values to
|
|
||||||
* @return modified text with all placeholders set to the corresponding values
|
|
||||||
*/
|
|
||||||
public static String setBracketPlaceholders(Player player, String text) {
|
|
||||||
if (text == null) return null;
|
|
||||||
if (placeholders.isEmpty()) return colorize(text);
|
|
||||||
Matcher placeholderMatcher = BRACKET_PLACEHOLDER_PATTERN.matcher(text);
|
|
||||||
Map<String, PlaceholderHook> hooks = getPlaceholders();
|
|
||||||
while (placeholderMatcher.find()) {
|
|
||||||
String format = placeholderMatcher.group(1);
|
|
||||||
int index = format.indexOf("_");
|
|
||||||
if (index == -1 || index >= format.length()) continue;
|
|
||||||
String identifier = format.substring(0, index).toLowerCase();
|
|
||||||
String params = format.substring(index+1);
|
|
||||||
if (hooks.containsKey(identifier)) {
|
|
||||||
String value = hooks.get(identifier).onPlaceholderRequest(player, params);
|
|
||||||
if (value != null) {
|
|
||||||
text = text.replaceAll("\\{"+format+"\\}", Matcher.quoteReplacement(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return colorize(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set placeholders in the list<String> text provided
|
* set placeholders in the list<String> text provided
|
||||||
* placeholders are matched with the pattern %(identifier)_(params)>% when set with this method
|
* placeholders are matched with the pattern %(identifier)_(params)>% when set with this method
|
||||||
@ -186,13 +153,35 @@ public class PlaceholderAPI {
|
|||||||
* @return modified list with all placeholders set to the corresponding values
|
* @return modified list with all placeholders set to the corresponding values
|
||||||
*/
|
*/
|
||||||
public static List<String> setPlaceholders(Player p, List<String> text) {
|
public static List<String> setPlaceholders(Player p, List<String> text) {
|
||||||
if (text == null) return null;
|
return setPlaceholders(p, text, PLACEHOLDER_PATTERN);
|
||||||
List<String> temp = new ArrayList<>();
|
|
||||||
text.forEach(line -> {
|
|
||||||
temp.add(setPlaceholders(p, line));
|
|
||||||
});
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set placeholders in the list<String> text provided
|
||||||
|
* placeholders are matched with the pattern %(identifier)_(params)>% when set with this method
|
||||||
|
* @param p Player to parse the placeholders for
|
||||||
|
* @param text text to parse the placeholder values in
|
||||||
|
* @return modified list with all placeholders set to the corresponding values
|
||||||
|
*/
|
||||||
|
public static List<String> setPlaceholders(Player p, List<String> text, Pattern pattern) {
|
||||||
|
if (text == null) return null;
|
||||||
|
List<String> temp = new ArrayList<>();
|
||||||
|
text.forEach(line -> {
|
||||||
|
temp.add(setPlaceholders(p, line, pattern));
|
||||||
|
});
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set placeholders in the text specified
|
||||||
|
* placeholders are matched with the pattern {<placeholder>} when set with this method
|
||||||
|
* @param player Player to parse the placeholders for
|
||||||
|
* @param text text to parse the placeholder values to
|
||||||
|
* @return modified text with all placeholders set to the corresponding values
|
||||||
|
*/
|
||||||
|
public static String setBracketPlaceholders(Player player, String text) {
|
||||||
|
return setPlaceholders(player, text, BRACKET_PLACEHOLDER_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set placeholders in the text specified
|
* set placeholders in the text specified
|
||||||
@ -202,22 +191,34 @@ public class PlaceholderAPI {
|
|||||||
* @return text with all placeholders set to the corresponding values
|
* @return text with all placeholders set to the corresponding values
|
||||||
*/
|
*/
|
||||||
public static String setPlaceholders(Player player, String text) {
|
public static String setPlaceholders(Player player, String text) {
|
||||||
|
return setPlaceholders(player, text, PLACEHOLDER_PATTERN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set placeholders in the text specified
|
||||||
|
* placeholders are matched with the pattern %<(identifier)_(params)>% when set with this method
|
||||||
|
* @param player Player to parse the placeholders for
|
||||||
|
* @param text text to parse the placeholder values to
|
||||||
|
* @param placeholderPattern the pattern to match placeholders to. Capture group 1 must contain an underscore separating the identifier from the params
|
||||||
|
* @return text with all placeholders set to the corresponding values
|
||||||
|
*/
|
||||||
|
public static String setPlaceholders(Player player, String text, Pattern placeholderPattern) {
|
||||||
if (text == null) return null;
|
if (text == null) return null;
|
||||||
if (placeholders.isEmpty()) return colorize(text);
|
if (placeholders.isEmpty()) return colorize(text);
|
||||||
Matcher m = PLACEHOLDER_PATTERN.matcher(text);
|
Matcher m = placeholderPattern.matcher(text);
|
||||||
Map<String, PlaceholderHook> hooks = getPlaceholders();
|
Map<String, PlaceholderHook> hooks = getPlaceholders();
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
String format = m.group(1);
|
String format = m.group(1);
|
||||||
int index = format.indexOf("_");
|
int index = format.indexOf("_");
|
||||||
if (index <= 0 || index >= format.length()) continue;
|
if (index <= 0 || index >= format.length()) continue;
|
||||||
String identifier = format.substring(0, index).toLowerCase();
|
String identifier = format.substring(0, index).toLowerCase();
|
||||||
String params = format.substring(index+1);
|
String params = format.substring(index+1);
|
||||||
if (hooks.containsKey(identifier)) {
|
if (hooks.containsKey(identifier)) {
|
||||||
String value = hooks.get(identifier).onPlaceholderRequest(player, params);
|
String value = hooks.get(identifier).onPlaceholderRequest(player, params);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
text = text.replace("%"+format+"%", Matcher.quoteReplacement(value));
|
text = text.replaceAll(m.group(), Matcher.quoteReplacement(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', text);
|
return ChatColor.translateAlternateColorCodes('&', text);
|
||||||
}
|
}
|
||||||
@ -269,7 +270,7 @@ public class PlaceholderAPI {
|
|||||||
String value = rel.onPlaceholderRequest(one, two, params);
|
String value = rel.onPlaceholderRequest(one, two, params);
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
text = text.replace("%rel_"+format+"%", Matcher.quoteReplacement(value));
|
text = text.replaceAll(m.group(), Matcher.quoteReplacement(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,46 +53,44 @@ public class PlaceholderAPICommands implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Msg.msg(s, "PlaceholderAPI &7version &b&o"+plugin.getDescription().getVersion());
|
Msg.msg(s, "PlaceholderAPI &7version &b&o" + plugin.getDescription().getVersion(),
|
||||||
Msg.msg(s, "&fCreated by&7: &bextended_clip");
|
"&fCreated by&7: &bextended_clip");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("help")) {
|
if (args[0].equalsIgnoreCase("help")) {
|
||||||
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)");
|
Msg.msg(s, "PlaceholderAPI &aHelp &e(&f" + plugin.getDescription().getVersion() + "&e)",
|
||||||
Msg.msg(s, "&b/papi");
|
"&b/papi",
|
||||||
Msg.msg(s, "&fView plugin info/version info");
|
"&fView plugin info/version info",
|
||||||
Msg.msg(s, "&b/papi list");
|
"&b/papi list",
|
||||||
Msg.msg(s, "&fList all placeholder expansions that are currently active");
|
"&fList all placeholder expansions that are currently active",
|
||||||
Msg.msg(s, "&b/papi info <placeholder name>");
|
"&b/papi info <placeholder name>",
|
||||||
Msg.msg(s, "&fView information for a specific expansion");
|
"&fView information for a specific expansion",
|
||||||
Msg.msg(s, "&b/papi parse <...args>");
|
"&b/papi parse <...args>",
|
||||||
Msg.msg(s, "&fParse a String with placeholders");
|
"&fParse a String with placeholders",
|
||||||
Msg.msg(s, "&b/papi parserel <player one> <player two> <...args>");
|
"&b/papi parserel <player one> <player two> <...args>",
|
||||||
Msg.msg(s, "&fParse a String with relational placeholders");
|
"&fParse a String with relational placeholders",
|
||||||
Msg.msg(s, "&b/papi reload");
|
"&b/papi reload",
|
||||||
Msg.msg(s, "&fReload the config settings");
|
"&fReload the config settings");
|
||||||
|
|
||||||
boolean enabled = plugin.getExpansionCloud() != null;
|
|
||||||
|
|
||||||
if (s.isOp()) {
|
if (s.isOp()) {
|
||||||
if (!enabled) {
|
if (plugin.getExpansionCloud() == null) {
|
||||||
Msg.msg(s, "&b/papi enablecloud");
|
Msg.msg(s, "&b/papi enablecloud",
|
||||||
Msg.msg(s, "&fEnable the expansion cloud");
|
"&fEnable the expansion cloud");
|
||||||
} else {
|
} else {
|
||||||
Msg.msg(s, "&b/papi disablecloud");
|
Msg.msg(s, "&b/papi disablecloud",
|
||||||
Msg.msg(s, "&fDisable the expansion cloud");
|
"&fDisable the expansion cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud");
|
"&b/papi ecloud",
|
||||||
Msg.msg(s, "&fView information about the PlaceholderAPI expansion cloud");
|
"&fView information about the PlaceholderAPI expansion cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud status");
|
"&b/papi ecloud status",
|
||||||
Msg.msg(s, "&fView status of the PlaceholderAPI expansion cloud");
|
"&fView status of the PlaceholderAPI expansion cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud list <all/author> <page>");
|
"&b/papi ecloud list <all/author> <page>",
|
||||||
Msg.msg(s, "&fList all available expansions");
|
"&fList all available expansions",
|
||||||
Msg.msg(s, "&b/papi ecloud info <expansion name>");
|
"&b/papi ecloud info <expansion name>",
|
||||||
Msg.msg(s, "&fView information about a specific expansion on the cloud");
|
"&fView information about a specific expansion on the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud download <expansion name>");
|
"&b/papi ecloud download <expansion name>",
|
||||||
Msg.msg(s, "&fDownload a specific expansion from the cloud");
|
"&fDownload a specific expansion from the cloud");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +110,6 @@ public class PlaceholderAPICommands implements CommandExecutor {
|
|||||||
return eCloud.onCommand(s, c, label, args);
|
return eCloud.onCommand(s, c, label, args);
|
||||||
|
|
||||||
} else if (args[0].equalsIgnoreCase("enablecloud")) {
|
} else if (args[0].equalsIgnoreCase("enablecloud")) {
|
||||||
|
|
||||||
if (!s.isOp()) {
|
if (!s.isOp()) {
|
||||||
Msg.msg(s, "&cYou don't have permission to do that!");
|
Msg.msg(s, "&cYou don't have permission to do that!");
|
||||||
return true;
|
return true;
|
||||||
@ -182,7 +179,7 @@ public class PlaceholderAPICommands implements CommandExecutor {
|
|||||||
if (ex.getPlugin() != null) {
|
if (ex.getPlugin() != null) {
|
||||||
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
|
Msg.msg(s, "&7Requires plugin: &f" + ex.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ex.getPlaceholders() != null) {
|
if (ex.getPlaceholders() != null) {
|
||||||
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
|
Msg.msg(s, "&8&m-- &r&7Placeholders &8&m--");
|
||||||
for (String placeholder : ex.getPlaceholders()) {
|
for (String placeholder : ex.getPlaceholders()) {
|
||||||
@ -274,7 +271,7 @@ public class PlaceholderAPICommands implements CommandExecutor {
|
|||||||
Msg.msg(s, "&cIncorrect usage! &7/papi help");
|
Msg.msg(s, "&cIncorrect usage! &7/papi help");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,20 +45,20 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
Msg.msg(s, "&bExpansion cloud commands");
|
Msg.msg(s, "&bExpansion cloud commands",
|
||||||
Msg.msg(s, " ");
|
" ",
|
||||||
Msg.msg(s, "&b/papi ecloud status");
|
"&b/papi ecloud status",
|
||||||
Msg.msg(s, "&fView status of the cloud");
|
"&fView status of the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
|
"&b/papi ecloud list <all/author> (page)",
|
||||||
Msg.msg(s, "&fList all/author specific available expansions");
|
"&fList all/author specific available expansions",
|
||||||
Msg.msg(s, "&b/papi ecloud info <expansion name>");
|
"&b/papi ecloud info <expansion name>",
|
||||||
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
|
"&fView information about a specific expansion available on the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud download <expansion name>");
|
"&b/papi ecloud download <expansion name>",
|
||||||
Msg.msg(s, "&fDownload a specific expansion from the cloud");
|
"&fDownload a specific expansion from the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud refresh");
|
"&b/papi ecloud refresh",
|
||||||
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
|
"&fFetch the most up to date list of expansions available.",
|
||||||
Msg.msg(s, "&b/papi ecloud clear");
|
"&b/papi ecloud clear",
|
||||||
Msg.msg(s, "&fClear the expansion cloud cache.");
|
"&fClear the expansion cloud cache.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,10 +111,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
|
|
||||||
if (args[1].equalsIgnoreCase("status")) {
|
if (args[1].equalsIgnoreCase("status")) {
|
||||||
|
|
||||||
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size()
|
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bcloud expansions available to download",
|
||||||
+ " &bcloud expansions available to download on demand.");
|
"&bA total of &f" + plugin.getExpansionCloud().getCloudAuthorCount() + " &bauthors have contributed.");
|
||||||
Msg.msg(s, "&bA total of &f" + plugin.getExpansionCloud().getCloudAuthorCount()
|
|
||||||
+ " &bauthors have contributed to the expansion cloud.");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (args[1].equalsIgnoreCase("info")) {
|
} else if (args[1].equalsIgnoreCase("info")) {
|
||||||
@ -143,12 +141,12 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
|
|
||||||
Msg.msg(s, "&aExpansion: &f" + expansion.getName());
|
Msg.msg(s, "&aExpansion: &f" + expansion.getName());
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
Msg.msg(s, "&aThis expansion is currently enabled!");
|
Msg.msg(s, "&aThis expansion is currently enabled!",
|
||||||
Msg.msg(s, "&bYour version&7: &f" + version);
|
"&bYour version&7: &f" + version);
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.msg(s, "&bCloud version&7: &f" + expansion.getVersion());
|
Msg.msg(s, "&bCloud version&7: &f" + expansion.getVersion(),
|
||||||
Msg.msg(s, "&bAuthor&7: &f" + expansion.getAuthor());
|
"&bAuthor&7: &f" + expansion.getAuthor());
|
||||||
|
|
||||||
String desc = expansion.getVersion();
|
String desc = expansion.getVersion();
|
||||||
|
|
||||||
@ -223,8 +221,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
for (Entry<Integer, CloudExpansion> expansion : ex.entrySet()) {
|
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, "&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, "&bDownload an expansion with &7/papi ecloud download <name>",
|
||||||
Msg.msg(s, "&bView more info on an expansion with &7/papi ecloud info <expansion>");
|
"&bView more info on an expansion with &7/papi ecloud info <expansion>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,20 +50,20 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
Msg.msg(s, "&bExpansion cloud commands");
|
Msg.msg(s, "&bExpansion cloud commands",
|
||||||
Msg.msg(s, " ");
|
" ",
|
||||||
Msg.msg(s, "&b/papi ecloud status");
|
"&b/papi ecloud status",
|
||||||
Msg.msg(s, "&fView status of the cloud");
|
"&fView status of the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud list <all/author> (page)");
|
"&b/papi ecloud list <all/author> (page)",
|
||||||
Msg.msg(s, "&fList all/author specific available expansions");
|
"&fList all/author specific available expansions",
|
||||||
Msg.msg(s, "&b/papi ecloud info <expansion name>");
|
"&b/papi ecloud info <expansion name>",
|
||||||
Msg.msg(s, "&fView information about a specific expansion available on the cloud");
|
"&fView information about a specific expansion available on the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud download <expansion name>");
|
"&b/papi ecloud download <expansion name>",
|
||||||
Msg.msg(s, "&fDownload a specific expansion from the cloud");
|
"&fDownload a specific expansion from the cloud",
|
||||||
Msg.msg(s, "&b/papi ecloud refresh");
|
"&b/papi ecloud refresh",
|
||||||
Msg.msg(s, "&fFetch the most up to date list of expansions available.");
|
"&fFetch the most up to date list of expansions available.",
|
||||||
Msg.msg(s, "&b/papi ecloud clear");
|
"&b/papi ecloud clear",
|
||||||
Msg.msg(s, "&fClear the expansion cloud cache.");
|
"&fClear the expansion cloud cache.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,9 +87,8 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
|
|
||||||
if (args[1].equalsIgnoreCase("status")) {
|
if (args[1].equalsIgnoreCase("status")) {
|
||||||
|
|
||||||
Msg.msg(s, "&bThere are &f" + plugin.getExpansionCloud().getCloudExpansions().size() + " &bexpansions available on the cloud.");
|
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()
|
"&7A total of &f" + plugin.getExpansionCloud().getCloudAuthorCount() + " &7authors have contributed to the expansion cloud.");
|
||||||
+ " &7authors have contributed to the expansion cloud.");
|
|
||||||
if (plugin.getExpansionCloud().getToUpdateCount() > 0) {
|
if (plugin.getExpansionCloud().getToUpdateCount() > 0) {
|
||||||
Msg.msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount()
|
Msg.msg(s, "&eYou have &f" + plugin.getExpansionCloud().getToUpdateCount()
|
||||||
+ " &eexpansions installed that have updates available.");
|
+ " &eexpansions installed that have updates available.");
|
||||||
@ -306,13 +305,13 @@ public class ExpansionCloudCommands implements CommandExecutor {
|
|||||||
return true;
|
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) );
|
TextComponent message = new TextComponent( ChatColor.translateAlternateColorCodes('&', text) );
|
||||||
if (hover != null) {
|
if (hover != null) {
|
||||||
message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', hover)).create() ) );
|
message.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.translateAlternateColorCodes('&', hover)).create() ) );
|
||||||
}
|
}
|
||||||
if (link != null) {
|
if (name != null) {
|
||||||
message.setClickEvent( new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/papi ecloud download " + link) );
|
message.setClickEvent( new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/papi ecloud download " + name) );
|
||||||
}
|
}
|
||||||
p.spigot().sendMessage( message );
|
p.spigot().sendMessage( message );
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,13 @@ package me.clip.placeholderapi.util;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Msg {
|
public class Msg {
|
||||||
|
|
||||||
public static void msg(CommandSender s, String msg) {
|
public static void msg(CommandSender s, String... msg) {
|
||||||
s.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
Arrays.stream(msg).forEach(text ->
|
||||||
|
s.sendMessage(ChatColor.translateAlternateColorCodes('&', text)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user