Added a simple way to identify Geyser players.

Keep in mind that using this to identify players is less secure than using Floodgate
This commit is contained in:
Tim203 2020-01-07 22:29:49 +01:00
parent a4ad4a96bb
commit c5205cc873
2 changed files with 19 additions and 0 deletions

View file

@ -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());

View file

@ -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<ServerPluginMessagePacket> {
@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())
);
}
}
}