mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix Floodgate autodetection
This commit is contained in:
parent
8a257181b9
commit
c8afd3436d
10 changed files with 39 additions and 31 deletions
|
@ -36,7 +36,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
|
@ -136,8 +135,6 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig.loadFloodgate(this);
|
|
||||||
|
|
||||||
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
// Big hack - Bungee does not provide us an event to listen to, so schedule a repeating
|
||||||
// task that waits for a field to be filled which is set after the plugin enable
|
// task that waits for a field to be filled which is set after the plugin enable
|
||||||
// process is complete
|
// process is complete
|
||||||
|
@ -260,8 +257,12 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return getProxy().getPluginManager().getPlugin("floodgate") != null;
|
if (getProxy().getPluginManager().getPlugin("floodgate") != null) {
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<InetSocketAddress> findCompatibleListener() {
|
private Optional<InetSocketAddress> findCompatibleListener() {
|
||||||
|
|
|
@ -60,6 +60,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||||
|
@ -138,7 +139,6 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||||
*/
|
*/
|
||||||
public void startGeyser(MinecraftServer server) {
|
public void startGeyser(MinecraftServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
geyserConfig.loadFloodgate(this, FabricLoader.getInstance().getModContainer("floodgate").orElse(null));
|
|
||||||
|
|
||||||
GeyserImpl.start();
|
GeyserImpl.start();
|
||||||
|
|
||||||
|
@ -229,8 +229,13 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return FabricLoader.getInstance().getModContainer("floodgate").isPresent();
|
Optional<ModContainer> floodgate = FabricLoader.getInstance().getModContainer("floodgate");
|
||||||
|
if (floodgate.isPresent()) {
|
||||||
|
geyserConfig.loadFloodgate(this, floodgate.orElse(null));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
|
@ -62,7 +61,9 @@ import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandExecutor;
|
||||||
import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandManager;
|
import org.geysermc.geyser.platform.spigot.command.GeyserSpigotCommandManager;
|
||||||
import org.geysermc.geyser.platform.spigot.world.GeyserPistonListener;
|
import org.geysermc.geyser.platform.spigot.world.GeyserPistonListener;
|
||||||
import org.geysermc.geyser.platform.spigot.world.GeyserSpigotBlockPlaceListener;
|
import org.geysermc.geyser.platform.spigot.world.GeyserSpigotBlockPlaceListener;
|
||||||
import org.geysermc.geyser.platform.spigot.world.manager.*;
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotLegacyNativeWorldManager;
|
||||||
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotNativeWorldManager;
|
||||||
|
import org.geysermc.geyser.platform.spigot.world.manager.GeyserSpigotWorldManager;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
import org.geysermc.geyser.util.FileUtils;
|
import org.geysermc.geyser.util.FileUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -171,8 +172,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig.loadFloodgate(this);
|
|
||||||
|
|
||||||
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
|
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
|
||||||
this.geyserCommandManager.init();
|
this.geyserCommandManager.init();
|
||||||
|
|
||||||
|
@ -451,7 +450,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return Bukkit.getPluginManager().getPlugin("floodgate") != null;
|
if (Bukkit.getPluginManager().getPlugin("floodgate") != null) {
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.api.command.Command;
|
import org.geysermc.geyser.api.command.Command;
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.command.GeyserCommandManager;
|
import org.geysermc.geyser.command.GeyserCommandManager;
|
||||||
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
import org.geysermc.geyser.configuration.GeyserConfiguration;
|
||||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||||
|
@ -125,8 +124,6 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
return;
|
return;
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postStartup() {
|
private void postStartup() {
|
||||||
|
@ -233,7 +230,12 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgatePluginPresent() {
|
public boolean testFloodgatePluginPresent() {
|
||||||
return proxyServer.getPluginManager().getPlugin("floodgate").isPresent();
|
var floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||||
|
if (floodgate.isPresent()) {
|
||||||
|
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
package org.geysermc.geyser;
|
package org.geysermc.geyser;
|
||||||
|
|
||||||
import org.geysermc.geyser.api.network.AuthType;
|
|
||||||
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
|
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
|
||||||
|
@ -34,10 +33,6 @@ import java.nio.file.Path;
|
||||||
|
|
||||||
public class FloodgateKeyLoader {
|
public class FloodgateKeyLoader {
|
||||||
public static Path getKeyPath(GeyserJacksonConfiguration config, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
|
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.
|
// 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
|
// This mostly prevents people from trying to copy the key and corrupting it in the process
|
||||||
if (floodgateDataFolder != null) {
|
if (floodgateDataFolder != null) {
|
||||||
|
|
|
@ -170,5 +170,8 @@ public interface GeyserBootstrap {
|
||||||
*/
|
*/
|
||||||
int getServerPort();
|
int getServerPort();
|
||||||
|
|
||||||
boolean isFloodgatePluginPresent();
|
/**
|
||||||
|
* Tests if Floodgate is installed, loads the Floodgate key if so, and returns the result of Floodgate installed.
|
||||||
|
*/
|
||||||
|
boolean testFloodgatePluginPresent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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") + " "
|
logger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
|
||||||
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||||
return;
|
return;
|
||||||
} else if (config.isAutoconfiguredRemote() && bootstrap.isFloodgatePluginPresent()) {
|
} else if (config.isAutoconfiguredRemote() && floodgatePresent) {
|
||||||
// Floodgate installed means that the user wants Floodgate authentication
|
// Floodgate installed means that the user wants Floodgate authentication
|
||||||
logger.debug("Auto-setting to Floodgate authentication.");
|
logger.debug("Auto-setting to Floodgate authentication.");
|
||||||
config.getRemote().setAuthType(AuthType.FLOODGATE);
|
config.getRemote().setAuthType(AuthType.FLOODGATE);
|
||||||
|
|
|
@ -148,8 +148,6 @@ public final class GeyserServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerBootstrap createBootstrap(EventLoopGroup group) {
|
private ServerBootstrap createBootstrap(EventLoopGroup group) {
|
||||||
// TODO
|
|
||||||
boolean enableProxyProtocol = this.geyser.getConfig().getBedrock().isEnableProxyProtocol();
|
|
||||||
if (this.geyser.getConfig().isDebugMode()) {
|
if (this.geyser.getConfig().isDebugMode()) {
|
||||||
this.geyser.getLogger().debug("EventLoop type: " + TRANSPORT.datagramChannel());
|
this.geyser.getLogger().debug("EventLoop type: " + TRANSPORT.datagramChannel());
|
||||||
if (TRANSPORT.datagramChannel() == NioDatagramChannel.class) {
|
if (TRANSPORT.datagramChannel() == NioDatagramChannel.class) {
|
||||||
|
|
Loading…
Reference in a new issue