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.netty")
|
||||||
relocate("org.cloudburstmc.protocol")
|
relocate("org.cloudburstmc.protocol")
|
||||||
relocate("com.github.steveice10.mc.protocol")
|
|
||||||
relocate("com.github.steveice10.mc.auth")
|
relocate("com.github.steveice10.mc.auth")
|
||||||
relocate("com.github.steveice10.packetlib")
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
remapJar {
|
remapJar {
|
||||||
|
@ -178,7 +178,7 @@ public class GeyserSpigotInjector extends GeyserInjector {
|
|||||||
MinecraftProtocol protocol = new MinecraftProtocol();
|
MinecraftProtocol protocol = new MinecraftProtocol();
|
||||||
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
|
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
|
||||||
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
|
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
|
||||||
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper(), false);
|
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
|
||||||
session.connect();
|
session.connect();
|
||||||
session.disconnect("");
|
session.disconnect("");
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import io.netty.buffer.ByteBufAllocator;
|
|||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import io.netty.channel.unix.PreferredDirectByteBufAllocator;
|
import io.netty.channel.unix.PreferredDirectByteBufAllocator;
|
||||||
import io.netty.handler.codec.haproxy.*;
|
import io.netty.handler.codec.haproxy.*;
|
||||||
|
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.mcprotocollib.network.BuiltinFlags;
|
import org.geysermc.mcprotocollib.network.BuiltinFlags;
|
||||||
import org.geysermc.mcprotocollib.network.codec.PacketCodecHelper;
|
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.Inet4Address;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages a Minecraft Java session over our LocalChannel implementations.
|
* 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 String clientIp;
|
||||||
private final PacketCodecHelper codecHelper;
|
private final PacketCodecHelper codecHelper;
|
||||||
|
|
||||||
private final boolean transferring;
|
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, MinecraftCodecHelper codecHelper) {
|
||||||
|
|
||||||
public LocalSession(String host, int port, SocketAddress targetAddress, String clientIp, PacketProtocol protocol, MinecraftCodecHelper codecHelper, boolean transferring) {
|
|
||||||
super(host, port, protocol);
|
super(host, port, protocol);
|
||||||
this.targetAddress = targetAddress;
|
this.targetAddress = targetAddress;
|
||||||
this.clientIp = clientIp;
|
this.clientIp = clientIp;
|
||||||
this.codecHelper = codecHelper;
|
this.codecHelper = codecHelper;
|
||||||
this.transferring = transferring;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(boolean wait) {
|
public void connect(boolean wait, boolean transferring) {
|
||||||
if (this.disconnected) {
|
if (this.disconnected) {
|
||||||
throw new IllegalStateException("Connection has already been disconnected.");
|
throw new IllegalStateException("Connection has already been disconnected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEFAULT_EVENT_LOOP_GROUP == null) {
|
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 {
|
try {
|
||||||
|
@ -880,7 +880,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
// We're going to connect through the JVM and not through TCP
|
// We're going to connect through the JVM and not through TCP
|
||||||
downstream = new LocalSession(this.remoteServer.address(), this.remoteServer.port(),
|
downstream = new LocalSession(this.remoteServer.address(), this.remoteServer.port(),
|
||||||
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
|
geyser.getBootstrap().getSocketAddress(), upstream.getAddress().getAddress().getHostAddress(),
|
||||||
this.protocol, this.protocol.createHelper(), loginEvent.transferring());
|
this.protocol, this.protocol.createHelper());
|
||||||
this.downstream = new DownstreamSession(downstream);
|
this.downstream = new DownstreamSession(downstream);
|
||||||
} else {
|
} else {
|
||||||
downstream = new TcpClientSession(this.remoteServer.address(), this.remoteServer.port(), this.protocol);
|
downstream = new TcpClientSession(this.remoteServer.address(), this.remoteServer.port(), this.protocol);
|
||||||
@ -1070,7 +1070,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
setDaylightCycle(true);
|
setDaylightCycle(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
downstream.connect(false);
|
downstream.connect(false, loginEvent.transferring());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren