From 289f0f3bfda96f706d2d11938d63c6090f5ae688 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 12 Jan 2022 22:21:51 +0100 Subject: [PATCH] Sort plugins on `/plot debugpaste` alphabetically (#3447) * feat: Sort plugins on debugpaste alphabetically * Put (F[A])WE at the top --- .../plotsquared/bukkit/BukkitPlatform.java | 25 ++++++++++++++++--- .../com/plotsquared/core/PlotPlatform.java | 10 ++++++++ .../plotsquared/core/command/DebugPaste.java | 9 +++++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 6100431f6..a3350e8e7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -147,6 +147,8 @@ import java.io.File; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -266,7 +268,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl faweHook = true; } catch (Exception ignored) { LOGGER.error("Incompatible version of FAWE to enable hook, please upgrade: https://ci.athion" + - ".net/job/FastAsyncWorldEdit-1.17/"); + ".net/job/FastAsyncWorldEdit/"); } } } @@ -1141,8 +1143,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl @Override public @NonNull String pluginsFormatted() { StringBuilder msg = new StringBuilder(); - Plugin[] plugins = Bukkit.getServer().getPluginManager().getPlugins(); - msg.append("Plugins (").append(plugins.length).append("): \n"); + List plugins = new ArrayList<>(); + Collections.addAll(plugins, Bukkit.getServer().getPluginManager().getPlugins()); + plugins.sort(Comparator.comparing(Plugin::getName)); + msg.append("Plugins (").append(plugins.size()).append("): \n"); for (Plugin p : plugins) { msg.append(" - ").append(p.getName()).append(":").append("\n") .append(" • Version: ").append(p.getDescription().getVersion()).append("\n") @@ -1156,6 +1160,21 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl return msg.toString(); } + @Override + @SuppressWarnings("ConstantConditions") + public @NonNull String worldEditImplementations() { + StringBuilder msg = new StringBuilder(); + if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null) { + msg.append("FastAsyncWorldEdit: ").append(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit").getDescription().getVersion()); + } else if (Bukkit.getPluginManager().getPlugin("AsyncWorldEdit") != null) { + msg.append("AsyncWorldEdit: ").append(Bukkit.getPluginManager().getPlugin("AsyncWorldEdit").getDescription().getVersion()).append("\n"); + msg.append("WorldEdit: ").append(Bukkit.getPluginManager().getPlugin("WorldEdit").getDescription().getVersion()); + } else { + msg.append("WorldEdit: ").append(Bukkit.getPluginManager().getPlugin("WorldEdit").getDescription().getVersion()); + } + return msg.toString(); + } + @Override public com.plotsquared.core.location.@NonNull World getPlatformWorld(final @NonNull String worldName) { return BukkitWorld.of(worldName); diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java index 336db9a1a..408d0f8cf 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java +++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java @@ -40,6 +40,7 @@ import com.plotsquared.core.permissions.PermissionHandler; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.queue.GlobalBlockQueue; +import com.plotsquared.core.util.AnnotationHelper; import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.PlatformWorldManager; @@ -291,6 +292,15 @@ public interface PlotPlatform

extends LocaleHolder { */ @NonNull String pluginsFormatted(); + /** + * Get the kind of WorldEdit implementation + * + * @return worldedit implementations + * @since TODO + */ + @AnnotationHelper.ApiDescription(info = "Internal use only") + @NonNull String worldEditImplementations(); + /** * Load the caption maps */ diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java index 48b6d4b54..dd643f6c5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -75,8 +75,11 @@ public class DebugPaste extends SubCommand { try { StringBuilder b = new StringBuilder(); b.append( - "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " - + "problem\n\n"); + """ + # Welcome to this paste + # It is meant to provide us at IntellectualSites with better information about your problem + """ + ); b.append("# PlotSquared Information\n"); b.append("PlotSquared Version: ").append(PlotSquared.get().getVersion()) .append("\n"); @@ -85,6 +88,8 @@ public class DebugPaste extends SubCommand { b.append("Download ID: ").append(PremiumVerification.getDownloadID()).append("\n"); b.append("This PlotSquared version is licensed to the spigot user ") .append(PremiumVerification.getUserID()).append("\n\n"); + b.append("# WorldEdit implementation:\n"); + b.append(PlotSquared.platform().worldEditImplementations()).append("\n\n"); b.append("# Server Information\n"); b.append("Server Version: ").append(PlotSquared.platform().serverImplementation()) .append("\n");