mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Always bypass Paper's username validation for Floodgate players
This commit is contained in:
@@ -76,14 +76,19 @@ public final class SpigotDataHandler extends CommonDataHandler {
|
||||
|
||||
// the server will do all the work if BungeeCord mode is enabled,
|
||||
// otherwise we have to help the server.
|
||||
boolean bungeeData = ProxyUtils.isProxyData();
|
||||
boolean needsAssistance = !ProxyUtils.isProxyData();
|
||||
|
||||
// Paper and forks now have username validation, so we have to help Paper as well.
|
||||
// The username is only validated in the login start packet, and that packet doesn't reach
|
||||
// the server handler when we follow the non-bungee-data route
|
||||
needsAssistance |= ProxyUtils.isPaperServer();
|
||||
|
||||
if (!bungeeData) {
|
||||
if (needsAssistance) {
|
||||
// Use a spoofedUUID for initUUID (just like Bungeecord)
|
||||
setValue(networkManager, "spoofedUUID", player.getCorrectUniqueId());
|
||||
}
|
||||
|
||||
return bungeeData;
|
||||
return !needsAssistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.lang.reflect.Field;
|
||||
public final class ProxyUtils {
|
||||
private static final Field IS_BUNGEE_DATA;
|
||||
private static final Field IS_MODERN_FORWARDING;
|
||||
private static final boolean IS_PAPER_SERVER;
|
||||
|
||||
static {
|
||||
Class<?> spigotConfig = ReflectionUtils.getClass("org.spigotmc.SpigotConfig");
|
||||
@@ -41,14 +42,22 @@ public final class ProxyUtils {
|
||||
checkNotNull(IS_BUNGEE_DATA, "bungee field cannot be null. Are you using CraftBukkit?");
|
||||
|
||||
Field velocitySupport;
|
||||
boolean isPaper = false;
|
||||
|
||||
try {
|
||||
Class<?> paperConfig = Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
isPaper = true;
|
||||
velocitySupport = getField(paperConfig, "velocitySupport");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// We're not on a platform that has modern forwarding
|
||||
velocitySupport = null; // NOPMD - there's really not a better way around this unless you want to use an optional
|
||||
}
|
||||
IS_MODERN_FORWARDING = velocitySupport;
|
||||
IS_PAPER_SERVER = isPaper;
|
||||
}
|
||||
|
||||
public static boolean isPaperServer() {
|
||||
return IS_PAPER_SERVER;
|
||||
}
|
||||
|
||||
public static boolean isProxyData() {
|
||||
|
||||
Reference in New Issue
Block a user