Add eCloud blocked information msg to ecloud command

This commit is contained in:
PiggyPiglet
2026-02-02 20:07:22 +08:00
parent 59ec9bee5a
commit 3e75070375
2 changed files with 17 additions and 0 deletions

View File

@@ -142,6 +142,16 @@ public final class CommandECloud extends PlaceholderCommand {
return;
}
if (!target.getLabel().equalsIgnoreCase("refresh") && plugin.cloudExpansionManager().isEmpty()) {
sender.sendMessage(Message.raw("There is no available data from the eCloud. Please try running ").color(Color.RED)
.insert(Message.raw("/papi ecloud refresh").color(Color.WHITE))
.insert(Message.raw(" If this does not resolve the issue, the eCloud may be blocked by your firewall, server host or service provider.\n\n").color(Color.RED))
.insert(Message.raw("More information: ").color(Color.RED))
.insert(Message.raw("https://placeholderapi.com/ecloud-blocked").color(Color.WHITE).bold(true).italic(true).link("https://placeholderapi.com/ecloud-blocked")));
// Msg.msg(sender, "&cThere is no available data from the eCloud. Please try running &f/papi ecloud refresh&c. If this does not resolve the issue, the eCloud may be blocked by your firewall, server host, or service provider.\n\nMore information: &fhttps://placeholderapi.com/ecloud-blocked");
return;
}
target.evaluate(plugin, sender, search, params.subList(1, params.size()));
}

View File

@@ -29,6 +29,7 @@ import java.lang.reflect.Type;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
@@ -110,6 +111,10 @@ public final class CloudExpansionManager {
return Map.copyOf(cache);
}
public boolean isEmpty() {
return cache.isEmpty();
}
@NotNull
@Unmodifiable
public Map<String, CloudExpansion> getCloudExpansionsInstalled() {
@@ -201,6 +206,8 @@ public final class CloudExpansionManager {
for (String name : toRemove) {
values.remove(name);
}
} catch (UnknownHostException e) {
logger.atWarning().log("There is no data available from the eCloud. Please try running /papi refresh. If this does not resolve the issue, the eCloud may be blocked by your firewall, server host, or service provider.\n\nMore information: https://placeholderapi.com/ecloud-blocked", e);
} catch (Throwable e) {
// ugly swallowing of every throwable, but we have to be defensive
logger.atWarning().log("Failed to download expansion information", e);