Fix double disconnect bug and minor code cleanups

This commit is contained in:
RednedEpic 2019-08-08 18:16:46 -05:00
parent de78c93b72
commit 295d8d5256
5 changed files with 12 additions and 20 deletions

View file

@ -158,8 +158,7 @@ public class GeyserSession implements PlayerSession, Player {
public void disconnected(DisconnectedEvent event) { public void disconnected(DisconnectedEvent event) {
loggedIn = false; loggedIn = false;
connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason()); connector.getLogger().info(authenticationData.getName() + " has disconnected from remote java server on address " + remoteServer.getAddress() + " because of " + event.getReason());
event.getCause().printStackTrace(); // upstream.disconnect(event.getReason());
disconnect(event.getReason());
} }
@Override @Override

View file

@ -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.JavaDisplayScoreboardTranslator;
import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardObjectiveTranslator; 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.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.world.JavaNotifyClientTranslator;
import org.geysermc.connector.network.translators.java.window.JavaOpenWindowTranslator; 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.window.JavaSetSlotTranslator;
import org.geysermc.connector.network.translators.java.JavaTitleTranslator; import org.geysermc.connector.network.translators.java.JavaTitleTranslator;
import org.geysermc.connector.network.translators.java.world.JavaUpdateTimeTranslator; import org.geysermc.connector.network.translators.java.world.JavaUpdateTimeTranslator;
import org.geysermc.connector.network.translators.java.window.JavaWindowItemsTranslator; import org.geysermc.connector.network.translators.java.window.JavaWindowItemsTranslator;
import org.geysermc.connector.utils.Chunks;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -161,7 +160,7 @@ public class TranslatorsInit {
Registry.registerJava(ServerPlayerHealthPacket.class, new JavaPlayerHealthTranslator()); Registry.registerJava(ServerPlayerHealthPacket.class, new JavaPlayerHealthTranslator());
Registry.registerJava(ServerNotifyClientPacket.class, new JavaNotifyClientTranslator()); 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(ServerEntityDestroyPacket.class, new JavaEntityDestroyTranslator());
Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator()); Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator());
Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator()); Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator());

View file

@ -78,7 +78,6 @@ public class ItemTranslator {
public static BedrockItem getBedrockItem(ItemStack stack) { public static BedrockItem getBedrockItem(ItemStack stack) {
Map<String, Object> m = Remapper.JAVA_TO_BEDROCK.get(stack.getId()); Map<String, Object> 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")); 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) { public static BedrockItem getBedrockBlock(BlockState stack) {
Map<String, Object> m = Remapper.JAVA_TO_BEDROCK_BLOCKS.get(stack.getId()); Map<String, Object> 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")); return new BedrockItem((String) m.get("name"), (Integer) m.get("id"), (Integer) m.get("data"));
} }

View file

@ -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.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; 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.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.utils.Chunks; import org.geysermc.connector.utils.Chunks;
public class JavaChunk extends PacketTranslator<ServerChunkDataPacket> { public class JavaChunkDataPacket extends PacketTranslator<ServerChunkDataPacket> {
@Override @Override
public void translate(ServerChunkDataPacket packet, GeyserSession session) { public void translate(ServerChunkDataPacket packet, GeyserSession session) {
LevelChunkPacket p = new LevelChunkPacket(); LevelChunkPacket levelChunkPacket = new LevelChunkPacket();
Chunks.ChunkData data = Chunks.getData(packet.getColumn()); 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); GeyserLogger.DEFAULT.info("Sent chunk packet!");
session.getUpstream().sendPacket(levelChunkPacket);
p.setData(data.bytes);
p.setChunkX(packet.getColumn().getX());
p.setChunkZ(packet.getColumn().getZ());
System.out.println("sent");
session.getUpstream().sendPacketImmediately(p);
} }
} }

View file

@ -134,7 +134,6 @@
<execution> <execution>
<id>attach-javadocs</id> <id>attach-javadocs</id>
<goals> <goals>
<goal>aggregate</goal>
<goal>jar</goal> <goal>jar</goal>
</goals> </goals>
</execution> </execution>