mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Velocity: only initialize injector on Minecraft listener bound
This commit is contained in:
parent
0537c04ef6
commit
4b05b74a9a
1 changed files with 12 additions and 6 deletions
|
@ -31,6 +31,7 @@ import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.proxy.ListenerBoundEvent;
|
import com.velocitypowered.api.event.proxy.ListenerBoundEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
|
import com.velocitypowered.api.network.ListenerType;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -86,7 +87,8 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
if (!configFolder.toFile().exists())
|
if (!configFolder.toFile().exists())
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
configFolder.toFile().mkdirs();
|
configFolder.toFile().mkdirs();
|
||||||
File configFile = FileUtils.fileOrCopiedFromResource(configFolder.resolve("config.yml").toFile(), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
File configFile = FileUtils.fileOrCopiedFromResource(configFolder.resolve("config.yml").toFile(),
|
||||||
|
"config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||||
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserVelocityConfiguration.class);
|
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserVelocityConfiguration.class);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
|
logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
|
||||||
|
@ -116,13 +118,15 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
try {
|
try {
|
||||||
// Should only exist on 1.0
|
// Should only exist on 1.0
|
||||||
Class.forName("org.geysermc.floodgate.FloodgateAPI");
|
Class.forName("org.geysermc.floodgate.FloodgateAPI");
|
||||||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.outdated", "https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"));
|
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.outdated",
|
||||||
|
"https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/"));
|
||||||
return;
|
return;
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && !proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
|
||||||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||||
|
+ LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||||
return;
|
return;
|
||||||
} else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
} else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||||
// Floodgate installed means that the user wants Floodgate authentication
|
// Floodgate installed means that the user wants Floodgate authentication
|
||||||
|
@ -188,9 +192,11 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onProxyBound(ListenerBoundEvent event) {
|
public void onProxyBound(ListenerBoundEvent event) {
|
||||||
|
if (event.getListenerType() == ListenerType.MINECRAFT && geyserInjector != null) {
|
||||||
// After this bound, we know that the channel initializer cannot change without it being ineffective for Velocity, too
|
// After this bound, we know that the channel initializer cannot change without it being ineffective for Velocity, too
|
||||||
geyserInjector.initializeLocalChannel(this);
|
geyserInjector.initializeLocalChannel(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BootstrapDumpInfo getDumpInfo() {
|
public BootstrapDumpInfo getDumpInfo() {
|
||||||
|
|
Loading…
Reference in a new issue