mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Fix: Reading of custom payloads (#128)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.geysermc.floodgate.pluginmessage.payloads;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
@@ -11,15 +12,16 @@ public record FormPayload(byte[] data) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<FormPayload> TYPE = new Type<>(ResourceLocation.parse("floodgate:form"));
|
||||
|
||||
private FormPayload(FriendlyByteBuf friendlyByteBuf) {
|
||||
this(friendlyByteBuf.readByteArray());
|
||||
this(ByteBufUtil.getBytes(friendlyByteBuf));
|
||||
friendlyByteBuf.readerIndex(friendlyByteBuf.readerIndex() + this.data.length);
|
||||
}
|
||||
|
||||
private void write(FriendlyByteBuf friendlyByteBuf) {
|
||||
friendlyByteBuf.writeByteArray(this.data);
|
||||
friendlyByteBuf.writeBytes(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload.@NonNull Type<FormPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.geysermc.floodgate.pluginmessage.payloads;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
@@ -11,15 +12,16 @@ public record PacketPayload(byte[] data) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<PacketPayload> TYPE = new Type<>(ResourceLocation.parse("floodgate:packet"));
|
||||
|
||||
private PacketPayload(FriendlyByteBuf friendlyByteBuf) {
|
||||
this(friendlyByteBuf.readByteArray());
|
||||
this(ByteBufUtil.getBytes(friendlyByteBuf));
|
||||
friendlyByteBuf.readerIndex(friendlyByteBuf.readerIndex() + this.data.length);
|
||||
}
|
||||
|
||||
private void write(FriendlyByteBuf friendlyByteBuf) {
|
||||
friendlyByteBuf.writeByteArray(this.data);
|
||||
friendlyByteBuf.writeBytes(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload.@NonNull Type<PacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.geysermc.floodgate.pluginmessage.payloads;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
@@ -11,15 +12,16 @@ public record SkinPayload(byte[] data) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<SkinPayload> TYPE = new Type<>(ResourceLocation.parse("floodgate:skin"));
|
||||
|
||||
private SkinPayload(FriendlyByteBuf friendlyByteBuf) {
|
||||
this(friendlyByteBuf.readByteArray());
|
||||
this(ByteBufUtil.getBytes(friendlyByteBuf));
|
||||
friendlyByteBuf.readerIndex(friendlyByteBuf.readerIndex() + this.data.length);
|
||||
}
|
||||
|
||||
private void write(FriendlyByteBuf friendlyByteBuf) {
|
||||
friendlyByteBuf.writeByteArray(this.data);
|
||||
friendlyByteBuf.writeBytes(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload.@NonNull Type<SkinPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.geysermc.floodgate.pluginmessage.payloads;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
@@ -11,15 +12,16 @@ public record TransferPayload(byte[] data) implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<TransferPayload> TYPE = new Type<>(ResourceLocation.parse("floodgate:transfer"));
|
||||
|
||||
private TransferPayload(FriendlyByteBuf friendlyByteBuf) {
|
||||
this(friendlyByteBuf.readByteArray());
|
||||
this(ByteBufUtil.getBytes(friendlyByteBuf));
|
||||
friendlyByteBuf.readerIndex(friendlyByteBuf.readerIndex() + this.data.length);
|
||||
}
|
||||
|
||||
private void write(FriendlyByteBuf friendlyByteBuf) {
|
||||
friendlyByteBuf.writeByteArray(this.data);
|
||||
friendlyByteBuf.writeBytes(this.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload.@NonNull Type<TransferPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user