Update download/update messages to be clearer

This commit is contained in:
PiggyPiglet
2026-01-30 18:21:23 +08:00
parent b06bc23465
commit 7edc94bc35
2 changed files with 11 additions and 114 deletions

View File

@@ -55,9 +55,9 @@ public final class CommandECloudDownload extends PlaceholderCommand {
final Message message = Message.raw(""" final Message message = Message.raw("""
Expansion downloads have been disabled to meet CurseForge's policy requirements. Expansion downloads have been disabled to meet CurseForge's policy requirements.
This limitation is imposed by the platform, not PlaceholderAPI. This limitation is imposed by the platform, not PlaceholderAPI.
""").color(Color.RED) """).color(Color.RED)
.insert(Message.raw("Please download expansions manually from ecloud.placeholderapi.com").link("https://ecloud.placeholderapi.com").bold(true).italic(true).color(Color.WHITE)) .insert(Message.raw("Please download expansions manually from ").color(Color.RED).insert(Message.raw("ecloud.placeholderapi.com").link("https://ecloud.placeholderapi.com").bold(true).italic(true).color(Color.WHITE)))
.insert(Message.raw(" or install the full version of PlaceholderAPI from ").color(Color.RED)) .insert(Message.raw(" or install the full version of PlaceholderAPI from ").color(Color.RED))
.insert(Message.raw("placeholderapi.com/downloads").link("https://placeholderapi.com/downloads").bold(true).italic(true).color(Color.WHITE)); .insert(Message.raw("placeholderapi.com/downloads").link("https://placeholderapi.com/downloads").bold(true).italic(true).color(Color.WHITE));

View File

@@ -47,123 +47,20 @@ public final class CommandECloudUpdate extends PlaceholderCommand {
super("update"); super("update");
} }
private static CompletableFuture<List<@Nullable Class<? extends PlaceholderExpansion>>> downloadAndDiscover(
@NotNull final List<CloudExpansion> expansions, @NotNull final PlaceholderAPIPlugin plugin) {
return expansions.stream()
.map(expansion -> plugin.cloudExpansionManager()
.downloadExpansion(expansion, expansion.getVersion()))
.map(future -> future.thenCompose(plugin.localExpansionManager()::findExpansionInFile))
.collect(Futures.collector());
}
@Override @Override
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin, public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
@NotNull final CommandSender sender, @NotNull final String alias, @NotNull final CommandSender sender, @NotNull final String alias,
@NotNull @Unmodifiable final List<String> params) { @NotNull @Unmodifiable final List<String> params) {
if (params.isEmpty()) { final Message message = Message.raw("""
sender.sendMessage(Message.raw("You must define 'all' or the name of an expansion to update.").color(Color.RED)); Expansion downloads have been disabled to meet CurseForge's policy requirements.
// Msg.msg(sender, This limitation is imposed by the platform, not PlaceholderAPI.
// "&cYou must define 'all' or the name of an expansion to update.");
return; """).color(Color.RED)
} .insert(Message.raw("Please download expansions manually from ").color(Color.RED).insert(Message.raw("ecloud.placeholderapi.com").link("https://ecloud.placeholderapi.com").bold(true).italic(true).color(Color.WHITE)))
.insert(Message.raw(" or install the full version of PlaceholderAPI from ").color(Color.RED))
.insert(Message.raw("placeholderapi.com/downloads").link("https://placeholderapi.com/downloads").bold(true).italic(true).color(Color.WHITE));
final boolean multiple = params.get(0).equalsIgnoreCase("all"); sender.sendMessage(message);
final List<CloudExpansion> expansions = new ArrayList<>();
// gather target expansions
if (multiple) {
expansions.addAll(plugin.cloudExpansionManager().getCloudExpansionsInstalled().values());
} else {
plugin.cloudExpansionManager().findCloudExpansionByName(params.get(0))
.ifPresent(expansions::add);
}
// remove the ones that are the latest version
expansions.removeIf(expansion -> !expansion.shouldUpdate());
if (expansions.isEmpty()) {
sender.sendMessage(Message.raw("No updates available for " + (!multiple ? "this expansion." : "your active expansions.")).color(Color.RED));
// Msg.msg(sender,
// "&cNo updates available for " + (!multiple ? "this expansion."
// : "your active expansions."));
return;
}
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")));
Futures.onMainThread(plugin, downloadAndDiscover(expansions, plugin), (classes, exception) -> {
if (exception != null) {
sender.sendMessage(Message.raw("Failed to update expansions: ").color(Color.RED).insert(Message.raw(exception.getMessage()).color(Color.YELLOW)));
// Msg.msg(sender,
// "&cFailed to update expansions: &e" + exception.getMessage());
return;
}
sender.sendMessage(Message.raw("Successfully downloaded updates, registering new versions.").color(Color.GREEN));
// Msg.msg(sender,
// "&aSuccessfully downloaded updates, registering new versions.");
final List<PlaceholderExpansion> registered = classes.stream()
.filter(Objects::nonNull)
.map(plugin.localExpansionManager()::register)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
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);
});
} }
// @Override
// public void complete(@NotNull final PlaceholderAPIPlugin plugin,
// @NotNull final CommandSender sender, @NotNull final String alias,
// @NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
// if (params.size() > 1) {
// return;
// }
//
// final List<CloudExpansion> installed = Lists
// .newArrayList(plugin.getCloudExpansionManager().getCloudExpansionsInstalled().values());
// installed.removeIf(expansion -> !expansion.shouldUpdate());
//
// if (!installed.isEmpty() && (params.isEmpty() || "all"
// .startsWith(params.get(0).toLowerCase(Locale.ROOT)))) {
// suggestions.add("all");
// }
//
// suggestByParameter(
// installed.stream().map(CloudExpansion::getName).map(name -> name.replace(" ", "_")),
// suggestions, params.isEmpty() ? null : params.get(0));
// }
} }