Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 14:30:17 +01:00
Properly shutdown LocalSession's, ensure transferring works properly regardless if we're injected or not
Dieser Commit ist enthalten in:
Ursprung
4ff746e48a
Commit
8b7b8cdffd
@ -49,9 +49,7 @@ application {
|
||||
|
||||
relocate("org.cloudburstmc.netty")
|
||||
relocate("org.cloudburstmc.protocol")
|
||||
relocate("com.github.steveice10.mc.protocol")
|
||||
relocate("com.github.steveice10.mc.auth")
|
||||
relocate("com.github.steveice10.packetlib")
|
||||
|
||||
tasks {
|
||||
remapJar {
|
||||
|
@ -178,7 +178,7 @@ public class GeyserSpigotInjector extends GeyserInjector {
|
||||
MinecraftProtocol protocol = new MinecraftProtocol();
|
||||
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
|
||||
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
|
||||
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper(), false);
|
||||
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
|
||||
session.connect();
|
||||
session.disconnect("");
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.*;
|
||||
import io.netty.channel.unix.PreferredDirectByteBufAllocator;
|
||||
import io.netty.handler.codec.haproxy.*;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.mcprotocollib.network.BuiltinFlags;
|
||||
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
|
||||
@ -42,6 +43,7 @@ import org.geysermc.mcprotocollib.protocol.codec.MinecraftCodecHelper;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manages a Minecraft Java session over our LocalChannel implementations.
|
||||
@ -54,24 +56,23 @@ public final class LocalSession extends TcpSession {
|
||||
private final String clientIp;
|
||||
private final PacketCodecHelper codecHelper;
|
||||
|
||||
private final boolean transferring;
|
||||
|
||||
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, MinecraftCodecHelper codecHelper, boolean transferring) {
|
||||
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, MinecraftCodecHelper codecHelper) {
|
||||
super(host, port, protocol);
|
||||
this.targetAddress = targetAddress;
|
||||
this.clientIp = clientIp;
|
||||
this.codecHelper = codecHelper;
|
||||
this.transferring = transferring;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(boolean wait) {
|
||||
public void connect(boolean wait, boolean transferring) {
|
||||
if (this.disconnected) {
|
||||
throw new IllegalStateException("Connection has already been disconnected.");
|
||||
}
|
||||
|
||||
if (DEFAULT_EVENT_LOOP_GROUP == null) {
|
||||
DEFAULT_EVENT_LOOP_GROUP = new DefaultEventLoopGroup();
|
||||
DEFAULT_EVENT_LOOP_GROUP = new DefaultEventLoopGroup(new DefaultThreadFactory(this.getClass(), true));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(
|
||||
() -> DEFAULT_EVENT_LOOP_GROUP.shutdownGracefully(100, 500, TimeUnit.MILLISECONDS)));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -880,7 +880,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
// We're going to connect through the JVM and not through TCP
|
||||
downstream = new LocalSession(this.remoteServer.address(), this.remoteServer.port(),
|
||||
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
|
||||
this.protocol, this.protocol.createHelper(), loginEvent.transferring());
|
||||
this.protocol, this.protocol.createHelper());
|
||||
this.downstream = new DownstreamSession(downstream);
|
||||
} else {
|
||||
downstream = new TcpClientSession(this.remoteServer.address(), this.remoteServer.port(), this.protocol);
|
||||
@ -1070,7 +1070,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
||||
setDaylightCycle(true);
|
||||
}
|
||||
|
||||
downstream.connect(false);
|
||||
downstream.connect(false, loginEvent.transferring());
|
||||
}
|
||||
|
||||
public void disconnect(String reason) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren