make the update checker run later on fabric

This commit is contained in:
Jason Penilla committed 2023-09-15 14:43:26 -07:00
1 parent 340f6befb3
commit 08b8c5841d
5 files changed
+14 -5

No files matched your search

@@ -127,12 +127,16 @@ public abstract class CarbonChatInternal implements CarbonChat {
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();
});
}
@@ -124,6 +124,7 @@ public final class CarbonChatFabric extends CarbonChatInternal {
}
private void registerServerLifecycleListeners() {
ServerLifecycleEvents.SERVER_STARTED.register(server -> this.checkVersion());
ServerLifecycleEvents.SERVER_STOPPED.register(server -> this.shutdown());
}
@@ -32,7 +32,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@Singleton
public final class MinecraftServerHolder {
private @Nullable MinecraftServer server;
private volatile @Nullable MinecraftServer server;
@Inject
private MinecraftServerHolder() {
@@ -112,6 +112,8 @@ public final class CarbonChatPaper extends CarbonChatInternal {
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() {
@@ -100,6 +100,8 @@ public class CarbonChatVelocity extends CarbonChatInternal {
for (final Class<? extends VelocityListener<?>> clazz : LISTENER_CLASSES) {
this.injector().getInstance(clazz).register(this.proxyServer.getEventManager(), carbonVelocityBootstrap);
}
this.checkVersion();
}
public void onShutdown() {