Move cleanup to front, don't discover if not necessary

This commit is contained in:
LeoDog896 2021-03-24 12:23:44 -04:00
parent 2de657bca6
commit 606079ea98

View File

@ -127,10 +127,21 @@ public class ExtensionManager {
}
}
// Periodically cleanup observers
MinecraftServer.getSchedulerManager().buildTask(() -> {
for (Extension ext : extensions.values()) {
ext.cleanupObservers();
}
}).repeat(1L, TimeUnit.MINUTE).schedule();
// Load extensions
{
// Get all extensions and order them accordingly.
List<DiscoveredExtension> discoveredExtensions = discoverExtensions();
// Don't waste resources on doing extra actions if there is nothing to do.
if (discoveredExtensions.isEmpty()) return;
discoveredExtensions = generateLoadOrder(discoveredExtensions);
loadDependencies(discoveredExtensions);
@ -164,13 +175,6 @@ public class ExtensionManager {
}
}
}
// periodically cleanup observers
MinecraftServer.getSchedulerManager().buildTask(() -> {
for (Extension ext : extensions.values()) {
ext.cleanupObservers();
}
}).repeat(1L, TimeUnit.MINUTE).schedule();
}
/**