From f30410630291aa3a893b25e8783b0c710b7bd88d Mon Sep 17 00:00:00 2001 From: bundabrg Date: Wed, 23 Sep 2020 11:17:19 +0800 Subject: [PATCH] Fix not disconnecting Closes #14 --- .../reversion/server/GeyserBedrockServer.java | 39 ++++++++ .../reversion/server/GeyserServerSession.java | 93 ++++++++++++++++++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserBedrockServer.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserBedrockServer.java index 116814d..3a027f0 100644 --- a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserBedrockServer.java +++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserBedrockServer.java @@ -25,9 +25,13 @@ package au.com.grieve.geyser.reversion.server; import au.com.grieve.reversion.api.ReversionServer; +import com.nukkitx.network.raknet.RakNetServer; import com.nukkitx.protocol.bedrock.BedrockServer; +import com.nukkitx.protocol.bedrock.BedrockServerEventHandler; +import io.netty.bootstrap.Bootstrap; import lombok.Getter; +import java.net.InetSocketAddress; import java.util.HashSet; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -64,4 +68,39 @@ public void registerServer(ReversionServer server, boolean isDefault) { public CompletableFuture bind() { return defaultServer.bind(); } + + @Override + public BedrockServerEventHandler getHandler() { + return original.getHandler(); + } + + @Override + public void setHandler(BedrockServerEventHandler handler) { + original.setHandler(handler); + } + + @Override + public RakNetServer getRakNet() { + return original.getRakNet(); + } + + @Override + public void close(String reason) { + original.close(reason); + } + + @Override + public boolean isClosed() { + return super.isClosed(); + } + + @Override + public InetSocketAddress getBindAddress() { + return original.getBindAddress(); + } + + @Override + public Bootstrap getBootstrap() { + return original.getBootstrap(); + } } diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserServerSession.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserServerSession.java index 6786fb8..af326d3 100644 --- a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserServerSession.java +++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/server/GeyserServerSession.java @@ -25,14 +25,20 @@ package au.com.grieve.geyser.reversion.server; import au.com.grieve.reversion.editions.bedrock.BedrockReversionSession; +import com.nukkitx.network.util.DisconnectReason; import com.nukkitx.protocol.bedrock.BedrockPacket; import com.nukkitx.protocol.bedrock.BedrockServerSession; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import org.geysermc.connector.network.BedrockProtocol; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import javax.crypto.SecretKey; +import java.net.InetSocketAddress; +import java.util.Collection; +import java.util.function.Consumer; @ParametersAreNonnullByDefault public class GeyserServerSession extends BedrockServerSession { @@ -74,8 +80,93 @@ public boolean isClosed() { return reversionSession.isClosed(); } +// @Override +// public void setPacketHandler(@Nonnull BedrockPacketHandler packetHandler) { +// throw new UnsupportedOperationException(); +// } + +// @Override +// public void setPacketCodec(BedrockPacketCodec packetCodec) { +// throw new UnsupportedOperationException(); +// } + + @Override + public void sendWrapped(Collection packets, boolean encrypt) { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized void sendWrapped(ByteBuf compressed, boolean encrypt) { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized void enableEncryption(@Nonnull SecretKey secretKey) { + reversionSession.enableEncryption(secretKey); + } + + @Override + public boolean isEncrypted() { + return reversionSession.isEncrypted(); + } + + @Override + public InetSocketAddress getAddress() { + return reversionSession.getAddress(); + } + +// @Override +// public BedrockPacketCodec getPacketCodec() { +// throw new UnsupportedOperationException(); +// } + +// @Override +// public BedrockPacketHandler getPacketHandler() { +// throw new UnsupportedOperationException(); +// } + +// @Override +// public BatchHandler getBatchHandler() { +// throw new UnsupportedOperationException(); +// } + +// @Override +// public void setBatchHandler(BatchHandler batchHandler) { +// throw new UnsupportedOperationException(); +// } + + @Override + public int getCompressionLevel() { + return reversionSession.getCompressionLevel(); + } + + @Override + public void setCompressionLevel(int compressionLevel) { + reversionSession.setCompressionLevel(compressionLevel); + } + + @Override + public boolean isLogging() { + return reversionSession.isLogging(); + } + + @Override + public void setLogging(boolean logging) { + reversionSession.setLogging(logging); + } + + @Override + public void addDisconnectHandler(Consumer disconnectHandler) { + reversionSession.addDisconnectHandler(disconnectHandler); + } + + @Override + public long getLatency() { + return reversionSession.getLatency(); + } + @Override public void disconnect(@Nullable String reason, boolean hideReason) { - super.disconnect(reason, hideReason); + reversionSession.disconnect(reason, hideReason); } }