3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-26 00:00:41 +01:00

Fixed auto-setting auth-type to Floodgate

Dieser Commit ist enthalten in:
Tim203 2023-04-26 18:52:12 +02:00
Ursprung d4ffecb500
Commit 7c1100b830
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 736F3CD49EF01DBF
9 geänderte Dateien mit 51 neuen und 45 gelöschten Zeilen

Datei anzeigen

@ -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<InetSocketAddress> findCompatibleListener() {
return getProxy().getConfig().getListeners().stream()
.filter(info -> info.getSocketAddress() instanceof InetSocketAddress)

Datei anzeigen

@ -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<ModContainer> 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) {

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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
*

Datei anzeigen

@ -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();
}
}

Datei anzeigen

@ -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();
}

Datei anzeigen

@ -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")) {

Datei anzeigen

@ -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 {