mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Separate the packet id from the rest of the packet data
This commit is contained in:
@@ -29,6 +29,23 @@ import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public interface Unsafe {
|
||||
void sendPacket(UUID bedrockPlayer, byte[] packetData);
|
||||
void sendPacket(FloodgatePlayer player, byte[] packetData);
|
||||
/**
|
||||
* Send a raw Bedrock packet to the given online Bedrock player.
|
||||
*
|
||||
* @param bedrockPlayer the uuid of the online Bedrock player
|
||||
* @param packetId the id of the packet to send
|
||||
* @param packetData the raw packet data
|
||||
*/
|
||||
void sendPacket(UUID bedrockPlayer, int packetId, byte[] packetData);
|
||||
|
||||
/**
|
||||
* Send a raw Bedrock packet to the given online Bedrock player.
|
||||
*
|
||||
* @param player the Bedrock player to send the packet to
|
||||
* @param packetId the id of the packet to send
|
||||
* @param packetData the raw packet data
|
||||
*/
|
||||
default void sendPacket(FloodgatePlayer player, int packetId, byte[] packetData) {
|
||||
sendPacket(player.getCorrectUniqueId(), packetId, packetData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
package org.geysermc.floodgate.api;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.api.unsafe.Unsafe;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageManager;
|
||||
import org.geysermc.floodgate.pluginmessage.channel.PacketChannel;
|
||||
@@ -44,12 +43,11 @@ public final class UnsafeFloodgateApi implements Unsafe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(UUID bedrockPlayer, byte[] packetData) {
|
||||
packetChannel.sendPacket(bedrockPlayer, packetData, this);
|
||||
}
|
||||
public void sendPacket(UUID bedrockPlayer, int packetId, byte[] packetData) {
|
||||
byte[] fullData = new byte[packetData.length + 1];
|
||||
fullData[0] = (byte) packetId;
|
||||
System.arraycopy(packetData, 0, fullData, 1, packetData.length);
|
||||
|
||||
@Override
|
||||
public void sendPacket(FloodgatePlayer player, byte[] packetData) {
|
||||
sendPacket(player.getCorrectUniqueId(), packetData);
|
||||
packetChannel.sendPacket(bedrockPlayer, fullData, this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user