Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
Implemented Floodgate's 'packet' plugin message
Dieser Commit ist enthalten in:
Ursprung
90442a8922
Commit
a4399f0c1e
@ -25,19 +25,22 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.translator.protocol.java;
|
package org.geysermc.geyser.translator.protocol.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import com.nukkitx.protocol.bedrock.packet.UnknownPacket;
|
||||||
import org.geysermc.geyser.GeyserLogger;
|
import io.netty.buffer.ByteBuf;
|
||||||
import org.geysermc.geyser.session.auth.AuthType;
|
import io.netty.buffer.Unpooled;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
|
||||||
import org.geysermc.cumulus.Form;
|
import org.geysermc.cumulus.Form;
|
||||||
import org.geysermc.cumulus.Forms;
|
import org.geysermc.cumulus.Forms;
|
||||||
import org.geysermc.cumulus.util.FormType;
|
import org.geysermc.cumulus.util.FormType;
|
||||||
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
|
import org.geysermc.geyser.GeyserLogger;
|
||||||
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.session.auth.AuthType;
|
||||||
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
|
import org.geysermc.geyser.translator.protocol.Translator;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
@ -62,8 +65,7 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
|||||||
|
|
||||||
FormType type = FormType.getByOrdinal(data[0]);
|
FormType type = FormType.getByOrdinal(data[0]);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException("Got type " + data[0] + " which isn't a valid form type!");
|
||||||
"Got type " + data[0] + " which isn't a valid form type!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
String dataString = new String(data, 3, data.length - 3, Charsets.UTF_8);
|
||||||
@ -84,8 +86,7 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
|||||||
} else if (channel.equals("floodgate:transfer")) {
|
} else if (channel.equals("floodgate:transfer")) {
|
||||||
byte[] data = packet.getData();
|
byte[] data = packet.getData();
|
||||||
|
|
||||||
// port, 4 bytes. remaining data, address.
|
// port (4 bytes), address (remaining data)
|
||||||
|
|
||||||
if (data.length < 5) {
|
if (data.length < 5) {
|
||||||
throw new NullPointerException("Transfer data should be at least 5 bytes long");
|
throw new NullPointerException("Transfer data should be at least 5 bytes long");
|
||||||
}
|
}
|
||||||
@ -101,6 +102,24 @@ public class JavaCustomPayloadTranslator extends PacketTranslator<ClientboundCus
|
|||||||
transferPacket.setAddress(address);
|
transferPacket.setAddress(address);
|
||||||
transferPacket.setPort(port);
|
transferPacket.setPort(port);
|
||||||
session.sendUpstreamPacket(transferPacket);
|
session.sendUpstreamPacket(transferPacket);
|
||||||
|
|
||||||
|
} else if (channel.equals("floodgate:packet")) {
|
||||||
|
logger.debug("A packet has been sent using the Floodgate api");
|
||||||
|
byte[] data = packet.getData();
|
||||||
|
|
||||||
|
// packet id, packet data
|
||||||
|
if (data.length < 2) {
|
||||||
|
throw new IllegalStateException("Packet data should be at least 2 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
int packetId = data[0];
|
||||||
|
ByteBuf packetData = Unpooled.wrappedBuffer(data, 1, data.length - 1);
|
||||||
|
|
||||||
|
var toSend = new UnknownPacket();
|
||||||
|
toSend.setPacketId(packetId);
|
||||||
|
toSend.setPayload(packetData);
|
||||||
|
|
||||||
|
session.sendUpstreamPacket(toSend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class PluginMessageUtils {
|
|||||||
.put(data)
|
.put(data)
|
||||||
.array();
|
.array();
|
||||||
|
|
||||||
FLOODGATE_REGISTER_DATA = (SKIN_CHANNEL + "\0floodgate:form").getBytes(Charsets.UTF_8);
|
FLOODGATE_REGISTER_DATA = (SKIN_CHANNEL + "\0floodgate:form\0floodgate:transfer\0floodgate:packet").getBytes(Charsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren