Updated Via API usage

This commit is contained in:
RaphiMC 2024-01-05 16:15:30 +01:00
parent 176b6de7c8
commit 162894fd76
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
2 changed files with 8 additions and 8 deletions

View File

@ -97,7 +97,7 @@ public class Protocol1_7_6_10to1_7_2_5 extends AbstractProtocol<ClientboundPacke
final GameProfileFetcher gameProfileFetcher = Via.getManager().getProviders().get(GameProfileFetcher.class);
final String skullName = extraType == null ? "" : extraType.getValue();
final CompoundTag newTag = tag.clone();
final CompoundTag newTag = tag.copy();
if (gameProfileFetcher.isUUIDLoaded(skullName)) { // short cut if skull is already loaded
final UUID uuid = gameProfileFetcher.getMojangUUID(skullName);

View File

@ -18,15 +18,15 @@
package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.opennbt.NBTIO;
import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.io.NBTIO;
import com.viaversion.viaversion.libs.opennbt.tag.limiter.TagLimiter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -45,12 +45,12 @@ public class NBTType extends Type<CompoundTag> {
final ByteBuf data = buffer.readSlice(length);
try (InputStream in = new GZIPInputStream(new ByteBufInputStream(data))) {
return NBTIO.readTag(in);
return NBTIO.readTag(new DataInputStream(in), TagLimiter.create(NamedCompoundTagType.MAX_NBT_BYTES, NamedCompoundTagType.MAX_NESTING_LEVEL), true, CompoundTag.class);
}
}
@Override
public void write(ByteBuf buffer, CompoundTag nbt) throws Exception {
public void write(ByteBuf buffer, CompoundTag nbt) throws IOException {
if (nbt == null) {
buffer.writeShort(-1);
return;
@ -59,7 +59,7 @@ public class NBTType extends Type<CompoundTag> {
final ByteBuf data = buffer.alloc().buffer();
try {
try (OutputStream out = new GZIPOutputStream(new ByteBufOutputStream(data))) {
NBTIO.writeTag(out, nbt);
NBTIO.writeTag(new DataOutputStream(out), nbt, true);
}
buffer.writeShort(data.readableBytes());