From c5205cc87316e5f01505c0236f7bca0eb2017c61 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Tue, 7 Jan 2020 22:29:49 +0100 Subject: [PATCH] Added a simple way to identify Geyser players. Keep in mind that using this to identify players is less secure than using Floodgate --- .../network/translators/TranslatorsInit.java | 1 + .../java/JavaPluginMessageTranslator.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java 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 bd7d7dae0..7cb620bf8 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,6 +95,7 @@ public class TranslatorsInit { public static void start() { Registry.registerJava(ServerJoinGamePacket.class, new JavaJoinGameTranslator()); + Registry.registerJava(ServerPluginMessagePacket.class, new JavaPluginMessageTranslator()); Registry.registerJava(ServerChatPacket.class, new JavaChatTranslator()); Registry.registerJava(ServerTitlePacket.class, new JavaTitleTranslator()); Registry.registerJava(ServerUpdateTimePacket.class, new JavaUpdateTimeTranslator()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java new file mode 100644 index 000000000..6aac66330 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java @@ -0,0 +1,18 @@ +package org.geysermc.connector.network.translators.java; + +import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket; +import org.geysermc.connector.GeyserConnector; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.PacketTranslator; + +public class JavaPluginMessageTranslator extends PacketTranslator { + @Override + public void translate(ServerPluginMessagePacket packet, GeyserSession session) { + if (packet.getChannel().equals("minecraft:brand")) { + session.getDownstream().getSession().send( + new ClientPluginMessagePacket(packet.getChannel(), GeyserConnector.NAME.getBytes()) + ); + } + } +}