mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix /geyser reload
This commit is contained in:
parent
b246d5b4d1
commit
b23275ff6c
1 changed files with 63 additions and 43 deletions
|
@ -112,35 +112,32 @@ public class GeyserImpl implements GeyserApi {
|
||||||
|
|
||||||
private FloodgateCipher cipher;
|
private FloodgateCipher cipher;
|
||||||
private FloodgateSkinUploader skinUploader;
|
private FloodgateSkinUploader skinUploader;
|
||||||
private final NewsHandler newsHandler;
|
private NewsHandler newsHandler;
|
||||||
|
|
||||||
private volatile boolean shuttingDown = false;
|
private volatile boolean shuttingDown = false;
|
||||||
|
|
||||||
private final ScheduledExecutorService scheduledThread;
|
private ScheduledExecutorService scheduledThread;
|
||||||
|
|
||||||
private final BedrockServer bedrockServer;
|
private BedrockServer bedrockServer;
|
||||||
private final PlatformType platformType;
|
private final PlatformType platformType;
|
||||||
private final GeyserBootstrap bootstrap;
|
private final GeyserBootstrap bootstrap;
|
||||||
|
|
||||||
private final Metrics metrics;
|
private Metrics metrics;
|
||||||
|
|
||||||
private static GeyserImpl instance;
|
private static GeyserImpl instance;
|
||||||
|
|
||||||
private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) {
|
private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||||
long startupTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
this.bootstrap = bootstrap;
|
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
Geyser.set(this);
|
Geyser.set(this);
|
||||||
|
|
||||||
GeyserLogger logger = bootstrap.getGeyserLogger();
|
|
||||||
GeyserConfiguration config = bootstrap.getGeyserConfig();
|
|
||||||
|
|
||||||
this.platformType = platformType;
|
this.platformType = platformType;
|
||||||
|
this.bootstrap = bootstrap;
|
||||||
|
|
||||||
|
long startupTime = System.currentTimeMillis();
|
||||||
|
|
||||||
GeyserLocale.finalizeDefaultLocale(this);
|
GeyserLocale.finalizeDefaultLocale(this);
|
||||||
|
GeyserLogger logger = bootstrap.getGeyserLogger();
|
||||||
|
|
||||||
logger.info("******************************************");
|
logger.info("******************************************");
|
||||||
logger.info("");
|
logger.info("");
|
||||||
|
@ -148,10 +145,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
logger.info("");
|
logger.info("");
|
||||||
logger.info("******************************************");
|
logger.info("******************************************");
|
||||||
|
|
||||||
this.scheduledThread = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("Geyser Scheduled Thread"));
|
|
||||||
|
|
||||||
logger.setDebug(config.isDebugMode());
|
|
||||||
|
|
||||||
/* Initialize translators and registries */
|
/* Initialize translators and registries */
|
||||||
BlockRegistries.init();
|
BlockRegistries.init();
|
||||||
Registries.init();
|
Registries.init();
|
||||||
|
@ -160,6 +153,46 @@ public class GeyserImpl implements GeyserApi {
|
||||||
ItemTranslator.init();
|
ItemTranslator.init();
|
||||||
MessageTranslator.init();
|
MessageTranslator.init();
|
||||||
MinecraftLocale.init();
|
MinecraftLocale.init();
|
||||||
|
|
||||||
|
start();
|
||||||
|
|
||||||
|
GeyserConfiguration config = bootstrap.getGeyserConfig();
|
||||||
|
|
||||||
|
boolean isGui = false;
|
||||||
|
// This will check if we are in standalone and get the 'useGui' variable from there
|
||||||
|
if (platformType == PlatformType.STANDALONE) {
|
||||||
|
try {
|
||||||
|
Class<?> cls = Class.forName("org.geysermc.geyser.platform.standalone.GeyserStandaloneBootstrap");
|
||||||
|
isGui = (boolean) cls.getMethod("isUseGui").invoke(cls.cast(bootstrap));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.debug("Failed detecting if standalone is using a GUI; if this is a GeyserConnect instance this can be safely ignored.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;
|
||||||
|
String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
|
||||||
|
if (isGui) {
|
||||||
|
message += GeyserLocale.getLocaleStringLog("geyser.core.finish.gui");
|
||||||
|
} else {
|
||||||
|
message += GeyserLocale.getLocaleStringLog("geyser.core.finish.console");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(message);
|
||||||
|
|
||||||
|
if (platformType == PlatformType.STANDALONE) {
|
||||||
|
logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn"));
|
||||||
|
} else if (config.getRemote().getAuthType() == AuthType.FLOODGATE) {
|
||||||
|
VersionCheckUtils.checkForOutdatedFloodgate(logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void start() {
|
||||||
|
this.scheduledThread = Executors.newSingleThreadScheduledExecutor(new DefaultThreadFactory("Geyser Scheduled Thread"));
|
||||||
|
|
||||||
|
GeyserLogger logger = bootstrap.getGeyserLogger();
|
||||||
|
GeyserConfiguration config = bootstrap.getGeyserConfig();
|
||||||
|
logger.setDebug(config.isDebugMode());
|
||||||
|
|
||||||
ScoreboardUpdater.init();
|
ScoreboardUpdater.init();
|
||||||
|
|
||||||
ResourcePack.loadPacks();
|
ResourcePack.loadPacks();
|
||||||
|
@ -231,7 +264,8 @@ public class GeyserImpl implements GeyserApi {
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Not getting git properties for the news handler as we are in a development environment.");
|
logger.debug("Not getting git properties for the news handler as we are in a development environment.");
|
||||||
}
|
}
|
||||||
newsHandler = new NewsHandler(branch, buildNumber);
|
|
||||||
|
this.newsHandler = new NewsHandler(branch, buildNumber);
|
||||||
|
|
||||||
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
CooldownUtils.setDefaultShowCooldown(config.getShowCooldown());
|
||||||
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
|
||||||
|
@ -367,32 +401,6 @@ public class GeyserImpl implements GeyserApi {
|
||||||
metrics = null;
|
metrics = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isGui = false;
|
|
||||||
// This will check if we are in standalone and get the 'useGui' variable from there
|
|
||||||
if (platformType == PlatformType.STANDALONE) {
|
|
||||||
try {
|
|
||||||
Class<?> cls = Class.forName("org.geysermc.geyser.platform.standalone.GeyserStandaloneBootstrap");
|
|
||||||
isGui = (boolean) cls.getMethod("isUseGui").invoke(cls.cast(bootstrap));
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.debug("Failed detecting if standalone is using a GUI; if this is a GeyserConnect instance this can be safely ignored.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;
|
|
||||||
String message = GeyserLocale.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
|
|
||||||
if (isGui) {
|
|
||||||
message += GeyserLocale.getLocaleStringLog("geyser.core.finish.gui");
|
|
||||||
} else {
|
|
||||||
message += GeyserLocale.getLocaleStringLog("geyser.core.finish.console");
|
|
||||||
}
|
|
||||||
logger.info(message);
|
|
||||||
|
|
||||||
if (platformType == PlatformType.STANDALONE) {
|
|
||||||
logger.warning(GeyserLocale.getLocaleStringLog("geyser.core.movement_warn"));
|
|
||||||
} else if (config.getRemote().getAuthType() == AuthType.FLOODGATE) {
|
|
||||||
VersionCheckUtils.checkForOutdatedFloodgate(logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
|
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,6 +455,8 @@ public class GeyserImpl implements GeyserApi {
|
||||||
newsHandler.shutdown();
|
newsHandler.shutdown();
|
||||||
this.getCommandManager().getCommands().clear();
|
this.getCommandManager().getCommands().clear();
|
||||||
|
|
||||||
|
ResourcePack.PACKS.clear();
|
||||||
|
|
||||||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,9 +479,19 @@ public class GeyserImpl implements GeyserApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GeyserImpl start(PlatformType platformType, GeyserBootstrap bootstrap) {
|
public static GeyserImpl start(PlatformType platformType, GeyserBootstrap bootstrap) {
|
||||||
|
if (instance == null) {
|
||||||
return new GeyserImpl(platformType, bootstrap);
|
return new GeyserImpl(platformType, bootstrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We've been reloaded
|
||||||
|
if (instance.isShuttingDown()) {
|
||||||
|
instance.shuttingDown = false;
|
||||||
|
instance.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public GeyserLogger getLogger() {
|
public GeyserLogger getLogger() {
|
||||||
return bootstrap.getGeyserLogger();
|
return bootstrap.getGeyserLogger();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue