Fix 1.20.4 reflection wrappers
This commit is contained in:
parent
7d89f0c376
commit
649e1a56c8
@ -196,7 +196,7 @@ public interface PaperOffPlayer extends AbstractOffPlayer {
|
|||||||
File old = getPlayerDataFile(true);
|
File old = getPlayerDataFile(true);
|
||||||
old.delete();
|
old.delete();
|
||||||
Files.move(file.toPath(), old.toPath());
|
Files.move(file.toPath(), old.toPath());
|
||||||
NbtIo.writeCompressed(data.data, file);
|
NbtIo.writeCompressed(data.data, file.toPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,7 @@ import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.Vec3i;
|
|||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CollectionTag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CollectionTag;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.ListTag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.ListTag;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.NbtAccounter;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.NbtIo;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.NbtIo;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.StringTag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.StringTag;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
|
||||||
@ -141,6 +142,7 @@ public class PandalibPaperReflect {
|
|||||||
thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.MAPPING.runtimeClass()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.MAPPING.runtimeClass()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ListTag.class, ListTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ListTag.class, ListTag.MAPPING.runtimeClass()));
|
||||||
|
thAcc.catchThrowable(() -> initWrapper(NbtAccounter.class, NbtAccounter.MAPPING.runtimeClass()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(NbtIo.class, NbtIo.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(NbtIo.class, NbtIo.MAPPING.runtimeClass()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(StringTag.class, StringTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(StringTag.class, StringTag.MAPPING.runtimeClass()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.MAPPING.runtimeClass()));
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
|
public class NbtAccounter extends ReflectWrapper {
|
||||||
|
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtAccounter"));
|
||||||
|
private static final ReflectMethod<?> unlimitedHeap = wrapEx(() -> MAPPING.mojMethod("unlimitedHeap"));
|
||||||
|
|
||||||
|
private NbtAccounter(Object obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static NbtAccounter unlimitedHeap() {
|
||||||
|
return wrap(wrapEx(() -> unlimitedHeap.invokeStatic()), NbtAccounter.class);
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
|
||||||
|
|
||||||
public class NbtIo extends ReflectWrapper {
|
public class NbtIo extends ReflectWrapper {
|
||||||
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo"));
|
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo"));
|
||||||
private static final ReflectMethod<?> readCompressed = wrapEx(() -> MAPPING.mojMethod("readCompressed", File.class));
|
private static final ReflectMethod<?> readCompressed = wrapEx(() -> MAPPING.mojMethod("readCompressed", Path.class, NbtAccounter.MAPPING));
|
||||||
private static final ReflectMethod<?> writeCompressed = wrapEx(() -> MAPPING.mojMethod("writeCompressed", CompoundTag.MAPPING, File.class));
|
private static final ReflectMethod<?> writeCompressed = wrapEx(() -> MAPPING.mojMethod("writeCompressed", CompoundTag.MAPPING, Path.class));
|
||||||
|
|
||||||
private NbtIo(Object obj) {
|
private NbtIo(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
@ -20,12 +20,11 @@ public class NbtIo extends ReflectWrapper {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static CompoundTag readCompressed(File f) {
|
public static CompoundTag readCompressed(Path p, NbtAccounter accounter) {
|
||||||
return wrap(wrapEx(() -> readCompressed.invokeStatic(f)), CompoundTag.class);
|
return wrap(wrapEx(() -> readCompressed.invokeStatic(p, unwrap(accounter))), CompoundTag.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeCompressed(CompoundTag tag, File f) {
|
public static void writeCompressed(CompoundTag tag, Path p) {
|
||||||
Object nmsTag = ReflectWrapper.unwrap(tag);
|
wrapEx(() -> writeCompressed.invokeStatic(unwrap(tag), p));
|
||||||
wrapEx(() -> writeCompressed.invokeStatic(nmsTag, f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user