mirror of
https://github.com/PlaceholderAPI/Javascript-Expansion.git
synced 2025-05-23 02:19:04 +00:00
Remove duplicate code
This commit is contained in:
parent
772111dc6c
commit
a30ef5c8e6
@ -26,6 +26,10 @@ public class ExpansionUtils {
|
||||
sender.sendMessage(colorize(Arrays.stream(msg).filter(Objects::nonNull).collect(Collectors.joining("\n"))));
|
||||
}
|
||||
|
||||
public static String plural(final int amount) {
|
||||
return amount > 1 ? "s" : "";
|
||||
}
|
||||
|
||||
public static void warnLog(String log, Throwable throwable) {
|
||||
warnLog(log, throwable, true);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
@ -104,7 +103,7 @@ public class JavascriptExpansion extends PlaceholderExpansion implements Cacheab
|
||||
config = new JavascriptPlaceholdersConfig(this);
|
||||
|
||||
int amountLoaded = config.loadPlaceholders();
|
||||
ExpansionUtils.infoLog(amountLoaded + " script" + plural(amountLoaded) + " loaded!");
|
||||
ExpansionUtils.infoLog(amountLoaded + " script" + ExpansionUtils.plural(amountLoaded) + " loaded!");
|
||||
|
||||
|
||||
if (debug) {
|
||||
@ -295,8 +294,4 @@ public class JavascriptExpansion extends PlaceholderExpansion implements Cacheab
|
||||
commandMap.register("papi" + commands.getName(), commands);
|
||||
commands.isRegistered();
|
||||
}
|
||||
|
||||
private String plural(final int amount) {
|
||||
return amount > 1 ? "s" : "";
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class GitCommand extends ICommand {
|
||||
final List<GithubScript> availableScripts = manager.getAvailableScripts();
|
||||
final Set<String> scripts = availableScripts.stream().map(GithubScript::getName).collect(Collectors.toSet());
|
||||
|
||||
ExpansionUtils.sendMsg(sender, availableScripts.size() + " &escript" + plural(availableScripts.size()) + " available on Github.", String.join(", ", scripts));
|
||||
ExpansionUtils.sendMsg(sender, availableScripts.size() + " &escript" + ExpansionUtils.plural(availableScripts.size()) + " available on Github.", String.join(", ", scripts));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -135,8 +135,4 @@ public class GitCommand extends ICommand {
|
||||
public @NotNull String getAlias() {
|
||||
return "git";
|
||||
}
|
||||
|
||||
private String plural(final int amount) {
|
||||
return amount > 1 ? "s" : "";
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class ListCommand extends ICommand {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
final List<String> loaded = expansion.getLoadedIdentifiers();
|
||||
ExpansionUtils.sendMsg(sender,loaded.size() + " &7script" + plural(loaded.size()) + " loaded.",
|
||||
ExpansionUtils.sendMsg(sender,loaded.size() + " &7script" + ExpansionUtils.plural(loaded.size()) + " loaded.",
|
||||
String.join(", ", loaded));
|
||||
}
|
||||
|
||||
@ -28,8 +28,4 @@ public class ListCommand extends ICommand {
|
||||
public String getAlias() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
private String plural(final int amount) {
|
||||
return amount > 1 ? "s" : "";
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class ReloadCommand extends ICommand {
|
||||
|
||||
ExpansionUtils.sendMsg(sender, "&aJavascriptExpansion reloading...");
|
||||
final int scripts = expansion.reloadScripts();
|
||||
ExpansionUtils.sendMsg(sender, scripts + " &7script" + plural(scripts) + " loaded");
|
||||
ExpansionUtils.sendMsg(sender, scripts + " &7script" + ExpansionUtils.plural(scripts) + " loaded");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,8 +26,4 @@ public class ReloadCommand extends ICommand {
|
||||
public String getAlias() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
private String plural(final int amount) {
|
||||
return amount > 1 ? "s" : "";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user