mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-05 11:57:14 +01:00
updated color handling
This commit is contained in:
@@ -76,7 +76,7 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||
.insert(Message.raw("PlaceholderAPI ").color(Color.CYAN).bold(true))
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY))
|
||||
.insert(Message.raw("eCloud Help Menu ").color(Color.GRAY))
|
||||
.insert(Message.raw("-\n\n").color(Color.DARK_GRAY));
|
||||
.insert(Message.raw("-\n").color(Color.DARK_GRAY));
|
||||
|
||||
final List<String[]> commands = List.of(
|
||||
new String[]{"ecloud status", "View status of the eCloud"},
|
||||
@@ -90,7 +90,7 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||
);
|
||||
|
||||
for (String[] command : commands) {
|
||||
message = message.insert(Message.raw("/papi").color(Color.CYAN))
|
||||
message = message.insert(Message.raw("\n/papi ").color(Color.CYAN))
|
||||
.insert(Message.raw(command[0]).color(Color.WHITE))
|
||||
.insert(Message.raw("\n " + command[1]).color(Color.GRAY));
|
||||
}
|
||||
|
||||
@@ -57,36 +57,31 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("&bExpansion: &f")
|
||||
.append(expansion.shouldUpdate() ? "&e" : "&a")
|
||||
.append(expansion.getName())
|
||||
.append('\n')
|
||||
.append("&bAuthor: &f")
|
||||
.append(expansion.getAuthor())
|
||||
.append('\n');
|
||||
Message message = Message.raw("Expansion: ").color(Color.CYAN)
|
||||
.insert(Message.raw(expansion.getName()).color(expansion.shouldUpdate() ? Color.YELLOW : Color.GREEN))
|
||||
.insert(Message.raw("\nAuthor: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getAuthor()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
|
||||
if (params.size() < 2) {
|
||||
builder.append("&bLatest Version: &f")
|
||||
.append(expansion.getLatestVersion())
|
||||
.append('\n')
|
||||
.append("&bReleased: &f")
|
||||
.append(expansion.getTimeSinceLastUpdate())
|
||||
.append(" ago")
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(expansion.getVersion().isVerified() ? "&a&l✔" : "&c&l❌")
|
||||
.append('\n')
|
||||
.append("&bRelease Notes: &f")
|
||||
.append(expansion.getVersion().getReleaseNotes())
|
||||
.append('\n');
|
||||
message = message
|
||||
.insert(Message.raw("Latest Version: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getLatestVersion()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nReleased: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getTimeSinceLastUpdate() + " ago").color(Color.WHITE))
|
||||
.insert(Message.raw("\nVerified: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getVersion().isVerified() ? "YES" : "NO")
|
||||
.color(expansion.getVersion().isVerified() ? Color.GREEN : Color.RED)
|
||||
.bold(true))
|
||||
.insert(Message.raw("\nRelease Notes: ").color(Color.CYAN))
|
||||
.insert(Message.raw(expansion.getVersion().getReleaseNotes()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
} else {
|
||||
final CloudExpansion.Version version = expansion.getVersion(params.get(1));
|
||||
if (version == null) {
|
||||
sender.sendMessage(Message.raw("Could not find specified version: ").color(Color.RED)
|
||||
.insert(Message.raw(params.get(1)).color(Color.WHITE))
|
||||
.insert(Message.raw("\nVersions: ").color(Color.GREEN))
|
||||
.insert(Message.raw("\nVersions: ").color(Color.GREEN))
|
||||
.insert(Message.raw(expansion.getAvailableVersions().toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find specified version: &f" + params.get(1),
|
||||
@@ -94,21 +89,21 @@ public final class CommandECloudExpansionInfo extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.append("&bVersion: &f")
|
||||
.append(version.getVersion())
|
||||
.append('\n')
|
||||
.append("&bVerified: ")
|
||||
.append(version.isVerified() ? "&a&l✔" : "&c&l❌")
|
||||
.append('\n')
|
||||
.append("&bRelease Notes: &f")
|
||||
.append(version.getReleaseNotes())
|
||||
.append('\n')
|
||||
.append("&bDownload URL: &f")
|
||||
.append(version.getUrl())
|
||||
.append('\n');
|
||||
message = message
|
||||
.insert(Message.raw("Version: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getVersion()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nVerified: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.isVerified() ? "YES" : "NO")
|
||||
.color(version.isVerified() ? Color.GREEN : Color.RED)
|
||||
.bold(true))
|
||||
.insert(Message.raw("\nRelease Notes: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getReleaseNotes()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nDownload URL: ").color(Color.CYAN))
|
||||
.insert(Message.raw(version.getUrl()).color(Color.WHITE))
|
||||
.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw(builder.toString())); // todo: convert colors
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -21,15 +21,10 @@
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.util.Format;
|
||||
|
||||
import java.awt.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
@@ -44,24 +39,14 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
|
||||
private static final int PAGE_SIZE = 10;
|
||||
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_NAME =
|
||||
expansion -> (expansion.shouldUpdate() ? "&6" : expansion.hasExpansion() ? "&a" : "&7")
|
||||
+ expansion.getName();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_AUTHOR =
|
||||
expansion -> "&f" + expansion.getAuthor();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_VERIFIED =
|
||||
expansion -> expansion.getVersion().isVerified() ? "&aY" : "&cN";
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_LATEST_VERSION =
|
||||
expansion -> "&f" + expansion.getLatestVersion();
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, Object> EXPANSION_CURRENT_VERSION =
|
||||
expansion -> "&f" + PlaceholderAPIPlugin.instance().localExpansionManager()
|
||||
.findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion)
|
||||
.orElse("Unknown");
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, String> EXPANSION_LATEST_VERSION =
|
||||
CloudExpansion::getLatestVersion;
|
||||
@NotNull
|
||||
private static final Function<CloudExpansion, String> EXPANSION_CURRENT_VERSION =
|
||||
expansion -> PlaceholderAPIPlugin.instance().localExpansionManager()
|
||||
.findExpansionByName(expansion.getName()).map(PlaceholderExpansion::getVersion)
|
||||
.orElse("Unknown");
|
||||
|
||||
|
||||
@Unmodifiable
|
||||
@@ -98,35 +83,33 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
return expansions.subList(head, tail);
|
||||
}
|
||||
|
||||
public static void addExpansionTitle(@NotNull final StringBuilder builder,
|
||||
@NotNull final String target, final int page) {
|
||||
public static Message buildExpansionTitle(@NotNull final String target, final int page) {
|
||||
Message title;
|
||||
switch (target.toLowerCase(Locale.ROOT)) {
|
||||
case "all":
|
||||
builder.append("&bAll Expansions");
|
||||
title = Message.raw("All Expansions").color(Color.CYAN);
|
||||
break;
|
||||
case "installed":
|
||||
builder.append("&bInstalled Expansions");
|
||||
title = Message.raw("Installed Expansions").color(Color.CYAN);
|
||||
break;
|
||||
default:
|
||||
builder.append("&bExpansions by &f")
|
||||
.append(target);
|
||||
title = Message.raw("Expansions by ").color(Color.CYAN)
|
||||
.insert(Message.raw(target).color(Color.WHITE));
|
||||
break;
|
||||
}
|
||||
|
||||
if (page == -1) {
|
||||
builder.append('\n');
|
||||
return;
|
||||
return title.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
builder.append(" &bPage&7: &a")
|
||||
.append(page)
|
||||
.append("&r");
|
||||
return title
|
||||
.insert(Message.raw(" Page").color(Color.CYAN))
|
||||
.insert(Message.raw(": ").color(Color.GRAY))
|
||||
.insert(Message.raw(String.valueOf(page)).color(Color.GREEN));
|
||||
}
|
||||
|
||||
private static Message getMessage(@NotNull final List<CloudExpansion> expansions,
|
||||
final int page, final int limit, @NotNull final String target) {
|
||||
final SimpleDateFormat format = new SimpleDateFormat(PlaceholderAPIPlugin.instance().configManager().config().dateFormat());
|
||||
|
||||
Message message = Message.empty();
|
||||
|
||||
for (int index = 0; index < expansions.size(); index++) {
|
||||
@@ -197,41 +180,95 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
return message;
|
||||
}
|
||||
|
||||
private static void addExpansionTable(@NotNull final List<CloudExpansion> expansions,
|
||||
@NotNull final StringBuilder message, final int startIndex,
|
||||
@NotNull final String versionTitle,
|
||||
@NotNull final Function<CloudExpansion, Object> versionFunction) {
|
||||
final Map<String, Function<CloudExpansion, Object>> functions = new LinkedHashMap<>();
|
||||
|
||||
final AtomicInteger counter = new AtomicInteger(startIndex);
|
||||
functions.put("&f", expansion -> "&8" + counter.getAndIncrement() + ".");
|
||||
|
||||
functions.put("&9Name", EXPANSION_NAME);
|
||||
functions.put("&9Author", EXPANSION_AUTHOR);
|
||||
functions.put("&9Verified", EXPANSION_VERIFIED);
|
||||
functions.put(versionTitle, versionFunction);
|
||||
|
||||
private static Message buildExpansionTable(@NotNull final List<CloudExpansion> expansions,
|
||||
final int startIndex,
|
||||
@NotNull final String versionTitle,
|
||||
@NotNull final Function<CloudExpansion, String> versionFunction) {
|
||||
final List<List<String>> rows = new ArrayList<>();
|
||||
rows.add(List.of("#", "Name", "Author", "Verified", versionTitle));
|
||||
|
||||
rows.add(0, new ArrayList<>(functions.keySet()));
|
||||
|
||||
int counter = startIndex;
|
||||
for (final CloudExpansion expansion : expansions) {
|
||||
rows.add(functions.values().stream().map(function -> function.apply(expansion))
|
||||
.map(Objects::toString).collect(Collectors.toList()));
|
||||
rows.add(List.of(
|
||||
counter++ + ".",
|
||||
expansion.getName(),
|
||||
expansion.getAuthor(),
|
||||
expansion.getVersion().isVerified() ? "Y" : "N",
|
||||
versionFunction.apply(expansion)
|
||||
));
|
||||
}
|
||||
|
||||
final List<String> table = Format.tablify(Format.Align.LEFT, rows)
|
||||
.orElse(Collections.emptyList());
|
||||
if (table.isEmpty()) {
|
||||
return;
|
||||
final int columnCount = rows.getFirst().size();
|
||||
final int[] widths = new int[columnCount];
|
||||
for (final List<String> row : rows) {
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
widths[i] = Math.max(widths[i], row.get(i).length());
|
||||
}
|
||||
}
|
||||
|
||||
final List<Color> headerColors = List.of(
|
||||
Color.WHITE,
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255),
|
||||
new Color(85, 85, 255)
|
||||
);
|
||||
|
||||
Message message = Message.empty();
|
||||
message = message.insert(buildTableRow(rows.getFirst(), headerColors, widths));
|
||||
message = message.insert(Message.raw("\n"));
|
||||
|
||||
// table.add(1, "&8" + Strings.repeat("-", table.get(0).length() - (rows.get(0).size() * 2)));
|
||||
table.add(1, "&8" + "-".repeat(table.get(0).length() - (rows.getFirst().size() * 2)));
|
||||
final int separatorLength = Arrays.stream(widths).sum() + (columnCount * 2);
|
||||
message = message.insert(Message.raw("-".repeat(separatorLength)).color(Color.DARK_GRAY));
|
||||
|
||||
message.append(String.join("\n", table));
|
||||
if (rows.size() > 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
for (int rowIndex = 1; rowIndex < rows.size(); rowIndex++) {
|
||||
final List<String> row = rows.get(rowIndex);
|
||||
final CloudExpansion expansion = expansions.get(rowIndex - 1);
|
||||
|
||||
final Color nameColor = expansion.shouldUpdate()
|
||||
? Color.YELLOW
|
||||
: (expansion.hasExpansion() ? Color.GREEN : Color.GRAY);
|
||||
|
||||
final List<Color> rowColors = List.of(
|
||||
Color.DARK_GRAY,
|
||||
nameColor,
|
||||
Color.WHITE,
|
||||
expansion.getVersion().isVerified() ? Color.GREEN : Color.RED,
|
||||
Color.WHITE
|
||||
);
|
||||
|
||||
message = message.insert(buildTableRow(row, rowColors, widths));
|
||||
if (rowIndex < rows.size() - 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private static Message buildTableRow(@NotNull final List<String> columns,
|
||||
@NotNull final List<Color> colors,
|
||||
@NotNull final int[] widths) {
|
||||
Message row = Message.empty();
|
||||
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
final String padded = padRight(columns.get(i), widths[i] + 2);
|
||||
row = row.insert(Message.raw(padded).color(colors.get(i)));
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String padRight(@NotNull final String text, final int length) {
|
||||
if (text.length() >= length) {
|
||||
return text;
|
||||
}
|
||||
return text + " ".repeat(length - text.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -259,16 +296,14 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
.sort(plugin.configManager().config().cloudSorting());
|
||||
|
||||
if (!(sender instanceof Player) && params.size() < 2) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final Message message = buildExpansionTitle(params.get(0), -1)
|
||||
.insert(buildExpansionTable(
|
||||
expansions,
|
||||
1,
|
||||
installed ? "Version" : "Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION));
|
||||
|
||||
addExpansionTitle(builder, params.get(0), -1);
|
||||
addExpansionTable(expansions,
|
||||
builder,
|
||||
1,
|
||||
installed ? "&9Version" : "&9Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
|
||||
|
||||
sender.sendMessage(Message.raw(builder.toString()));
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
return;
|
||||
}
|
||||
@@ -306,32 +341,31 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||
page = parsed;
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final List<CloudExpansion> values = getPage(expansions, page - 1);
|
||||
|
||||
addExpansionTitle(builder, params.get(0), page);
|
||||
final Message title = buildExpansionTitle(params.get(0), page);
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
addExpansionTable(values,
|
||||
builder,
|
||||
final Message message = title.insert(buildExpansionTable(
|
||||
values,
|
||||
((page - 1) * PAGE_SIZE) + 1,
|
||||
installed ? "&9Version" : "&9Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION);
|
||||
installed ? "Version" : "Latest Version",
|
||||
installed ? EXPANSION_CURRENT_VERSION : EXPANSION_LATEST_VERSION));
|
||||
|
||||
sender.sendMessage(Message.raw(builder.toString()));
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw(builder.toString()));
|
||||
sender.sendMessage(title);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
|
||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||
|
||||
|
||||
// final Component message = getMessage(values, page, limit, params.get(0));
|
||||
// plugin.getAdventure().player((Player) sender).sendMessage(message);
|
||||
final Message message = getMessage(values, page, limit, params.get(0));
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -72,7 +72,29 @@ public final class CommandECloudExpansionPlaceholders extends PlaceholderCommand
|
||||
// .partition(placeholders.stream().sorted().collect(Collectors.toList()), 10);
|
||||
final List<List<String>> partitions = new ArrayList<>(IntStream.range(0, placeholders.size()).boxed().collect(Collectors.groupingBy(i -> i/10, Collectors.mapping(placeholders::get, Collectors.toList()))).values());
|
||||
|
||||
sender.sendMessage(Message.raw("&6 " + placeholders.size() + " &7 placeholders: &a\n" + partitions.stream().map(p -> String.join(", ", p)).collect(Collectors.joining("\n"))));
|
||||
Message message = Message.raw(" ").color(Color.ORANGE)
|
||||
.insert(Message.raw(String.valueOf(placeholders.size())).color(Color.ORANGE))
|
||||
.insert(Message.raw(" placeholders: ").color(Color.GRAY));
|
||||
|
||||
for (int i = 0; i < partitions.size(); i++) {
|
||||
if (i == 0) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
|
||||
final List<String> partition = partitions.get(i);
|
||||
for (int j = 0; j < partition.size(); j++) {
|
||||
message = message.insert(Message.raw(partition.get(j)).color(Color.GREEN));
|
||||
if (j < partition.size() - 1) {
|
||||
message = message.insert(Message.raw(", ").color(Color.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
if (i < partitions.size() - 1) {
|
||||
message = message.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender,
|
||||
// "&6" + placeholders.size() + "&7 placeholders: &a",
|
||||
// partitions.stream().map(partition -> String.join(", ", partition))
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
package at.helpch.placeholderapi.commands.impl.cloud;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
@@ -46,20 +47,24 @@ public final class CommandECloudStatus extends PlaceholderCommand {
|
||||
final int authorCount = manager.getCloudExpansionAuthorCount();
|
||||
final int expansionCount = manager.getCloudExpansions().size();
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("&bThere are &a").append(expansionCount)
|
||||
.append("&b expansions available on the eCloud.").append('\n');
|
||||
builder.append("&7A total of &f").append(authorCount)
|
||||
.append("&7 authors have contributed to the eCloud.").append('\n');
|
||||
Message message = Message.raw("There are ").color(Color.CYAN)
|
||||
.insert(Message.raw(String.valueOf(expansionCount)).color(Color.GREEN))
|
||||
.insert(Message.raw(" expansions available on the eCloud.\n").color(Color.CYAN))
|
||||
.insert(Message.raw("A total of ").color(Color.GRAY))
|
||||
.insert(Message.raw(String.valueOf(authorCount)).color(Color.WHITE))
|
||||
.insert(Message.raw(" authors have contributed Hytale expansions to the eCloud.\n").color(Color.GRAY));
|
||||
|
||||
if (updateCount > 0) {
|
||||
builder.append("&eYou have &f").append(updateCount)
|
||||
.append(updateCount > 1 ? "&e expansions" : "&e expansion").append(" installed that ")
|
||||
.append(updateCount > 1 ? "have an" : "has an").append(" update available.");
|
||||
message = message
|
||||
.insert(Message.raw("You have ").color(Color.YELLOW))
|
||||
.insert(Message.raw(String.valueOf(updateCount)).color(Color.WHITE))
|
||||
.insert(Message.raw(updateCount > 1 ? " expansions" : " expansion").color(Color.YELLOW))
|
||||
.insert(Message.raw(" installed that ").color(Color.YELLOW))
|
||||
.insert(Message.raw(updateCount > 1 ? "have an" : "has an").color(Color.YELLOW))
|
||||
.insert(Message.raw(" update available.").color(Color.YELLOW));
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw(builder.toString()));
|
||||
sender.sendMessage(message);
|
||||
// Msg.msg(sender, builder.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
@@ -90,7 +89,17 @@ public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Updating expansions: " + expansions.stream().map(CloudExpansion::getName).collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r"))).color(Color.GREEN));
|
||||
Message expansionList = Message.raw("[").color(Color.DARK_GRAY);
|
||||
for (int i = 0; i < expansions.size(); i++) {
|
||||
if (i > 0) {
|
||||
expansionList = expansionList.insert(Message.raw(", ").color(Color.GRAY));
|
||||
}
|
||||
expansionList = expansionList.insert(Message.raw(expansions.get(i).getName()).color(Color.ORANGE));
|
||||
}
|
||||
expansionList = expansionList.insert(Message.raw("]").color(Color.DARK_GRAY));
|
||||
|
||||
sender.sendMessage(Message.raw("Updating expansions: ").color(Color.GREEN)
|
||||
.insert(expansionList));
|
||||
// Msg.msg(sender,
|
||||
// "&aUpdating expansions: " + expansions.stream().map(CloudExpansion::getName)
|
||||
// .collect(Collectors.joining("&7, &6", "&8[&6", "&8]&r")));
|
||||
@@ -107,15 +116,28 @@ public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully downloaded updates, registering new versions.");
|
||||
|
||||
final String message = classes.stream()
|
||||
final List<PlaceholderExpansion> registered = classes.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(plugin.localExpansionManager()::register)
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.map(expansion -> " &a" + expansion.getName() + " &f" + expansion.getVersion())
|
||||
.collect(Collectors.joining("\n"));
|
||||
.toList();
|
||||
|
||||
sender.sendMessage(Message.raw("&7Registered expansions: \n" + message));
|
||||
Message registeredMessage = Message.raw("Registered expansions:\n").color(Color.GRAY);
|
||||
for (int i = 0; i < registered.size(); i++) {
|
||||
final PlaceholderExpansion expansion = registered.get(i);
|
||||
registeredMessage = registeredMessage
|
||||
.insert(Message.raw(" ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getName()).color(Color.GREEN))
|
||||
.insert(Message.raw(" ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getVersion()).color(Color.WHITE));
|
||||
|
||||
if (i < registered.size() - 1) {
|
||||
registeredMessage = registeredMessage.insert(Message.raw("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(registeredMessage);
|
||||
// Msg.msg(sender,
|
||||
// "&7Registered expansions:", message);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class CommandHelp extends PlaceholderCommand {
|
||||
|
||||
final Message message = Message.raw("PlaceholderAPI ").color(Color.CYAN).bold(true)
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY).bold(false))
|
||||
.insert(Message.raw("Help Menu ").color(Color.GRAY).bold(false))
|
||||
.insert(Message.raw("Help Menu ").color(Color.WHITE).bold(false))
|
||||
.insert(Message.raw("- ").color(Color.DARK_GRAY).bold(false))
|
||||
.insert(Message.raw("(").color(Color.GRAY).bold(false))
|
||||
.insert(Message.raw(description.getVersion().toString()).color(Color.WHITE).bold(false))
|
||||
@@ -102,10 +102,10 @@ public final class CommandHelp extends PlaceholderCommand {
|
||||
.insert(Message.raw(command).color(Color.WHITE));
|
||||
|
||||
if (arguments != null) {
|
||||
message = message.insert(" " + arguments).color(Color.BLUE);
|
||||
message = message.insert(" " + arguments).color(Color.CYAN);
|
||||
}
|
||||
|
||||
return message
|
||||
.insert(Message.raw("\n " + description).color(Color.GRAY).italic(true));
|
||||
.insert(Message.raw("\n " + description).color(Color.gray).bold(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ public final class CommandInfo extends PlaceholderCommand {
|
||||
}
|
||||
|
||||
Message message = Message.empty()
|
||||
.insert(Message.raw("Placeholder expansion info for: &r").color(Color.GRAY))
|
||||
.insert(Message.raw("Placeholder expansion info for:").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getName() + "\n").color(Color.WHITE))
|
||||
.insert(Message.raw("Status: ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.isRegistered() ? "Registered" : "Not Registered").color(expansion.isRegistered() ? Color.GRAY : Color.RED))
|
||||
.insert(Message.raw(expansion.isRegistered() ? "Registered" : "Not Registered").color(expansion.isRegistered() ? Color.GREEN : Color.RED))
|
||||
.insert("\n");
|
||||
|
||||
final String author = expansion.getAuthor();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"Name": "PlaceholderAPI",
|
||||
"Version": "1.0.0",
|
||||
"Description": "An awesome placeholder provider",
|
||||
"Authors": [{"Name": "Your Mama"}],
|
||||
"Authors": [{"Name": "HelpChat"}],
|
||||
"Website": "https://placeholderapi.com",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {},
|
||||
|
||||
Reference in New Issue
Block a user