mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-21 11:45:25 +01:00
Don't run dependency download on a separate thread on bukkit
This commit is contained in:
parent
00e80166b3
commit
bd1f50c502
@ -47,7 +47,8 @@ public class DiscordSRVBukkitBootstrap extends BukkitBootstrap implements IBoots
|
||||
logger,
|
||||
plugin.getDataFolder().toPath(),
|
||||
getDependencyResources(),
|
||||
getClasspathAppender()
|
||||
getClasspathAppender(),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,8 @@ public class DiscordSRVBungeeBootstrap extends BungeeBootstrap implements IBoots
|
||||
logger,
|
||||
plugin.getDataFolder().toPath(),
|
||||
new String[] {"dependencies/runtimeDownload-bungee.txt"},
|
||||
getClasspathAppender()
|
||||
getClasspathAppender(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,17 @@ public class LifecycleManager {
|
||||
private final Logger logger;
|
||||
private final ExecutorService taskPool;
|
||||
private final DependencyLoader dependencyLoader;
|
||||
private final CompletableFuture<?> completableFuture;
|
||||
private CompletableFuture<?> completableFuture;
|
||||
|
||||
public LifecycleManager(
|
||||
Logger logger,
|
||||
Path dataDirectory,
|
||||
String[] dependencyResources,
|
||||
ClasspathAppender classpathAppender
|
||||
ClasspathAppender classpathAppender,
|
||||
boolean useExecutor
|
||||
) throws IOException {
|
||||
this.logger = logger;
|
||||
this.taskPool = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "DiscordSRV Initialization"));
|
||||
this.taskPool = useExecutor ? Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "DiscordSRV Initialization")) : null;
|
||||
|
||||
List<String> resourcePaths = new ArrayList<>(Collections.singletonList(
|
||||
"dependencies/runtimeDownload-common.txt"
|
||||
@ -63,9 +64,6 @@ public class LifecycleManager {
|
||||
classpathAppender,
|
||||
resourcePaths.toArray(new String[0])
|
||||
);
|
||||
|
||||
this.completableFuture = dependencyLoader.download();
|
||||
completableFuture.whenComplete((v, t) -> taskPool.shutdown());
|
||||
}
|
||||
|
||||
public void loadAndEnable(Supplier<DiscordSRV> discordSRVSupplier) {
|
||||
@ -76,6 +74,11 @@ public class LifecycleManager {
|
||||
|
||||
private boolean load() {
|
||||
try {
|
||||
this.completableFuture = dependencyLoader.download();
|
||||
if (taskPool != null) {
|
||||
completableFuture.whenComplete((v, t) -> taskPool.shutdown());
|
||||
}
|
||||
|
||||
completableFuture.get();
|
||||
return true;
|
||||
} catch (InterruptedException ignored) {
|
||||
|
@ -64,7 +64,8 @@ public class DiscordSRVVelocityBootstrap implements IBootstrap {
|
||||
this.logger,
|
||||
dataDirectory,
|
||||
new String[] {"dependencies/runtimeDownload-velocity.txt"},
|
||||
classpathAppender
|
||||
classpathAppender,
|
||||
true
|
||||
);
|
||||
this.proxyServer = proxyServer;
|
||||
this.pluginContainer = pluginContainer;
|
||||
|
Loading…
Reference in New Issue
Block a user