Improve startup on forge to be more stable with other mods

This commit is contained in:
Blue (Lukas Rieger) 2020-10-06 16:05:39 +02:00
parent e071ed83fa
commit 86b8deb3f3
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
3 changed files with 33 additions and 21 deletions

View File

@ -37,6 +37,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine;
@ -100,13 +101,16 @@ public ForgeMod() {
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
this.worldUUIDs.clear();
//save worlds to generate level.dat files
event.getServer().save(false, true, true);
this.serverInstance = event.getServer();
//register commands
new Commands<>(pluginInstance, event.getServer().getCommandManager().getDispatcher(), forgeSource -> new ForgeCommandSource(this, pluginInstance, forgeSource));
}
@SubscribeEvent
public void onServerStarted(FMLServerStartedEvent event) {
//save worlds to generate level.dat files
serverInstance.save(false, true, true);
new Thread(() -> {
Logger.global.logInfo("Loading...");

View File

@ -37,6 +37,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine;
@ -100,13 +101,16 @@ public ForgeMod() {
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
this.worldUUIDs.clear();
//save worlds to generate level.dat files
event.getServer().save(false, true, true);
this.serverInstance = event.getServer();
//register commands
new Commands<>(pluginInstance, event.getServer().getCommandManager().getDispatcher(), forgeSource -> new ForgeCommandSource(this, pluginInstance, forgeSource));
}
@SubscribeEvent
public void onServerStarted(FMLServerStartedEvent event) {
//save worlds to generate level.dat files
serverInstance.save(false, true, true);
new Thread(() -> {
Logger.global.logInfo("Loading...");

View File

@ -37,6 +37,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine;
@ -108,7 +109,10 @@ public void onServerStarting(FMLServerStartingEvent event) {
//register commands
new Commands<>(pluginInstance, event.getServer().getCommandManager().getDispatcher(), forgeSource -> new ForgeCommandSource(this, pluginInstance, forgeSource));
}
@SubscribeEvent
public void onServerStarted(FMLServerStartedEvent event) {
//save worlds to generate level.dat files
serverInstance.save(false, true, true);