Skip to content
Permalink
Browse files

Load extension classes synchronously.

CMDHELPER-3179
  • Loading branch information...
PseudoKnight committed Aug 11, 2019
1 parent c0ccab3 commit 0eac533e8fa89c47055c46c1ae7732ca06a572b1
Showing with 8 additions and 9 deletions.
  1. +8 −9 src/main/java/com/laytonsmith/commandhelper/CommandHelperPlugin.java
@@ -270,27 +270,22 @@ public void run() {
Prefs.SetColors();
Installer.Install(CommandHelperFileLocations.getDefault().getConfigDirectory());

getLogger().log(Level.INFO, "Running initial class discovery...");
ClassDiscoveryCache cdc = new ClassDiscoveryCache(CommandHelperFileLocations.getDefault().getCacheDirectory());
cdc.setLogger(getLogger());
ClassDiscovery.getDefaultInstance().setClassDiscoveryCache(cdc);
ClassDiscovery.getDefaultInstance().addDiscoveryLocation(ClassDiscovery.GetClassContainer(CommandHelperPlugin.class));

MSLog.initialize(CommandHelperFileLocations.getDefault().getConfigDirectory());

getLogger().log(Level.INFO, "Loading extensions in the background...");
loadingThread = new Thread("extensionloader") {
@Override
public void run() {
ExtensionManager.AddDiscoveryLocation(CommandHelperFileLocations.getDefault().getExtensionsDirectory());

if(OSUtils.GetOS() == OSUtils.OS.WINDOWS) {
getLogger().log(Level.INFO, "Caching extensions...");
getLogger().log(Level.INFO, "Caching extensions in the background...");
ExtensionManager.Cache(CommandHelperFileLocations.getDefault().getExtensionCacheDirectory());
getLogger().log(Level.INFO, "Extension caching complete.");
}

ExtensionManager.Initialize(ClassDiscovery.getDefaultInstance());
getLogger().log(Level.INFO, "Extension loading complete.");
}
};
loadingThread.start();
@@ -320,15 +315,19 @@ public void run() {
@Override
public void onEnable() {
if(loadingThread.isAlive()) {
getLogger().log(Level.INFO, "Waiting for extension loading to complete...");

getLogger().log(Level.INFO, "Waiting for extension caching to complete...");
try {
loadingThread.join();
} catch (InterruptedException ex) {
getLogger().log(Level.SEVERE, null, ex);
}
}

if(firstLoad) {
ExtensionManager.Initialize(ClassDiscovery.getDefaultInstance());
getLogger().log(Level.INFO, "Extensions initialized.");
}

//Metrics
Metrics m = new Metrics(this);
m.addCustomChart(new Metrics.SingleLineChart("player_count",

0 comments on commit 0eac533

Please sign in to comment.
You can’t perform that action at this time.