Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-24 23:30:26 +01:00
Add support for Plugin Message packet, full implementation later.
Dieser Commit ist enthalten in:
Ursprung
48fafc73be
Commit
153f09ae70
@ -35,6 +35,10 @@ public enum StateRegistry {
|
||||
map(0x02, MINECRAFT_1_11),
|
||||
map(0x03, MINECRAFT_1_12),
|
||||
map(0x02, MINECRAFT_1_12_2));
|
||||
SERVERBOUND.register(PluginMessage.class, PluginMessage::new,
|
||||
map(0x0A, MINECRAFT_1_11),
|
||||
map(0x0A, MINECRAFT_1_12),
|
||||
map(0x09, MINECRAFT_1_12_1));
|
||||
SERVERBOUND.register(KeepAlive.class, KeepAlive::new,
|
||||
map(0x0B, MINECRAFT_1_11),
|
||||
map(0x0C, MINECRAFT_1_12),
|
||||
@ -48,6 +52,8 @@ public enum StateRegistry {
|
||||
map(0x0C, MINECRAFT_1_11));
|
||||
CLIENTBOUND.register(Chat.class, Chat::new,
|
||||
map(0x0F, MINECRAFT_1_11));
|
||||
CLIENTBOUND.register(PluginMessage.class, PluginMessage::new,
|
||||
map(0x18, MINECRAFT_1_11));
|
||||
CLIENTBOUND.register(Disconnect.class, Disconnect::new,
|
||||
map(0x1A, MINECRAFT_1_11));
|
||||
CLIENTBOUND.register(KeepAlive.class, KeepAlive::new,
|
||||
|
@ -14,6 +14,7 @@ public class MinecraftVarintLengthEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
|
||||
out.ensureWritable(msg.readableBytes() + 5);
|
||||
ProtocolUtils.writeVarInt(out, msg.readableBytes());
|
||||
out.writeBytes(msg);
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.velocitypowered.proxy.protocol.packets;
|
||||
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolConstants;
|
||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class PluginMessage implements MinecraftPacket {
|
||||
private String channel;
|
||||
private byte[] data;
|
||||
|
||||
@Override
|
||||
public void decode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
this.channel = ProtocolUtils.readString(buf, 20);
|
||||
this.data = new byte[buf.readableBytes()];
|
||||
buf.readBytes(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) {
|
||||
ProtocolUtils.writeString(buf, channel);
|
||||
buf.writeBytes(data);
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren