From ebd1e502f2dcfa9483c151721e966a083aa5b964 Mon Sep 17 00:00:00 2001 From: Logicism Date: Sat, 3 Aug 2019 18:01:16 -0700 Subject: [PATCH 1/2] Add Gamemode Change and Titles Times Translator w/ Scoreboard Registry --- .../network/translators/TranslatorsInit.java | 9 +++++++++ .../translators/java/JavaJoinGameTranslator.java | 13 +++++++++++++ .../translators/java/JavaTitleTranslator.java | 9 +++++---- .../java/world/JavaNotifyClientTranslator.java | 14 ++++++++++++++ .../network/translators/scoreboard/Scoreboard.java | 2 +- 5 files changed, 42 insertions(+), 5 deletions(-) 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 4357f9f65..0144bfe92 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 @@ -35,6 +35,9 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket; @@ -62,6 +65,9 @@ import org.geysermc.connector.network.translators.java.entity.JavaEntityPosition import org.geysermc.connector.network.translators.java.entity.JavaEntityTeleportTranslator; import org.geysermc.connector.network.translators.java.entity.JavaEntityVelocityTranslator; import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnExpOrbTranslator; +import org.geysermc.connector.network.translators.java.scoreboard.JavaScoreboardDisplayTranslator; +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.JavaNotifyClientTranslator; import org.geysermc.connector.network.translators.java.window.JavaOpenWindowTranslator; import org.geysermc.connector.network.translators.java.window.JavaSetSlotTranslator; @@ -114,6 +120,9 @@ public class TranslatorsInit { Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator()); Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator()); Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator()); + Registry.registerJava(ServerScoreboardObjectivePacket.class, new JavaScoreboardObjectiveTranslator()); + Registry.registerJava(ServerDisplayScoreboardPacket.class, new JavaScoreboardDisplayTranslator()); + Registry.registerJava(ServerUpdateScorePacket.class, new JavaUpdateScoreTranslator()); Registry.registerBedrock(AnimatePacket.class, new BedrockAnimateTranslator()); Registry.registerBedrock(CommandRequestPacket.class, new BedrockCommandRequestTranslator()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java index a43fd4a43..d44252233 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java @@ -26,9 +26,11 @@ package org.geysermc.connector.network.translators.java; import com.flowpowered.math.vector.Vector3f; +import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket; import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; +import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.TranslatorsInit; @@ -41,6 +43,17 @@ public class JavaJoinGameTranslator extends PacketTranslator> 4; int chunkZ = pos.getFloorZ() >> 4; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTitleTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTitleTranslator.java index c9239fe29..e3d9bbead 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTitleTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTitleTranslator.java @@ -54,12 +54,13 @@ public class JavaTitleTranslator extends PacketTranslator { titlePacket.setType(SetTitlePacket.Type.SET_ACTIONBAR_MESSAGE); titlePacket.setText(packet.getActionBar().getFullText()); break; + case TIMES: + titlePacket.setFadeInTime(packet.getFadeIn()); + titlePacket.setFadeOutTime(packet.getFadeOut()); + titlePacket.setStayTime(packet.getStay()); + break; } - titlePacket.setFadeInTime(packet.getFadeIn()); - titlePacket.setFadeOutTime(packet.getFadeOut()); - titlePacket.setStayTime(packet.getStay()); - session.getUpstream().sendPacket(titlePacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java index 65c25a1d3..8ef64503f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java @@ -26,8 +26,10 @@ package org.geysermc.connector.network.translators.java.world; import com.flowpowered.math.vector.Vector3f; +import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket; import com.nukkitx.protocol.bedrock.packet.LevelEventPacket; +import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; @@ -54,6 +56,18 @@ public class JavaNotifyClientTranslator extends PacketTranslator fakeMap = new HashMap(); From fc50242c47bf9cf3fe6bc458f229a4924dcaa889 Mon Sep 17 00:00:00 2001 From: Logicism Date: Sat, 3 Aug 2019 18:20:15 -0700 Subject: [PATCH 2/2] Fix Redudant Gamemode Code --- .../network/translators/java/JavaJoinGameTranslator.java | 9 +-------- .../java/world/JavaNotifyClientTranslator.java | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java index d44252233..7a5c47444 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java @@ -43,14 +43,7 @@ public class JavaJoinGameTranslator extends PacketTranslator