From 871cee060d015b2736ed1d367998b0a88ee45812 Mon Sep 17 00:00:00 2001 From: JustinasLa Date: Tue, 29 Sep 2026 18:36:13 +0200 Subject: [PATCH] fix: re-check soft dependencies after every plugin has enabled Paper breaks the Cooking/CustomCrops/ItemsAdder/MMOItems/nightcore dependency cycle by enabling MMOItems after activity. Activity then treated every m.. path as unusable for the whole session, so daily/weekly reward scrolls failed with "could not be handed over", m.* icons fell back to PAPER and MMOItems station crafts went uncredited. Hooks are now registered on the first tick, and the config is reloaded there when an item plugin's availability changed since enable. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../activitytf/ActivityPlugin.java | 10 ++++++- .../config/ActivityConfiguration.java | 26 ++++++++++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/tfminecraft/activitytf/ActivityPlugin.java b/src/main/java/net/tfminecraft/activitytf/ActivityPlugin.java index 0f1c97d..2f2f486 100644 --- a/src/main/java/net/tfminecraft/activitytf/ActivityPlugin.java +++ b/src/main/java/net/tfminecraft/activitytf/ActivityPlugin.java @@ -46,7 +46,15 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new CraftListener(manager), this); getServer().getPluginManager().registerEvents(gui, this); - registerHooks(); + // Paper can enable soft dependencies after this plugin when their own dependencies form + // a cycle, so re-check them once every plugin has finished enabling. + getServer().getScheduler().runTask(this, () -> { + if (manager.getConfiguration().itemPluginsChanged()) { + getLogger().info("An item plugin finished enabling after activity - reloading the config."); + manager.reload(); + } + registerHooks(); + }); getLogger().info("activity has been enabled!"); } diff --git a/src/main/java/net/tfminecraft/activitytf/config/ActivityConfiguration.java b/src/main/java/net/tfminecraft/activitytf/config/ActivityConfiguration.java index 42cab5d..89da819 100644 --- a/src/main/java/net/tfminecraft/activitytf/config/ActivityConfiguration.java +++ b/src/main/java/net/tfminecraft/activitytf/config/ActivityConfiguration.java @@ -129,12 +129,7 @@ public void load() { FileConfiguration config = plugin.getConfig(); messages.reload(); - List missing = new ArrayList<>(); - for (String name : List.of("TLibs", "MMOItems", "MythicLib")) { - if (!Bukkit.getPluginManager().isPluginEnabled(name)) { - missing.add(name); - } - } + List missing = missingItemPathPlugins(); itemPathsUsable = missing.isEmpty(); missingItemPathPlugins = String.join(", ", missing); itemsAdderUsable = Bukkit.getPluginManager().isPluginEnabled("ItemsAdder"); @@ -1268,6 +1263,25 @@ public boolean itemPathsUsable() { return itemPathsUsable; } + private static List missingItemPathPlugins() { + List missing = new ArrayList<>(); + for (String name : List.of("TLibs", "MMOItems", "MythicLib")) { + if (!Bukkit.getPluginManager().isPluginEnabled(name)) { + missing.add(name); + } + } + return missing; + } + + /** + * True when an item plugin was enabled or disabled since the last load, e.g. when Paper + * breaks a dependency cycle by enabling MMOItems after this plugin. + */ + public boolean itemPluginsChanged() { + return itemPathsUsable != missingItemPathPlugins().isEmpty() + || itemsAdderUsable != Bukkit.getPluginManager().isPluginEnabled("ItemsAdder"); + } + public boolean itemsAdderUsable() { return itemsAdderUsable; }