From 8ec2dfc8aa4bf8dfd24a93c12f4935b09048c9bc Mon Sep 17 00:00:00 2001 From: Zoriot Date: Sat, 18 Jul 2026 00:28:45 +0200 Subject: [PATCH 1/2] Support bungeecord & velocity for plugin updates --- .../autoplug/client/console/Commands.java | 3 +- .../tasks/updater/mods/ModrinthAPI.java | 14 ++++---- .../plugins/InstalledPluginLoader.java | 36 +++++++++++++++++++ .../tasks/updater/plugins/ResourceFinder.java | 6 ++-- .../updater/plugins/TaskPluginsUpdater.java | 4 ++- .../tasks/updater/TestPluginUpdaters.java | 3 +- 6 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java diff --git a/src/main/java/com/osiris/autoplug/client/console/Commands.java b/src/main/java/com/osiris/autoplug/client/console/Commands.java index df18d2c1..5e37ec10 100644 --- a/src/main/java/com/osiris/autoplug/client/console/Commands.java +++ b/src/main/java/com/osiris/autoplug/client/console/Commands.java @@ -57,6 +57,7 @@ import com.osiris.autoplug.client.utils.tasks.MyBThreadManager; import com.osiris.autoplug.client.utils.tasks.UtilsTasks; import com.osiris.jlib.logger.AL; +import com.osiris.autoplug.client.tasks.updater.plugins.InstalledPluginLoader; /** * Listens for input started with . @@ -427,7 +428,7 @@ public static boolean installPlugin(String command) throws Exception { MinecraftPlugin plugin2 = new MinecraftPlugin(new File(pluginsDir + "/" + tempName).getAbsolutePath(), tempName, "0", "", 0, 0, ""); plugin2.setModrinthId(input.replace(repo, "").trim()); - result = new ResourceFinder().findPluginByModrinthId(plugin2, mcVersion); + result = new ResourceFinder().findPluginByModrinthId(new InstalledPluginLoader(updaterConfig.server_software.asString()).getLoaderList(), plugin2, mcVersion); } /* Nothing of the above worked thus do search by name diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java index 1850d673..d45039d8 100644 --- a/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java +++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/mods/ModrinthAPI.java @@ -17,6 +17,7 @@ import java.io.File; import java.time.Instant; +import java.util.List; public class ModrinthAPI { @@ -38,16 +39,15 @@ private boolean isInt(String s) { */ public SearchResult searchUpdateMod(InstalledModLoader modLoader, MinecraftMod mod, String mcVersion) { if (mod.modrinthId == null && !isInt(mod.curseforgeId)) mod.modrinthId = mod.curseforgeId; // Slug - SearchResult res = searchUpdate((modLoader.isFabric || modLoader.isQuilt ? "fabric" : "forge"),mod.modrinthId,mcVersion, mod.installationPath, mod.forceLatest); + SearchResult res = searchUpdate((modLoader.isFabric || modLoader.isQuilt ? List.of("fabric") : List.of("forge")),mod.modrinthId,mcVersion, mod.installationPath, mod.forceLatest); res.mod = mod; return res; } - public SearchResult searchUpdatePlugin(MinecraftPlugin plugin, String mcVersion) { //TODO: probably don't hardcode spigot and papermc - return searchUpdate("spigot\",\"paper", plugin.getModrinthId(), mcVersion, plugin.getInstallationPath(), false); + public SearchResult searchUpdatePlugin(List loaders, MinecraftPlugin plugin, String mcVersion) { + return searchUpdate(loaders, plugin.getModrinthId(), mcVersion, plugin.getInstallationPath(), false); } - private SearchResult searchUpdate(String loader, String id, String mcVersion, String installPath, boolean forceLatest) { - - String url = baseUrl + "/project/" + id + "/version?loaders=[\"" + loader + "\"]&game_versions=[\"" + mcVersion + "\"]"; + private SearchResult searchUpdate(List loaders, String id, String mcVersion, String installPath, boolean forceLatest) { + String url = baseUrl + "/project/" + id + "/version?loaders=[\"" + String.join( "\",\"", loaders) + "\"]&game_versions=[\"" + mcVersion + "\"]"; url = new UtilsURL().clean(url); Exception exception = null; String latest = null; @@ -67,7 +67,7 @@ private SearchResult searchUpdate(String loader, String id, String mcVersion, St if (!isInt(id)) { // Try another url, with slug replaced _ with - url = baseUrl + "/project/" + id.replace("_", "-") + "/version?loaders=[\"" + - loader + "\"]" + (forceLatest ? "" : "&game_versions=[\"" + mcVersion + "\"]"); + String.join( "\",\"", loaders) + "\"]" + (forceLatest ? "" : "&game_versions=[\"" + mcVersion + "\"]"); AL.debug(this.getClass(), url); release = Json.getAsJsonArray(url) .get(0).getAsJsonObject(); diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java new file mode 100644 index 00000000..84fc1fd7 --- /dev/null +++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java @@ -0,0 +1,36 @@ +package com.osiris.autoplug.client.tasks.updater.plugins; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class InstalledPluginLoader { + public Loader loader; + + public InstalledPluginLoader(@NotNull String software) { + if (software.equalsIgnoreCase("velocity")) { + loader = Loader.VELOCITY; + } else if (software.equalsIgnoreCase("bungeecord")) { + loader = Loader.BUNGEECORD; + } else loader = Loader.SPIGOT_AND_FORKS; + } + + public List getLoaderList() { + switch (loader) { + case VELOCITY: + return List.of("velocity"); + case BUNGEECORD: + return List.of("bungeecord", "waterfall"); + case SPIGOT_AND_FORKS: + return List.of("spigot", "paper", "purpur"); + } + return List.of(); + } + + public enum Loader { + VELOCITY, + BUNGEECORD, + SPIGOT_AND_FORKS + } + +} diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/ResourceFinder.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/ResourceFinder.java index 4d3d38f4..7d0bf079 100644 --- a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/ResourceFinder.java +++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/ResourceFinder.java @@ -22,6 +22,8 @@ import com.osiris.autoplug.client.tasks.updater.search.spigot.SpigotSearchById; import com.osiris.autoplug.client.tasks.updater.search.spigot.SpigotSearchByName; +import java.util.List; + public class ResourceFinder { /** @@ -77,8 +79,8 @@ public SearchResult findPluginByBukkitId(MinecraftPlugin plugin) { sr.plugin = plugin; return sr; } - public SearchResult findPluginByModrinthId(MinecraftPlugin plugin, String mcVersion) { - SearchResult sr = new ModrinthAPI().searchUpdatePlugin(plugin, mcVersion); + public SearchResult findPluginByModrinthId(List loaders, MinecraftPlugin plugin, String mcVersion) { + SearchResult sr = new ModrinthAPI().searchUpdatePlugin(loaders, plugin, mcVersion); sr.plugin = plugin; return sr; } diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java index ce1cbd91..cb3fafd1 100644 --- a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java +++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/TaskPluginsUpdater.java @@ -302,6 +302,8 @@ else if (installedPlugin.getVersion() == null || installedPlugin.getVersion().tr if (mcVersion == null) updaterConfig.server_updater_version.asString(); if (mcVersion == null) mcVersion = Server.getMCVersion(); + List loaders = new InstalledPluginLoader(updaterConfig.server_software.asString()).getLoaderList(); + for (MinecraftPlugin pl : includedPlugins) { try { @@ -325,7 +327,7 @@ else if (installedPlugin.getVersion() == null || installedPlugin.getVersion().tr } else if (pl.getModrinthId() != null) { // MODRINTH PLUGIN sizeModrinthPlugins++; String finalMcVersion = mcVersion; - activeFutures.add(executorService.submit(() -> new ResourceFinder().findPluginByModrinthId(pl, finalMcVersion))); + activeFutures.add(executorService.submit(() -> new ResourceFinder().findPluginByModrinthId(loaders, pl, finalMcVersion))); } else { sizeUnknownPlugins++; // UNKNOWN PLUGIN pl.setIgnoreContentType(true); // TODO temporary workaround for xamazon-json content type curseforge/bukkit issue: https://github.com/Osiris-Team/AutoPlug-Client/issues/109 diff --git a/src/test/java/com/osiris/autoplug/client/tasks/updater/TestPluginUpdaters.java b/src/test/java/com/osiris/autoplug/client/tasks/updater/TestPluginUpdaters.java index 59e87d44..2f4bda07 100644 --- a/src/test/java/com/osiris/autoplug/client/tasks/updater/TestPluginUpdaters.java +++ b/src/test/java/com/osiris/autoplug/client/tasks/updater/TestPluginUpdaters.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test; import java.io.IOException; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertSame; @@ -36,7 +37,7 @@ void testModrinth() throws IOException { UtilsTest.init(); MinecraftPlugin pl = new MinecraftPlugin("./plugins/", "BMMarker", "0.0.0", "Miraculixx", 0, 0, null); pl.modrinthId = "a8UoyV2h"; - SearchResult sr = new ModrinthAPI().searchUpdatePlugin(pl, "1.21.1"); + SearchResult sr = new ModrinthAPI().searchUpdatePlugin(List.of("paper"), pl, "1.21.1"); assertSame(SearchResult.Type.UPDATE_AVAILABLE, sr.type); } } From cbc08b21d2f331fe55deb572569aeb4581d5f974 Mon Sep 17 00:00:00 2001 From: Zoriot Date: Sat, 18 Jul 2026 13:33:14 +0200 Subject: [PATCH 2/2] Add folia as supported loaders - Geyser Extensions are currently not supported because the updating logic itself doesn't allow it - sponge and multi plugin loader hacve to be carefully tested any should be implemented in a seperate pr. --- .../plugins/InstalledPluginLoader.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java index 84fc1fd7..ceaca588 100644 --- a/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java +++ b/src/main/java/com/osiris/autoplug/client/tasks/updater/plugins/InstalledPluginLoader.java @@ -3,16 +3,36 @@ import org.jetbrains.annotations.NotNull; import java.util.List; +import java.util.Locale; +import java.util.Set; public class InstalledPluginLoader { public Loader loader; + private static final Set BUNGEE_FORKS = Set.of( + "bungeecord", + "waterfall" + ); + + private static final Set FOLIA_FORKS = Set.of( + "folia", + "luminolmc", + "canvas", + "shreddedpaper" + ); + public InstalledPluginLoader(@NotNull String software) { - if (software.equalsIgnoreCase("velocity")) { + String type = software.toLowerCase(Locale.ROOT); + + if (type.equals("velocity")) { loader = Loader.VELOCITY; - } else if (software.equalsIgnoreCase("bungeecord")) { + } else if (BUNGEE_FORKS.contains(type)) { loader = Loader.BUNGEECORD; - } else loader = Loader.SPIGOT_AND_FORKS; + } else if (FOLIA_FORKS.contains(type)) { + loader = Loader.FOLIA_COMPATIBLE; + } else { + loader = Loader.SPIGOT_AND_FORKS; + } } public List getLoaderList() { @@ -22,7 +42,9 @@ public List getLoaderList() { case BUNGEECORD: return List.of("bungeecord", "waterfall"); case SPIGOT_AND_FORKS: - return List.of("spigot", "paper", "purpur"); + return List.of("spigot", "paper", "purpur", "bukkit"); + case FOLIA_COMPATIBLE: + return List.of("folia"); } return List.of(); } @@ -30,7 +52,8 @@ public List getLoaderList() { public enum Loader { VELOCITY, BUNGEECORD, - SPIGOT_AND_FORKS + SPIGOT_AND_FORKS, + FOLIA_COMPATIBLE } }