mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-07 12:37:14 +01:00
Compare commits
18 Commits
hytale
...
hytale-cur
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3e32f5688 | ||
|
|
dae0b96002 | ||
|
|
36995a0916 | ||
|
|
798ca2ea10 | ||
|
|
07c6e292b3 | ||
|
|
59d916966c | ||
|
|
d4c64fc17e | ||
|
|
395c743b41 | ||
|
|
4b015a9076 | ||
|
|
7952702abd | ||
|
|
c11904d9c9 | ||
|
|
b869b98338 | ||
|
|
a01e6abab8 | ||
|
|
e8716e57ff | ||
|
|
8f9c52940c | ||
|
|
7edc94bc35 | ||
|
|
b06bc23465 | ||
|
|
ffd115296c |
@@ -53,108 +53,16 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must supply the name of an expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must supply the name of an expansion.");
|
||||
return;
|
||||
}
|
||||
final Message message = Message.raw("""
|
||||
Expansion downloads have been disabled to meet CurseForge's policy requirements.
|
||||
This limitation is imposed by the platform, not PlaceholderAPI.
|
||||
|
||||
""").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));
|
||||
|
||||
if (isBlockedExpansion(params.get(0))) {
|
||||
sender.sendMessage(Message.raw("This expansion can't be downloaded.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cThis expansion can't be downloaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion expansion = plugin.cloudExpansionManager()
|
||||
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||
if (expansion == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find an expansion named: ").color(Color.GREEN).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to find an expansion named: &f" + params.get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
final CloudExpansion.Version version;
|
||||
if (params.size() < 2) {
|
||||
version = expansion.getVersion(expansion.getLatestVersion());
|
||||
if (version == null) {
|
||||
sender.sendMessage(Message.raw("Could not find latest version for expansion.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find latest version for expansion.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
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(0) + "\n").color(Color.WHITE))
|
||||
.insert(Message.raw("Available versions: ").color(Color.GRAY))
|
||||
.insert(Message.raw(expansion.getAvailableVersions().toString()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cCould not find specified version: &f" + params.get(1),
|
||||
// "&7Available versions: &f" + expansion.getAvailableVersions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!version.isVerified()) {
|
||||
sender.sendMessage(Message.raw("The expansion: '").color(Color.RED)
|
||||
.insert(Message.raw(params.get(0)).color(Color.WHITE))
|
||||
.insert(Message.raw("' is not verified and can only be downloaded manually from ").color(Color.RED))
|
||||
.insert(Message.raw("https://ecloud.placeholderapi.com").color(Color.WHITE)));
|
||||
// Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://ecloud.placeholderapi.com");
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.cloudExpansionManager().downloadExpansion(expansion, version)
|
||||
.whenComplete((file, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage(Message.raw("Failed to download expansion: ").color(Color.RED).insert(Message.raw(exception.getMessage()).color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&cFailed to download expansion: &f" + exception.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Message.raw("Successfully downloaded expansion ").color(Color.GREEN)
|
||||
.insert(Message.raw(expansion.getName() + " [" + version.getVersion() + "] ").color(Color.WHITE))
|
||||
.insert(Message.raw("to file: ").color(Color.GREEN))
|
||||
.insert(Message.raw(file.getName()).color(Color.WHITE))
|
||||
.insert(Message.raw("\nMake sure to type ").color(Color.GREEN))
|
||||
.insert(Message.raw("/papi reload ").color(Color.GREEN))
|
||||
.insert(Message.raw("to enable your new expansion!").color(Color.WHITE)));
|
||||
// Msg.msg(sender,
|
||||
// "&aSuccessfully downloaded expansion &f" + expansion.getName() + " [" + version
|
||||
// .getVersion() + "] &ato file: &f" + file.getName(),
|
||||
// "&aMake sure to type &f/papi reload &ato enable your new expansion!");
|
||||
|
||||
plugin.cloudExpansionManager().load();
|
||||
});
|
||||
sender.sendMessage(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() > 2) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (params.size() <= 1) {
|
||||
// final Stream<String> names = plugin.getCloudExpansionManager().getCloudExpansions().values()
|
||||
// .stream().map(CloudExpansion::getName).map(name -> name.replace(' ', '_'));
|
||||
// suggestByParameter(names, suggestions, params.isEmpty() ? null : params.get(0));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// final Optional<CloudExpansion> expansion = plugin.getCloudExpansionManager()
|
||||
// .findCloudExpansionByName(params.get(0));
|
||||
// if (!expansion.isPresent()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// suggestByParameter(expansion.get().getAvailableVersions().stream(), suggestions, params.get(1));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -48,123 +48,20 @@ public final class CommandECloudUpdate extends PlaceholderCommand {
|
||||
setPermissions("placeholderapi.ecloud.*", "placeholderapi.ecloud.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
|
||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||
@NotNull @Unmodifiable final List<String> params) {
|
||||
if (params.isEmpty()) {
|
||||
sender.sendMessage(Message.raw("You must define 'all' or the name of an expansion to update.").color(Color.RED));
|
||||
// Msg.msg(sender,
|
||||
// "&cYou must define 'all' or the name of an expansion to update.");
|
||||
return;
|
||||
}
|
||||
final Message message = Message.raw("""
|
||||
Expansion downloads have been disabled to meet CurseForge's policy requirements.
|
||||
This limitation is imposed by the platform, not PlaceholderAPI.
|
||||
|
||||
""").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");
|
||||
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);
|
||||
|
||||
});
|
||||
sender.sendMessage(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));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -245,12 +245,14 @@ public final class CloudExpansionManager {
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public boolean isDownloading(@NotNull final CloudExpansion expansion) {
|
||||
return await.containsKey(toIndexName(expansion));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@NotNull
|
||||
public CompletableFuture<File> downloadExpansion(@NotNull final CloudExpansion expansion,
|
||||
@NotNull final CloudExpansion.Version version) {
|
||||
final CompletableFuture<File> previous = await.get(toIndexName(expansion));
|
||||
@@ -282,7 +284,7 @@ public final class CloudExpansionManager {
|
||||
await.put(toIndexName(expansion), download);
|
||||
|
||||
return download;
|
||||
}
|
||||
} */
|
||||
|
||||
private static final class LoggingThreadFactory implements ThreadFactory {
|
||||
private final ThreadFactory backing = Executors.defaultThreadFactory();
|
||||
|
||||
@@ -217,7 +217,17 @@ public final class LocalExpansionManager /*implements Listener*/ {
|
||||
@ApiStatus.Internal
|
||||
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||
final String identifier = expansion.getIdentifier().toLowerCase(Locale.ROOT);
|
||||
|
||||
|
||||
if (!expansion.canRegister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid loading two external expansions with the same identifier
|
||||
if (expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL && expansions.containsKey(identifier)) {
|
||||
logger.atWarning().log("Failed to load external expansion %s. Identifier is already in use.", expansion.getIdentifier());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expansion instanceof Configurable<?> configurable) {
|
||||
final PlaceholderAPIConfig config = configManager.config();
|
||||
|
||||
@@ -232,16 +242,36 @@ public final class LocalExpansionManager /*implements Listener*/ {
|
||||
final Object expansionConfig = configManager.convertExpansion((Map<String, Object>) config.expansions().get(expansion.getIdentifier()), configurable.provideConfigType());
|
||||
config.expansions().put(expansion.getIdentifier(), expansionConfig);
|
||||
}
|
||||
}
|
||||
|
||||
if (!expansion.canRegister()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid loading two external expansions with the same identifier
|
||||
if (expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL && expansions.containsKey(identifier)) {
|
||||
logger.atWarning().log("Failed to load external expansion %s. Identifier is already in use.", expansion.getIdentifier());
|
||||
return false;
|
||||
// Map<String, Object> defaults = ((Configurable<?>) expansion).getDefaults();
|
||||
// String pre = "expansions." + identifier + ".";
|
||||
// boolean save = false;
|
||||
//
|
||||
// final PlaceholderAPIConfig config = this.config.config();
|
||||
//
|
||||
// if (defaults != null) {
|
||||
// for (Map.Entry<String, Object> entries : defaults.entrySet()) {
|
||||
// if (entries.getKey() == null || entries.getKey().isEmpty()) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (entries.getValue() == null) {
|
||||
// if (cfg.contains(pre + entries.getKey())) {
|
||||
// save = true;
|
||||
// cfg.set(pre + entries.getKey(), null);
|
||||
// }
|
||||
// } else {
|
||||
// if (!cfg.contains(pre + entries.getKey())) {
|
||||
// save = true;
|
||||
// cfg.set(pre + entries.getKey(), entries.getValue());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (save) {
|
||||
// plugin.saveConfig();
|
||||
// plugin.reloadConfig();
|
||||
// }
|
||||
}
|
||||
|
||||
// if (expansion instanceof VersionSpecific) {
|
||||
|
||||
Reference in New Issue
Block a user