From 295d8d5256473fc33701c3f63b0e4de738e58d37 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Thu, 8 Aug 2019 18:16:46 -0500 Subject: [PATCH] Fix double disconnect bug and minor code cleanups --- .../network/session/GeyserSession.java | 3 +-- .../network/translators/TranslatorsInit.java | 5 ++--- .../translators/item/ItemTranslator.java | 2 -- ...avaChunk.java => JavaChunkDataPacket.java} | 21 ++++++++----------- pom.xml | 1 - 5 files changed, 12 insertions(+), 20 deletions(-) rename connector/src/main/java/org/geysermc/connector/network/translators/java/world/{JavaChunk.java => JavaChunkDataPacket.java} (52%) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 011ad0ad..913b67ce 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -158,8 +158,7 @@ public class GeyserSession implements PlayerSession, Player { public void disconnected(DisconnectedEvent event) { loggedIn = false; connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason()); - event.getCause().printStackTrace(); - disconnect(event.getReason()); + // upstream.disconnect(event.getReason()); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index d1370c9d..1d24ee2e 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -95,14 +95,13 @@ import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnPla import org.geysermc.connector.network.translators.java.scoreboard.JavaDisplayScoreboardTranslator; import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardObjectiveTranslator; import org.geysermc.connector.network.translators.java.scoreboard.JavaUpdateScoreTranslator; -import org.geysermc.connector.network.translators.java.world.JavaChunk; +import org.geysermc.connector.network.translators.java.world.JavaChunkDataPacket; import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator; import org.geysermc.connector.network.translators.java.window.JavaOpenWindowTranslator; import org.geysermc.connector.network.translators.java.window.JavaSetSlotTranslator; import org.geysermc.connector.network.translators.java.JavaTitleTranslator; import org.geysermc.connector.network.translators.java.world.JavaUpdateTimeTranslator; import org.geysermc.connector.network.translators.java.window.JavaWindowItemsTranslator; -import org.geysermc.connector.utils.Chunks; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -161,7 +160,7 @@ public class TranslatorsInit { Registry.registerJava(ServerPlayerHealthPacket.class, new JavaPlayerHealthTranslator()); Registry.registerJava(ServerNotifyClientPacket.class, new JavaNotifyClientTranslator()); - Registry.registerJava(ServerChunkDataPacket.class, new JavaChunk()); + Registry.registerJava(ServerChunkDataPacket.class, new JavaChunkDataPacket()); Registry.registerJava(ServerEntityDestroyPacket.class, new JavaEntityDestroyTranslator()); Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator()); Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java index 702b6c9e..dfc01970 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java @@ -78,7 +78,6 @@ public class ItemTranslator { public static BedrockItem getBedrockItem(ItemStack stack) { Map m = Remapper.JAVA_TO_BEDROCK.get(stack.getId()); - System.out.println(stack.getId()); return new BedrockItem((String) m.get("name"), (Integer) m.get("id"), (Integer) m.get("data")); } @@ -89,7 +88,6 @@ public class ItemTranslator { public static BedrockItem getBedrockBlock(BlockState stack) { Map m = Remapper.JAVA_TO_BEDROCK_BLOCKS.get(stack.getId()); - System.out.println(stack.getId()); return new BedrockItem((String) m.get("name"), (Integer) m.get("id"), (Integer) m.get("data")); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunk.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataPacket.java similarity index 52% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunk.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataPacket.java index e368cde4..98e2b056 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunk.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataPacket.java @@ -3,26 +3,23 @@ package org.geysermc.connector.network.translators.java.world; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket; import com.github.steveice10.packetlib.packet.Packet; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; +import org.geysermc.connector.console.GeyserLogger; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.utils.Chunks; -public class JavaChunk extends PacketTranslator { +public class JavaChunkDataPacket extends PacketTranslator { @Override public void translate(ServerChunkDataPacket packet, GeyserSession session) { - LevelChunkPacket p = new LevelChunkPacket(); + LevelChunkPacket levelChunkPacket = new LevelChunkPacket(); Chunks.ChunkData data = Chunks.getData(packet.getColumn()); + levelChunkPacket.setSubChunksLength(data.count); + levelChunkPacket.setData(data.bytes); + levelChunkPacket.setChunkX(packet.getColumn().getX()); + levelChunkPacket.setChunkZ(packet.getColumn().getZ()); - p.setSubChunksLength(data.count); - - p.setData(data.bytes); - - p.setChunkX(packet.getColumn().getX()); - p.setChunkZ(packet.getColumn().getZ()); - - System.out.println("sent"); - - session.getUpstream().sendPacketImmediately(p); + GeyserLogger.DEFAULT.info("Sent chunk packet!"); + session.getUpstream().sendPacket(levelChunkPacket); } } diff --git a/pom.xml b/pom.xml index 973d270f..280df1a7 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,6 @@ attach-javadocs - aggregate jar