3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Spigot: Temporarily work around issue where channel handlers don't see the connection

This 'fixes' issues where Floodgate may not work when the first player joins.
Dieser Commit ist enthalten in:
Camotoy 2021-12-28 15:36:45 -05:00
Ursprung 2037a924bd
Commit b246d5b4d1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.platform.spigot;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
@ -34,10 +35,12 @@ import org.bukkit.Bukkit;
import org.geysermc.geyser.GeyserBootstrap;
import org.geysermc.geyser.network.netty.GeyserInjector;
import org.geysermc.geyser.network.netty.LocalServerChannelWrapper;
import org.geysermc.geyser.network.netty.LocalSession;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.net.InetAddress;
import java.util.List;
public class GeyserSpigotInjector extends GeyserInjector {
@ -128,6 +131,8 @@ public class GeyserSpigotInjector extends GeyserInjector {
allServerChannels.add(channelFuture);
this.localChannel = channelFuture;
this.serverSocketAddress = channelFuture.channel().localAddress();
workAroundWeirdBug(bootstrap);
}
@SuppressWarnings("unchecked")
@ -158,6 +163,18 @@ public class GeyserSpigotInjector extends GeyserInjector {
return childHandler;
}
/**
* Work around an odd bug where the first connection might not initialize all channel handlers on the main pipeline -
* send a dummy status request down that acts as the first connection, then.
* For the future, if someone wants to properly fix this - as of December 28, 2021, it happens on 1.16.5/1.17.1/1.18.1 EXCEPT Spigot 1.16.5
*/
private void workAroundWeirdBug(GeyserBootstrap bootstrap) {
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(),
bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress,
InetAddress.getLoopbackAddress().getHostAddress(), new MinecraftProtocol());
session.connect();
}
@Override
public void shutdown() {
if (this.allServerChannels != null) {