Skip to content

Commit

Permalink
make the update checker run later on fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Sep 15, 2023
1 parent 340f6be commit 08b8c58
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ protected void init() {
this.channelRegistry().loadConfigChannels(this.carbonMessages);

this.messagingManager.get();
}

CompletableFuture.runAsync(() -> {
if (!this.injector.getInstance(ConfigManager.class).primaryConfig().updateChecker()) {
return;
protected final void checkVersion() {
if (!this.injector.getInstance(ConfigManager.class).primaryConfig().updateChecker()) {
return;
}
CompletableFuture.runAsync(() -> new UpdateChecker(this.logger).checkVersion()).whenComplete(($, thr) -> {
if (thr != null) {
this.logger.warn("Exception fetching version information", thr);
}
new UpdateChecker(this.logger).checkVersion();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private void registerChatListener() {
}

private void registerServerLifecycleListeners() {
ServerLifecycleEvents.SERVER_STARTED.register(server -> this.checkVersion());
ServerLifecycleEvents.SERVER_STOPPED.register(server -> this.shutdown());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Singleton
public final class MinecraftServerHolder {

private @Nullable MinecraftServer server;
private volatile @Nullable MinecraftServer server;

@Inject
private MinecraftServerHolder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ void onEnable() {

final Metrics metrics = new Metrics(this.plugin, BSTATS_PLUGIN_ID);
metrics.addCustomChart(new SimplePie("user_manager_type", () -> this.injector().getInstance(ConfigManager.class).primaryConfig().storageType().name()));

this.checkVersion();
}

private void discoverDiscordHooks() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public void onInitialization(final CarbonVelocityBootstrap carbonVelocityBootstr
for (final Class<? extends VelocityListener<?>> clazz : LISTENER_CLASSES) {
this.injector().getInstance(clazz).register(this.proxyServer.getEventManager(), carbonVelocityBootstrap);
}

this.checkVersion();
}

public void onShutdown() {
Expand Down

0 comments on commit 08b8c58

Please sign in to comment.