Skip to content

Commit

Permalink
Suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
Asleeepp committed Dec 31, 2024
1 parent 3ad9b84 commit 2a20dda
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -134,6 +135,7 @@
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -1711,14 +1713,9 @@ private static void logErrorDetails(@Nullable Throwable cause, String[] info, @N
private static Set<PluginDescriptionFile> identifyPluginsInStackTrace(StackTraceElement[] stackTrace) {
Set<PluginDescriptionFile> stackPlugins = new HashSet<>();
for (StackTraceElement element : stackTrace) {
try {
Class<?> clazz = Class.forName(element.getClassName());
if (Plugin.class.isAssignableFrom(clazz)) {
Plugin plugin = JavaPlugin.getProvidingPlugin(clazz);
stackPlugins.add(plugin.getDescription());
}
} catch (ClassNotFoundException | NoClassDefFoundError | IllegalStateException ignored) {
}
pluginPackages.entrySet().stream()
.filter(entry -> element.getClassName().startsWith(entry.getKey()))
.forEach(entry -> stackPlugins.add(entry.getValue()));
}
return stackPlugins;
}
Expand All @@ -1733,7 +1730,8 @@ private static void logPlatformSupportInfo(String issuesUrl, String downloadUrl,
logEx("You're running a (buggy) nightly version of Skript. If this is not a test server, switch to a stable release.");
logEx("Please report this bug to: " + issuesUrl);
} else if (!serverPlatform.supported) {
logEx("Your server platform appears to be unsupported by Skript. Consider switching to Paper or Spigot for better compatibility.");
String supportedPlatforms = getSupportedPlatforms();
logEx("Your server platform appears to be unsupported by Skript. Consider switching to one of the supported platforms: " + supportedPlatforms + " for better compatibility.");
} else if (updater != null && updater.getReleaseStatus() == ReleaseStatus.OUTDATED) {
logEx("You're running an outdated version of Skript! Update to the latest version here: " + downloadUrl);
} else {
Expand All @@ -1742,6 +1740,13 @@ private static void logPlatformSupportInfo(String issuesUrl, String downloadUrl,
}
}

private static String getSupportedPlatforms() {
return Arrays.stream(ServerPlatform.values())
.filter(platform -> platform.supported)
.map(ServerPlatform::name)
.collect(Collectors.joining(","));
}

private static void logExAddonInfo(String issuesUrl, Set<PluginDescriptionFile> stackPlugins) {
if (pluginPackages.isEmpty()) {
logEx("Report the issue: " + issuesUrl);
Expand Down

0 comments on commit 2a20dda

Please sign in to comment.