Fix Floodgate autodetection

This commit is contained in:
Camotoy 2023-04-26 21:11:26 -04:00
parent 8a257181b9
commit c8afd3436d
10 changed files with 39 additions and 31 deletions

View file

@ -25,7 +25,6 @@
package org.geysermc.geyser;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
import org.geysermc.geyser.text.GeyserLocale;
@ -34,10 +33,6 @@ import java.nio.file.Path;
public class FloodgateKeyLoader {
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
if (config.getRemote().authType() != AuthType.FLOODGATE) {
return geyserDataFolder.resolve(config.getFloodgateKeyFile());
}
// Always prioritize Floodgate's key, if it is installed.
// This mostly prevents people from trying to copy the key and corrupting it in the process
if (floodgateDataFolder != null) {

View file

@ -170,5 +170,8 @@ public interface GeyserBootstrap {
*/
int getServerPort();
boolean isFloodgatePluginPresent();
/**
* Tests if Floodgate is installed, loads the Floodgate key if so, and returns the result of Floodgate installed.
*/
boolean testFloodgatePluginPresent();
}

View file

@ -324,11 +324,12 @@ public class GeyserImpl implements GeyserApi {
}
}
if (config.getRemote().authType() == AuthType.FLOODGATE && !bootstrap.isFloodgatePluginPresent()) {
boolean floodgatePresent = bootstrap.testFloodgatePluginPresent();
if (config.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) {
logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
return;
} else if (config.isAutoconfiguredRemote() && bootstrap.isFloodgatePluginPresent()) {
} else if (config.isAutoconfiguredRemote() && floodgatePresent) {
// Floodgate installed means that the user wants Floodgate authentication
logger.debug("Auto-setting to Floodgate authentication.");
config.getRemote().setAuthType(AuthType.FLOODGATE);

View file

@ -148,8 +148,6 @@ public final class GeyserServer {
}
private ServerBootstrap createBootstrap(EventLoopGroup group) {
// TODO
boolean enableProxyProtocol = this.geyser.getConfig().getBedrock().isEnableProxyProtocol();
if (this.geyser.getConfig().isDebugMode()) {
this.geyser.getLogger().debug("EventLoop type: " + TRANSPORT.datagramChannel());
if (TRANSPORT.datagramChannel() == NioDatagramChannel.class) {