diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java index 518e461cb..4122cf547 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java @@ -136,15 +136,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap { } } - if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) { - geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); - return; - } else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) { - // Floodgate installed means that the user wants Floodgate authentication - geyserLogger.debug("Auto-setting to Floodgate authentication."); - geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE); - } - geyserConfig.loadFloodgate(this); // Big hack - Bungee does not provide us an event to listen to, so schedule a repeating @@ -268,6 +259,11 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap { return findCompatibleListener().stream().mapToInt(InetSocketAddress::getPort).findFirst().orElse(-1); } + @Override + public boolean isFloodgatePluginPresent() { + return getProxy().getPluginManager().getPlugin("floodgate") != null; + } + private Optional findCompatibleListener() { return getProxy().getConfig().getListeners().stream() .filter(info -> info.getSocketAddress() instanceof InetSocketAddress) diff --git a/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/GeyserFabricMod.java b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/GeyserFabricMod.java index 355777da1..8f39b3850 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/GeyserFabricMod.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/GeyserFabricMod.java @@ -41,7 +41,6 @@ import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.command.Command; -import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.configuration.GeyserConfiguration; @@ -60,7 +59,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; -import java.util.*; +import java.util.Map; +import java.util.UUID; public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { private static GeyserFabricMod instance; @@ -138,19 +138,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { */ public void startGeyser(MinecraftServer server) { this.server = server; - - Optional floodgate = FabricLoader.getInstance().getModContainer("floodgate"); - boolean floodgatePresent = floodgate.isPresent(); - if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) { - geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); - return; - } else if (geyserConfig.isAutoconfiguredRemote() && floodgatePresent) { - // Floodgate installed means that the user wants Floodgate authentication - geyserLogger.debug("Auto-setting to Floodgate authentication."); - geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE); - } - - geyserConfig.loadFloodgate(this, floodgate.orElse(null)); + geyserConfig.loadFloodgate(this, FabricLoader.getInstance().getModContainer("floodgate").orElse(null)); GeyserImpl.start(); @@ -240,6 +228,11 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { return ((GeyserServerPortGetter) server).geyser$getServerPort(); } + @Override + public boolean isFloodgatePluginPresent() { + return FabricLoader.getInstance().getModContainer("floodgate").isPresent(); + } + @Nullable @Override public InputStream getResourceOrNull(String resource) { diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java index 88b006851..d9b27e668 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java @@ -171,15 +171,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { return; } - if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) { - geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); - this.getPluginLoader().disablePlugin(this); - } else if (geyserConfig.isAutoconfiguredRemote() && Bukkit.getPluginManager().getPlugin("floodgate") != null) { - // Floodgate installed means that the user wants Floodgate authentication - geyserLogger.debug("Auto-setting to Floodgate authentication."); - geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE); - } - geyserConfig.loadFloodgate(this); this.geyserCommandManager = new GeyserSpigotCommandManager(geyser); @@ -458,4 +449,9 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { public int getServerPort() { return Bukkit.getPort(); } + + @Override + public boolean isFloodgatePluginPresent() { + return Bukkit.getPluginManager().getPlugin("floodgate") != null; + } } diff --git a/bootstrap/sponge/src/main/java/org/geysermc/geyser/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/geyser/platform/sponge/GeyserSpongePlugin.java index a87b51820..718c53ce8 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/geyser/platform/sponge/GeyserSpongePlugin.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/geyser/platform/sponge/GeyserSpongePlugin.java @@ -239,4 +239,9 @@ public class GeyserSpongePlugin implements GeyserBootstrap { public int getServerPort() { return Sponge.server().boundAddress().stream().mapToInt(InetSocketAddress::getPort).findFirst().orElse(-1); } + + @Override + public boolean isFloodgatePluginPresent() { + return false; + } } diff --git a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java index e99ba98bc..f410370d7 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java @@ -303,6 +303,11 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap { throw new IllegalStateException(); } + @Override + public boolean isFloodgatePluginPresent() { + return false; + } + /** * Get the {@link BeanPropertyDefinition}s for the given class * diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java index 41e797d48..8b4d9e82c 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java @@ -126,18 +126,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap { } catch (ClassNotFoundException ignored) { } - if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) { - geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " - + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); - return; - } else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) { - // Floodgate installed means that the user wants Floodgate authentication - geyserLogger.debug("Auto-setting to Floodgate authentication."); - geyserConfig.getRemote().setAuthType(AuthType.FLOODGATE); - } - geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile()); - } private void postStartup() { @@ -242,4 +231,9 @@ public class GeyserVelocityPlugin implements GeyserBootstrap { public int getServerPort() { return proxyServer.getBoundAddress().getPort(); } + + @Override + public boolean isFloodgatePluginPresent() { + return proxyServer.getPluginManager().getPlugin("floodgate").isPresent(); + } } diff --git a/core/src/main/java/org/geysermc/geyser/GeyserBootstrap.java b/core/src/main/java/org/geysermc/geyser/GeyserBootstrap.java index 46abf4f1e..e31c6bd10 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserBootstrap.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserBootstrap.java @@ -169,4 +169,6 @@ public interface GeyserBootstrap { * @return the listening port being used by the Java server. -1 if can't be found */ int getServerPort(); + + boolean isFloodgatePluginPresent(); } diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 4d7958e16..73fbe6323 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -81,7 +81,6 @@ import org.geysermc.geyser.skin.ProvidedSkins; import org.geysermc.geyser.skin.SkinProvider; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.text.MinecraftLocale; -import org.geysermc.geyser.translator.inventory.item.ItemTranslator; import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.util.*; @@ -324,7 +323,18 @@ public class GeyserImpl implements GeyserApi { logger.info("Port set from system property: " + port); } } + + if (config.getRemote().authType() == AuthType.FLOODGATE && !bootstrap.isFloodgatePluginPresent()) { + logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); + return; + } else if (config.isAutoconfiguredRemote() && bootstrap.isFloodgatePluginPresent()) { + // Floodgate installed means that the user wants Floodgate authentication + logger.debug("Auto-setting to Floodgate authentication."); + config.getRemote().setAuthType(AuthType.FLOODGATE); + } } + String remoteAddress = config.getRemote().address(); // Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry. if (!remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) { diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java index 2b0f193a7..222af341b 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java @@ -27,6 +27,7 @@ package org.geysermc.geyser.configuration; import com.fasterxml.jackson.annotation.JsonIgnore; import org.geysermc.geyser.GeyserLogger; +import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.network.BedrockListener; import org.geysermc.geyser.api.network.RemoteServer; import org.geysermc.geyser.network.CIDRMatcher; @@ -119,6 +120,8 @@ public interface GeyserConfiguration { int getPendingAuthenticationTimeout(); + boolean isAutoconfiguredRemote(); + interface IBedrockConfiguration extends BedrockListener { void setAddress(String address); @@ -157,6 +160,8 @@ public interface GeyserConfiguration { default int protocolVersion() { return GameProtocol.getJavaProtocolVersion(); } + + void setAuthType(AuthType authType); } interface IUserAuthenticationInfo {