Create PLUGIN_MESSAGE packets without input buffers

This commit is contained in:
RaphiMC 2023-10-08 10:49:13 +02:00
parent 3f57c28d65
commit d7e33fa011
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
2 changed files with 2 additions and 4 deletions

View File

@ -27,7 +27,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.CustomByteType;
import io.netty.buffer.Unpooled;
import net.raphimc.vialegacy.ViaLegacy;
import net.raphimc.vialegacy.api.data.BlockList1_6;
import net.raphimc.vialegacy.api.model.ChunkCoord;
@ -75,7 +74,7 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
handler(wrapper -> {
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocol1_6_2to1_6_1.class)) {
final ExtensionProtocolMetadataStorage protocolMetadataStorage = wrapper.user().get(ExtensionProtocolMetadataStorage.class);
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.PLUGIN_MESSAGE, Unpooled.buffer(), wrapper.user());
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.PLUGIN_MESSAGE, wrapper.user());
brand.write(Types1_6_4.STRING, "MC|Brand");
final byte[] brandBytes = protocolMetadataStorage.getServerSoftwareName().getBytes(StandardCharsets.UTF_8);
brand.write(Type.SHORT, (short) brandBytes.length); // data length

View File

@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.Unpooled;
import net.raphimc.vialegacy.api.data.ItemList1_6;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
@ -47,7 +46,7 @@ public class Protocol1_6_2to1_6_1 extends StatelessProtocol<ClientboundPackets1_
@Override
public void register() {
handler(wrapper -> {
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.PLUGIN_MESSAGE, Unpooled.buffer(), wrapper.user());
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.PLUGIN_MESSAGE, wrapper.user());
brand.write(Types1_6_4.STRING, "MC|Brand");
final byte[] brandBytes = "legacy".getBytes(StandardCharsets.UTF_8);
brand.write(Type.SHORT, (short) brandBytes.length); // data length