Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/java/net/tfminecraft/activitytf/ActivityPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ public void load() {
FileConfiguration config = plugin.getConfig();
messages.reload();

List<String> missing = new ArrayList<>();
for (String name : List.of("TLibs", "MMOItems", "MythicLib")) {
if (!Bukkit.getPluginManager().isPluginEnabled(name)) {
missing.add(name);
}
}
List<String> missing = missingItemPathPlugins();
itemPathsUsable = missing.isEmpty();
missingItemPathPlugins = String.join(", ", missing);
itemsAdderUsable = Bukkit.getPluginManager().isPluginEnabled("ItemsAdder");
Expand Down Expand Up @@ -1268,6 +1263,25 @@ public boolean itemPathsUsable() {
return itemPathsUsable;
}

private static List<String> missingItemPathPlugins() {
List<String> 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;
}
Expand Down