diff --git a/pandalib-paper/pom.xml b/pandalib-paper/pom.xml index d166f49..a70102e 100644 --- a/pandalib-paper/pom.xml +++ b/pandalib-paper/pom.xml @@ -89,14 +89,6 @@ paper-mojangapi ${paper.version}-SNAPSHOT - - - - net.fabricmc - mapping-io - 0.5.0 - provided - diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java index d425c8a..f88c3bf 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/commands/PaperBrigadierCommand.java @@ -366,7 +366,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand context, String argument, Vector deflt) { - return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(), + return tryGetArgument(context, argument, Coordinates.REFLECT.get(), nmsCoordinate -> CraftVector.toBukkit( ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getPosition(context.getSource()) ), diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java deleted file mode 100644 index 7bae2df..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java +++ /dev/null @@ -1,716 +0,0 @@ -package fr.pandacube.lib.paper.reflect; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.io.StringReader; -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.TreeMap; -import java.util.stream.Collectors; - -import org.bukkit.Bukkit; - -import fr.pandacube.lib.util.log.Log; -import fr.pandacube.lib.reflect.Reflect; -import fr.pandacube.lib.reflect.ReflectClass; -import fr.pandacube.lib.reflect.ReflectField; -import fr.pandacube.lib.reflect.ReflectMember; -import fr.pandacube.lib.reflect.ReflectMethod; -import net.fabricmc.mappingio.MappingReader; -import net.fabricmc.mappingio.format.MappingFormat; -import net.fabricmc.mappingio.tree.MappingTree; -import net.fabricmc.mappingio.tree.MemoryMappingTree; - -/** - * Provides reflection tools related to Minecraft servers internals. - * It automatically deals with the obfuscated classes and methods. - */ -public class NMSReflect { - - - private static String OBF_NAMESPACE; - private static String MOJ_NAMESPACE; - - /* package */ static final Map CLASSES_BY_OBF = new TreeMap<>(); - /* package */ static final Map CLASSES_BY_MOJ = new TreeMap<>(); - - private static Boolean IS_SERVER_OBFUSCATED; - - private static boolean isInit = false; - - /** - * Initialize all the obfuscation mapping data. - */ - public static void init() { - - synchronized (NMSReflect.class) { - if (isInit) - return; - isInit = true; - } - - Log.info("[NMSReflect] Initializing NMS obfuscation mapping..."); - - try { - ReflectClass obfHelperClass; - try { - obfHelperClass = Reflect.ofClass("io.papermc.paper.util.ObfHelper"); - - OBF_NAMESPACE = (String) obfHelperClass.field("SPIGOT_NAMESPACE").getStaticValue(); - MOJ_NAMESPACE = (String) obfHelperClass.field("MOJANG_PLUS_YARN_NAMESPACE").getStaticValue(); - } catch (ReflectiveOperationException e) { - throw new ReflectiveOperationException("Unable to find the Paper obfuscation mapping class or class members.", e); - } - - List mappings = loadMappings(obfHelperClass); - for (ClassMapping clazz : mappings) { - CLASSES_BY_OBF.put(clazz.obfName, clazz); - CLASSES_BY_MOJ.put(clazz.mojName, clazz); - } - - // determine if the runtime server is obfuscated - ClassNotFoundException exIfUnableToDetermine = null; - for (ClassMapping clazz : CLASSES_BY_OBF.values()) { - if (clazz.obfName.equals(clazz.mojName) // avoid direct collision between obf and unobf class names - || CLASSES_BY_MOJ.containsKey(clazz.obfName) // avoid indirect collision - || CLASSES_BY_OBF.containsKey(clazz.mojName))// avoid indirect collision - continue; - - try { - Class.forName(clazz.obfName); - IS_SERVER_OBFUSCATED = true; - break; - } catch (ClassNotFoundException e) { - try { - Class.forName(clazz.mojName); - IS_SERVER_OBFUSCATED = false; - break; - } catch (ClassNotFoundException ee) { - ee.addSuppressed(e); - if (exIfUnableToDetermine == null) - exIfUnableToDetermine = ee; - } - } - } - - if (IS_SERVER_OBFUSCATED == null) { - throw new IllegalStateException("Unable to determine if this server is obfuscated or not", exIfUnableToDetermine); - } - if (IS_SERVER_OBFUSCATED) { - Log.info("[NMSReflect] NMS runtime classes are obfuscated."); - } - else { - Log.info("[NMSReflect] NMS runtime classes are mojang mapped."); - } - - int missingRuntimeClasses = 0; - for (ClassMapping clazz : mappings) { - try { - clazz.cacheReflectClass(); - } catch (Throwable e) { - missingRuntimeClasses++; - if (e instanceof ClassNotFoundException cnfe) { - Log.warning("[NMSReflect] Missing runtime class " + cnfe.getMessage() + (IS_SERVER_OBFUSCATED ? (" (moj class: " + clazz.mojName + ")") : "")); - } - else { - Log.warning("[NMSReflect] Unable to load runtime class " + (IS_SERVER_OBFUSCATED ? (clazz.obfName + " (moj class: " + clazz.mojName + ")") : clazz.mojName)); - Log.warning(e); // throwable on separate log message due to sometimes the message not showing at all because of this exception - } - CLASSES_BY_OBF.remove(clazz.obfName); - CLASSES_BY_MOJ.remove(clazz.mojName); - } - } - - if (missingRuntimeClasses > 0) { - Log.warning("[NMSReflect] " + missingRuntimeClasses + " class have been removed from the mapping data due to the previously stated errors."); - } - - } catch (Throwable t) { - CLASSES_BY_OBF.clear(); - CLASSES_BY_MOJ.clear(); - Log.severe("[NMSReflect] The plugin will not have access to NMS stuff due to an error while loading the obfuscation mapping.", t); - } - Log.info("[NMSReflect] Obfuscation mapping loaded for " + CLASSES_BY_OBF.size() + " classes."); - } - - - /** - * Returns the class mapping instance for the provided class. - * @param mojName the binary name of the desired class, on the mojang mapping. - * @return the class mapping instance for the provided class. - * @throws NullPointerException if there is no mapping for the provided Mojang mapped class. - */ - public static ClassMapping mojClass(String mojName) { - return Objects.requireNonNull(CLASSES_BY_MOJ.get(mojName), "Unable to find the Mojang mapped class '" + mojName + "'"); - } - - - - - - - - - - - private static List loadMappings(ReflectClass obfHelperClass) throws IOException { - try (final InputStream mappingsInputStream = obfHelperClass.get().getClassLoader().getResourceAsStream("META-INF/mappings/reobf.tiny")) { - if (mappingsInputStream == null) { - throw new RuntimeException("Unable to find the obfuscation mapping file in the Paper jar."); - } - - MemoryMappingTree tree = new MemoryMappingTree(); - MappingReader.read(new InputStreamReader(mappingsInputStream, StandardCharsets.UTF_8), MappingFormat.TINY_2_FILE, tree); - - List classes = new ArrayList<>(); - for (MappingTree.ClassMapping cls : tree.getClasses()) { - classes.add(new ClassMapping(cls)); - } - return classes; - } - } - - - /** - * Prints an HTML rendering of the currently loaded obfuscation mapping, into the provided {@link PrintStream}. - * @param out the stream in which to print the HTML content. - */ - public static void printHTMLMapping(PrintStream out) { - String title = "Obfuscation mapping - " + Bukkit.getName() + " version " + Bukkit.getVersion(); - out.println("\n" - + "" + title + "\n" - + """ - - - """ - + "

" + title + "

\n" - + """ -

- C: class   - E: enum   - I: interface   - @: @interface   - R: record
- : field   - c: constructor   - : method
- : public   - : protected   - : package   - : private
- S: static   - A: abstract   - F: final -

- - """); - out.println(""); - for (ClassMapping clazz : CLASSES_BY_OBF.values()) { - clazz.printHTML(out); - } - out.println("
ns" + OBF_NAMESPACE + "" + MOJ_NAMESPACE + "

Generated by marcbal" - + " using this tool" - + " running on " + Bukkit.getName() + " version " + Bukkit.getVersion() + "

" - + ""); - } - - - /** - * Represents the mapping between the obfuscated and Mojang names of a class and all its members. - */ - public static class ClassMapping { - private static int nextID = 0; - - /* package */ final int id = nextID++; - /* package */ final String obfName; - /* package */ final String mojName; - - private final Map>> methodsByObf = new TreeMap<>(); - private final Map>> methodsByMoj = new TreeMap<>(); - private final Map>> fieldsByObf = new TreeMap<>(); - private final Map>> fieldsByMoj = new TreeMap<>(); - - private ReflectClass runtimeReflectClass = null; - - private ClassMapping(MappingTree.ClassMapping cls) { - obfName = binaryClassName(cls.getName(OBF_NAMESPACE)); - mojName = binaryClassName(cls.getName(MOJ_NAMESPACE)); - - cls.getMethods().stream().map(MemberMapping::of).forEach(method -> { - method.declaringClass = this; - methodsByObf.put(method.obfDesc.identifier, method); - methodsByMoj.put(method.mojDesc.identifier, method); - }); - cls.getFields().stream().map(MemberMapping::of).forEach(field -> { - field.declaringClass = this; - fieldsByObf.put(field.obfDesc.identifier, field); - fieldsByMoj.put(field.mojDesc.identifier, field); - }); - - } - - - - private synchronized void cacheReflectClass() throws ClassNotFoundException { - if (runtimeReflectClass == null) - runtimeReflectClass = Reflect.ofClass(IS_SERVER_OBFUSCATED ? obfName : mojName); - } - - - /** - * Returns the actual runtime {@link Class} represented by this {@link ClassMapping}, wrapped into a - * {@link ReflectClass}. - * @return the actual runtime {@link Class} represented by this {@link ClassMapping}, wrapped into a - * * {@link ReflectClass}. - */ - public ReflectClass runtimeReflect() { - return runtimeReflectClass; - } - - /** - * Returns the actual runtime Class represented by this {@link ClassMapping}. - * @return the actual runtime Class represented by this {@link ClassMapping}. - */ - public Class runtimeClass() { - return runtimeReflectClass.get(); - } - - - - - /** - * Returns the actual runtime Method that has the provided mojang name and parameter types, wrapped into a - * {@link ReflectMethod}. - * @param mojName the Mojang mapped name of the method. - * @param mojParametersType the list of parameters of the method. - * Each parameter type must be an instance of one of the following type: - * {@link NMSTypeWrapper}, {@link Class}, {@link ReflectClass} or {@link ClassMapping}. - * @return the actual runtime Method that has the provided mojang name and parameter types, wrapped into a - * {@link ReflectMethod}. - * @throws IllegalArgumentException if one of the parameter has an invalid type - * @throws NullPointerException if one of the parameter is null, or if there is no mapping for the provided Mojang mapped method. - * @throws ClassNotFoundException if there is no runtime class to represent one of the provided parametersType. - * @throws NoSuchMethodException if there is no runtime method to represent the provided method. - */ - public ReflectMethod mojMethod(String mojName, Object... mojParametersType) throws ClassNotFoundException, NoSuchMethodException { - MethodId mId = new MethodId(mojName, NMSTypeWrapper.toTypeList(Arrays.asList(mojParametersType))); - MemberMapping> mm = methodsByMoj.get(mId); - Objects.requireNonNull(mm, "Unable to find the Mojang mapped method " + mId); - - try { - return mm.getReflectMember(); - } catch (ReflectiveOperationException e) { - if (e instanceof ClassNotFoundException cnfe) - throw cnfe; - if (e instanceof NoSuchMethodException nsme) - throw nsme; - // should not have another exception - throw new RuntimeException(e); - } - } - - - - - /** - * Returns the actual runtime Field that has the provided mojang name, wrapped into a {@link ReflectField}. - * @param mojName the Mojang mapped name of the field. - * @return the actual runtime Field that has the provided mojang name, wrapped into a {@link ReflectField}. - * @throws NullPointerException if there is no mapping for the provided Mojang mapped field. - * @throws NoSuchFieldException if there is no runtime field to represent the provided mojang field. - */ - public ReflectField mojField(String mojName) throws NoSuchFieldException { - MemberMapping> fm = fieldsByMoj.get(mojName); - Objects.requireNonNull(fm, "Unable to find the Mojang mapped field '" + mojName + "'"); - try { - return fm.getReflectMember(); - } catch (ReflectiveOperationException e) { - if (e instanceof NoSuchFieldException nsfe) - throw nsfe; - // should not have another exception - throw new RuntimeException(e); - } - } - - - - - - /* package */ String toClickableHTML(boolean isObfClass) { - String classToPrint = isObfClass ? obfName : mojName; - String classSimpleName = classToPrint.substring(classToPrint.lastIndexOf('.') + 1); - String htmlTitle = classSimpleName.equals(classToPrint) ? "" : (" title='" + classToPrint + "'"); - return "" + classSimpleName + ""; - } - - - - - /* package */ NMSTypeWrapper toType(boolean obf) { - return new NMSTypeWrapper(obf ? obfName : mojName, 0); - } - - - private void printHTML(PrintStream out) { - String modifiersHTML = classModifiersToHTML(runtimeClass()); - out.println("" + modifiersHTML + "" + nameToHTML(true) + "" + nameToHTML(false) + ""); - fieldsByObf.values().stream().filter(MemberMapping::isStatic).forEach(f -> f.printHTML(out)); - methodsByObf.values().stream().filter(MemberMapping::isStatic).forEach(m -> m.printHTML(out)); - printConstructorsHTML(out); - fieldsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(f -> f.printHTML(out)); - methodsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(m -> m.printHTML(out)); - } - - private String nameToHTML(boolean obf) { - String classToPrint = obf ? obfName : mojName; - int packageSep = classToPrint.lastIndexOf('.'); - String classSimpleName = classToPrint.substring(packageSep + 1); - String classPackages = classToPrint.substring(0, Math.max(packageSep, 0)); - String classHTML = (packageSep >= 0 ? (classPackages + ".") : "") + "" + classSimpleName + ""; - - NMSTypeWrapper superClass = superClass(obf); - String superClassHTML = superClass == null ? "" : (" extends " + superClass.toHTML(obf)); - - List superInterfaces = superInterfaces(obf); - String superInterfacesHTML = superInterfaces.isEmpty() ? "" - : (" implements " + superInterfaces.stream().map(t -> t.toHTML(obf)).collect(Collectors.joining(", "))); - - return classHTML + superClassHTML + superInterfacesHTML; - } - - private NMSTypeWrapper superClass(boolean obf) { - Class superClass = runtimeClass().getSuperclass(); - if (superClass == null || superClass.equals(Object.class) || superClass.equals(Enum.class) || superClass.equals(Record.class)) - return null; - ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(superClass.getName()); - return (cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(superClass); - } - - private List superInterfaces(boolean obf) { - Class[] interfaces = runtimeClass().getInterfaces(); - List types = new ArrayList<>(interfaces.length); - for (Class i : interfaces) { - ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(i.getName()); - types.add((cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(i)); - } - return types; - } - - - private void printConstructorsHTML(PrintStream out) { - String classObfSimpleName = obfName.substring(obfName.lastIndexOf('.') + 1); - String classMojSimpleName = mojName.substring(mojName.lastIndexOf('.') + 1); - for (Constructor ct : runtimeClass().getDeclaredConstructors()) { - List obfParams = new ArrayList<>(); - List mojParams = new ArrayList<>(); - for (Class param : ct.getParameterTypes()) { - ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(param.getName()); - if (cm == null) { - NMSTypeWrapper t = NMSTypeWrapper.of(param); - obfParams.add(t); - mojParams.add(t); - } - else { - obfParams.add(cm.toType(true)); - mojParams.add(cm.toType(false)); - } - } - out.println("" - + "" + elementModifiersToHTML("c", ct.getModifiers()) + "" - + "" + classObfSimpleName + "(" + obfParams.stream().map(t -> t.toHTML(true)).collect(Collectors.joining(", ")) + ")" - + "" + classMojSimpleName + "(" + mojParams.stream().map(t -> t.toHTML(false)).collect(Collectors.joining(", ")) + ")" - + ""); - } - - } - } - - - - - - - - - private record MethodId(String name, List parametersType) implements Comparable { - @Override - public int compareTo(MethodId o) { - int cmp = name.compareTo(o.name); - if (cmp != 0) - return cmp; - return toString().compareTo(o.toString()); - } - - private String toHTML(boolean isObfClass, boolean isStatic, boolean isFinal) { - String paramsHTML = parametersType.stream().map(p -> p.toHTML(isObfClass)).collect(Collectors.joining(", ")); - String cl = "mtd"; - if (isStatic) - cl += " st"; - if (isFinal) - cl += " fn"; - return "" + name + "(" + paramsHTML + ")"; - } - - public String toString() { - String paramsStr = parametersType.stream().map(NMSTypeWrapper::toString).collect(Collectors.joining(", ")); - return name + "(" + paramsStr + ")"; - } - - } - - - - private record MemberDesc>(I identifier, NMSTypeWrapper returnType) { - private String toHTML(boolean isObfClass, boolean isStatic, boolean isFinal) { - String identifierHTML = ""; - if (identifier instanceof MethodId mId) - identifierHTML = mId.toHTML(isObfClass, isStatic, isFinal); - else if (identifier instanceof String n) { - String cl = "fld"; - if (isStatic) - cl += " st"; - if (isFinal) - cl += " fn"; - identifierHTML = "" + n + ""; - } - return returnType.toHTML(isObfClass) + " " + identifierHTML; - } - - private static MemberDesc of(MappingTree.MethodMapping member, String namespace) { - String desc = member.getDesc(namespace); - try (StringReader descReader = new StringReader(desc)) { - char r = (char) descReader.read(); - if (r != '(') - throw new IllegalArgumentException("Invalid method description '" + desc + "'. Must start with '('."); - - List paramsType = new ArrayList<>(); - - while (((char) descReader.read()) != ')') { - descReader.skip(-1); - paramsType.add(NMSTypeWrapper.parse(descReader)); - } - - NMSTypeWrapper retType = NMSTypeWrapper.parse(descReader); - return new MemberDesc<>(new MethodId(member.getName(namespace), Collections.unmodifiableList(paramsType)), retType); - } catch (IOException e) { - throw new RuntimeException("StringReader read error", e); - } - - } - - - private static MemberDesc of(MappingTree.FieldMapping member, String namespace) { - StringReader descReader = new StringReader(member.getDesc(namespace)); - return new MemberDesc<>(member.getName(namespace), NMSTypeWrapper.parse(descReader)); - } - } - - - - - private static abstract class MemberMapping, R extends ReflectMember> { - private final String htmlTypeChar; - /* package */ final MemberDesc obfDesc, mojDesc; - /* package */ ClassMapping declaringClass; - private MemberMapping(String htmlType, MemberDesc obfDesc, MemberDesc mojDesc) { - htmlTypeChar = htmlType; - this.obfDesc = obfDesc; - this.mojDesc = mojDesc; - } - - /* package */ void printHTML(PrintStream out) { - int mod = 0; - try { - mod = getReflectMember().getModifiers(); - } catch (ReflectiveOperationException e) { - // ignore - } - boolean isStatic = Modifier.isStatic(mod); - boolean isFinal = Modifier.isFinal(mod); - out.println("" - + "" + elementModifiersToHTML(htmlTypeChar, mod) + "" - + "" + obfDesc.toHTML(true, isStatic, isFinal) + "" - + "" + mojDesc.toHTML(false, isStatic, isFinal) + "" - + ""); - } - - /* package */ MemberDesc getReflectDesc() { - return (IS_SERVER_OBFUSCATED ? obfDesc : mojDesc); - } - - /* package */ abstract R getReflectMember() throws ReflectiveOperationException; - - /* package */ boolean isStatic() { - try { - return Modifier.isStatic(getReflectMember().getModifiers()); - } catch (ReflectiveOperationException e) { - Log.severe(e); - return false; - } - } - - private static MemberMapping> of(MappingTree.MethodMapping mioMapping) { - return new MemberMapping<>("⬤", MemberDesc.of(mioMapping, OBF_NAMESPACE), MemberDesc.of(mioMapping, MOJ_NAMESPACE)) { - @Override - ReflectMethod getReflectMember() throws ClassNotFoundException, NoSuchMethodException { - MethodId id = getReflectDesc().identifier; - return declaringClass.runtimeReflectClass.method(id.name, NMSTypeWrapper.toClassArray(id.parametersType)); - } - }; - } - - private static MemberMapping> of(MappingTree.FieldMapping mioMapping) { - return new MemberMapping<>("●", MemberDesc.of(mioMapping, OBF_NAMESPACE), MemberDesc.of(mioMapping, MOJ_NAMESPACE)) { - @Override - ReflectField getReflectMember() throws NoSuchFieldException { - String id = getReflectDesc().identifier; - return declaringClass.runtimeReflectClass.field(id); - } - }; - } - - - - } - - - - - - /* package */ static String binaryClassName(String cl) { - return cl.replace('/', '.'); - } - - - - private static String classModifiersToHTML(Class clazz) { - String elementHTMLType; - - if (clazz.isEnum()) - elementHTMLType = "E"; - else if (clazz.isAnnotation()) - elementHTMLType = "@"; - else if (clazz.isInterface()) - elementHTMLType = "I"; - else if (clazz.isRecord()) - elementHTMLType = "R"; - else if (clazz.isPrimitive()) - elementHTMLType = ""; - else - elementHTMLType = "C"; - - return elementModifiersToHTML(elementHTMLType, clazz.getModifiers()); - } - - - - private static String elementModifiersToHTML(String elementHTMLType, int elModifiers) { - String html = "" + elementHTMLType + ""; - - boolean isStatic = Modifier.isStatic(elModifiers); - boolean isAbstract = Modifier.isAbstract(elModifiers); - boolean isFinal = Modifier.isFinal(elModifiers); - - if (isStatic || isAbstract || isFinal) { - html += ""; - if (isStatic) - html += "S"; - if (isAbstract) - html += "A"; - if (isFinal) - html += "F"; - html += ""; - } - - return html; - } - - // ● (field) - // ⬤ (method) - -} diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java deleted file mode 100644 index 2928b92..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java +++ /dev/null @@ -1,194 +0,0 @@ -package fr.pandacube.lib.paper.reflect; - -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import fr.pandacube.lib.reflect.ReflectClass; -import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; - -/* package */ class NMSTypeWrapper implements Comparable { - private final String type; - private final int arrayDepth; - - /* package */ NMSTypeWrapper(String type, int arrayDepth) { - this.type = type; - this.arrayDepth = arrayDepth; - } - - @Override - public boolean equals(Object obj) { - return obj instanceof NMSTypeWrapper ot && type.equals(ot.type) && arrayDepth == ot.arrayDepth; - } - @Override - public int hashCode() { - return type.hashCode() ^ arrayDepth; - } - - @Override - public int compareTo(NMSTypeWrapper o) { - return toString().compareTo(o.toString()); - } - - Class toClass() throws ClassNotFoundException { - - Class cl = switch(type) { - case "boolean" -> boolean.class; - case "byte" -> byte.class; - case "char" -> char.class; - case "double" -> double.class; - case "float" -> float.class; - case "int" -> int.class; - case "long" -> long.class; - case "short" -> short.class; - case "void" -> void.class; - default -> Class.forName(type); - }; - - for (int i = 0; i < arrayDepth; i++) { - cl = cl.arrayType(); - } - - return cl; - } - - /* package */ static NMSTypeWrapper of(Class cl) { - int arrayDepth = 0; - while (cl.isArray()) { - cl = cl.getComponentType(); - arrayDepth++; - } - return new NMSTypeWrapper(cl.getName(), arrayDepth); - } - - public static NMSTypeWrapper of(ReflectClass rc) { - return arrayOf(rc, 0); - } - - public static NMSTypeWrapper arrayOf(ReflectClass rc, int arrayDepth) { - return new NMSTypeWrapper(rc.get().getName(), arrayDepth); - } - - public static NMSTypeWrapper mojOf(ClassMapping cm) { - return arrayMojOf(cm, 0); - } - - public static NMSTypeWrapper arrayMojOf(ClassMapping cm, int arrayDepth) { - return new NMSTypeWrapper(cm.mojName, arrayDepth); - } - - /* package */ static NMSTypeWrapper toType(Object typeObj) { - Objects.requireNonNull(typeObj, "typeObj cannot be null"); - if (typeObj instanceof Class cl) { - return of(cl); - } - else if (typeObj instanceof ClassMapping cm) { - return mojOf(cm); - } - else if (typeObj instanceof ReflectClass rc) { - return of(rc); - } - else if (typeObj instanceof NMSTypeWrapper t) { - return t; - } - else - throw new IllegalArgumentException("Unsupported object of type " + typeObj.getClass()); - } - - /* package */ String toHTML(boolean isObfClass) { - ClassMapping clMapping = (isObfClass ? NMSReflect.CLASSES_BY_OBF : NMSReflect.CLASSES_BY_MOJ).get(type); - String typeHTML; - if (clMapping != null) { - typeHTML = clMapping.toClickableHTML(isObfClass); - } - else { - String classToPrint = type; - String classSimpleName = classToPrint.substring(classToPrint.lastIndexOf('.') + 1); - String htmlTitle = classSimpleName.equals(classToPrint) ? "" : (" title='" + classToPrint + "'"); - if (!htmlTitle.isEmpty()) { - typeHTML = "" + classSimpleName + ""; - } - else { - typeHTML = "" + classSimpleName + ""; - } - } - - - return typeHTML + "[]".repeat(arrayDepth); - } - - public String toString() { - return type + "[]".repeat(arrayDepth); - } - - - public boolean isPrimitive() { - try { - return toClass().isPrimitive(); - } catch (ClassNotFoundException e) { - return false; - } - } - - - - - /* package */ static NMSTypeWrapper parse(StringReader desc) { - try { - int arrayDepth = 0; - char c; - while ((c = (char) desc.read()) == '[') { - arrayDepth++; - } - String type = switch(c) { - case 'Z' -> "boolean"; - case 'B' -> "byte"; - case 'C' -> "char"; - case 'D' -> "double"; - case 'F' -> "float"; - case 'I' -> "int"; - case 'J' -> "long"; - case 'S' -> "short"; - case 'L' -> { - StringBuilder sbClass = new StringBuilder(); - char r; - while ((r = (char) desc.read()) != ';') { - sbClass.append(r); - } - yield NMSReflect.binaryClassName(sbClass.toString()); - } - default -> "void"; - }; - return new NMSTypeWrapper(type, arrayDepth); - } catch (IOException e) { - throw new RuntimeException("StringReader read error", e); - } - } - - - - - /* package */ static List toTypeList(List paramsType) { - List types = new ArrayList<>(paramsType.size()); - for (int i = 0; i < paramsType.size(); i++) { - Object param = paramsType.get(i); - try { - types.add(NMSTypeWrapper.toType(param)); - } catch (NullPointerException|IllegalArgumentException e) { - throw new IllegalArgumentException("Invalid parameterType at index " + i, e); - } - } - return types; - } - - /* package */ static Class[] toClassArray(List types) throws ClassNotFoundException { - Class[] classes = new Class[types.size()]; - for (int i = 0; i < types.size(); i++) { - classes[i] = types.get(i).toClass(); - } - return classes; - } - -} \ No newline at end of file diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java index 4a27649..6a4a229 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/PandalibPaperReflect.java @@ -17,13 +17,9 @@ import fr.pandacube.lib.paper.reflect.wrapper.dataconverter.MCTypeRegistry; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.DetectedVersion; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.SharedConstants; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.WorldVersion; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.BlockPosArgument; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.CommandSourceStack; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ComponentArgument; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Coordinates; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntityArgument; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntitySelector; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.GameProfileArgument; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ResourceLocationArgument; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Vec3Argument; @@ -93,7 +89,6 @@ public class PandalibPaperReflect { * @throws Exception if a problem occurs when initializing wrapper classes. */ public static void init() throws Exception { - NMSReflect.init(); synchronized (PandalibPaperReflect.class) { if (isInit) return; @@ -127,76 +122,72 @@ public class PandalibPaperReflect { thAcc.catchThrowable(() -> initWrapper(MCTypeRegistry.class, MCTypeRegistry.REFLECT.get())); // minecraft.commands - thAcc.catchThrowable(() -> initWrapper(BlockPosArgument.class, BlockPosArgument.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Commands.class, Commands.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(CommandSourceStack.class, CommandSourceStack.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ComponentArgument.class, ComponentArgument.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Coordinates.class, Coordinates.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(EntityArgument.class, EntityArgument.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(EntitySelector.class, EntitySelector.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(GameProfileArgument.class, GameProfileArgument.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ResourceLocationArgument.class, ResourceLocationArgument.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Vec3Argument.class, Vec3Argument.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(Commands.class, Commands.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(CommandSourceStack.class, CommandSourceStack.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Coordinates.class, Coordinates.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(GameProfileArgument.class, GameProfileArgument.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ResourceLocationArgument.class, ResourceLocationArgument.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Vec3Argument.class, Vec3Argument.REFLECT.get())); // minecraft.core - thAcc.catchThrowable(() -> initWrapper(BlockPos.class, BlockPos.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Vec3i.class, Vec3i.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(BlockPos.class, BlockPos.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Vec3i.class, Vec3i.REFLECT.get())); // minecraft.nbt - thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.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(StringTag.class, StringTag.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ListTag.class, ListTag.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(NbtAccounter.class, NbtAccounter.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(NbtIo.class, NbtIo.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(StringTag.class, StringTag.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.REFLECT.get())); // minecraft.network.chat - thAcc.catchThrowable(() -> initWrapper(Component.class, Component.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(Component.class, Component.REFLECT.get())); // minecraft.network.protocol.custom - thAcc.catchThrowable(() -> initWrapper(BrandPayload.class, BrandPayload.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(CustomPacketPayload.class, CustomPacketPayload.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(BrandPayload.class, BrandPayload.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(CustomPacketPayload.class, CustomPacketPayload.REFLECT.get())); // minecraft.network.protocol - thAcc.catchThrowable(() -> initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Packet.class, Packet.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Packet.class, Packet.REFLECT.get())); // minecraft.network - thAcc.catchThrowable(() -> initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.REFLECT.get())); // minecraft.resources - thAcc.catchThrowable(() -> initWrapper(ResourceLocation.class, ResourceLocation.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(ResourceLocation.class, ResourceLocation.REFLECT.get())); // minecraft.server - thAcc.catchThrowable(() -> initWrapper(ChunkMap.class, ChunkMap.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(DedicatedServer.class, DedicatedServer.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(MinecraftServer.class, MinecraftServer.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(PlayerList.class, PlayerList.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ServerChunkCache.class, ServerChunkCache.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ServerCommonPacketListenerImpl.class, ServerCommonPacketListenerImpl.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ServerLevel.class, ServerLevel.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ServerPlayer.class, ServerPlayer.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Settings.class, Settings.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(ChunkMap.class, ChunkMap.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(DedicatedServer.class, DedicatedServer.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(MinecraftServer.class, MinecraftServer.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(PlayerList.class, PlayerList.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ServerChunkCache.class, ServerChunkCache.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ServerCommonPacketListenerImpl.class, ServerCommonPacketListenerImpl.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ServerLevel.class, ServerLevel.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ServerPlayer.class, ServerPlayer.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Settings.class, Settings.REFLECT.get())); // minecraft.util - thAcc.catchThrowable(() -> initWrapper(ProgressListener.class, ProgressListener.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(ProgressListener.class, ProgressListener.REFLECT.get())); // minecraft.world.block - thAcc.catchThrowable(() -> initWrapper(Block.class, Block.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(BambooStalkBlock.class, BambooStalkBlock.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(Block.class, Block.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(BambooStalkBlock.class, BambooStalkBlock.REFLECT.get())); // minecraft.world - thAcc.catchThrowable(() -> initWrapper(AABB.class, AABB.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ChunkPos.class, ChunkPos.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ChunkStorage.class, ChunkStorage.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(DataVersion.class, DataVersion.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Entity.class, Entity.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(ItemStack.class, ItemStack.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Level.class, Level.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(MapItemSavedData.class, MapItemSavedData.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(PlayerDataStorage.class, PlayerDataStorage.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(SavedData.class, SavedData.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(Vec3.class, Vec3.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(VoxelShape.class, VoxelShape.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(AABB.class, AABB.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ChunkPos.class, ChunkPos.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ChunkStorage.class, ChunkStorage.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(DataVersion.class, DataVersion.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Entity.class, Entity.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(ItemStack.class, ItemStack.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Level.class, Level.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(MapItemSavedData.class, MapItemSavedData.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(PlayerDataStorage.class, PlayerDataStorage.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(SavedData.class, SavedData.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(Vec3.class, Vec3.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(VoxelShape.class, VoxelShape.REFLECT.get())); // minecraft - thAcc.catchThrowable(() -> initWrapper(DetectedVersion.class, DetectedVersion.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(SharedConstants.class, SharedConstants.MAPPING.runtimeClass())); - thAcc.catchThrowable(() -> initWrapper(WorldVersion.class, WorldVersion.MAPPING.runtimeClass())); + thAcc.catchThrowable(() -> initWrapper(DetectedVersion.class, DetectedVersion.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(SharedConstants.class, SharedConstants.REFLECT.get())); + thAcc.catchThrowable(() -> initWrapper(WorldVersion.class, WorldVersion.REFLECT.get())); // netty thAcc.catchThrowable(() -> initWrapper(ByteBuf.class, ByteBuf.REFLECT.get())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java index ae614a1..9cc4243 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftItemStack.java @@ -12,7 +12,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CraftItemStack extends ReflectWrapperTyped { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("inventory.CraftItemStack")); - public static final ReflectMethod asCraftMirror = wrapEx(() -> REFLECT.method("asCraftMirror", fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack.MAPPING.runtimeClass())); + public static final ReflectMethod asCraftMirror = wrapEx(() -> REFLECT.method("asCraftMirror", fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack.REFLECT.get())); public static final ReflectMethod asNMSCopy = wrapEx(() -> REFLECT.method("asNMSCopy", ItemStack.class)); public static ItemStack asCraftMirror(fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack original) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftNamespacedKey.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftNamespacedKey.java index fc0b359..ad14012 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftNamespacedKey.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftNamespacedKey.java @@ -15,7 +15,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CraftNamespacedKey extends ReflectWrapper { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey")); public static final ReflectMethod toMinecraft = wrapEx(() -> REFLECT.method("toMinecraft", NamespacedKey.class)); - public static final ReflectMethod fromMinecraft = ThrowableUtil.wrapEx(() -> REFLECT.method("fromMinecraft", ResourceLocation.MAPPING.runtimeClass())); + public static final ReflectMethod fromMinecraft = ThrowableUtil.wrapEx(() -> REFLECT.method("fromMinecraft", ResourceLocation.REFLECT.get())); public static ResourceLocation toMinecraft(NamespacedKey key) { return wrap(wrapReflectEx(() -> toMinecraft.invokeStatic(key)), ResourceLocation.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftVector.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftVector.java index 231e5be..4362781 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftVector.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/CraftVector.java @@ -15,8 +15,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CraftVector extends ReflectWrapper { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector")); - public static final ReflectMethod toBukkit_Vec3 = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", Vec3.MAPPING.runtimeClass())); - public static final ReflectMethod toBukkit_BlockPos = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", BlockPos.MAPPING.runtimeClass())); + public static final ReflectMethod toBukkit_Vec3 = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", Vec3.REFLECT.get())); + public static final ReflectMethod toBukkit_BlockPos = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", BlockPos.REFLECT.get())); public static final ReflectMethod toNMS = wrapEx(() -> REFLECT.method("toNMS", Vector.class)); public static final ReflectMethod toBlockPos = wrapEx(() -> REFLECT.method("toNMS", Vector.class)); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java index a813d90..8b36f32 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/craftbukkit/VanillaCommandWrapper.java @@ -17,7 +17,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class VanillaCommandWrapper extends ReflectWrapperTyped { public static final ReflectClass REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper")); - public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class)); + public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Commands.REFLECT.get(), CommandNode.class)); public static final ReflectField vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand")); public static final ReflectMethod getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class)); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java index 9f01475..af3596e 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/dataconverter/MCDataConverter.java @@ -11,7 +11,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class MCDataConverter extends ReflectWrapper { public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("ca.spottedleaf.dataconverter.minecraft.MCDataConverter")); - private static final ReflectMethod convertTag = wrapEx(() -> REFLECT.method("convertTag", MCDataType.REFLECT.get(), CompoundTag.MAPPING.runtimeClass(), int.class, int.class)); + private static final ReflectMethod convertTag = wrapEx(() -> REFLECT.method("convertTag", MCDataType.REFLECT.get(), CompoundTag.REFLECT.get(), int.class, int.class)); public static CompoundTag convertTag(MCDataType type, CompoundTag data, int fromVersion, int toVersion) { return wrap(wrapReflectEx(() -> convertTag.invokeStatic(unwrap(type), unwrap(data), fromVersion, toVersion)), CompoundTag.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/DetectedVersion.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/DetectedVersion.java index 11d4484..1ed861a 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/DetectedVersion.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/DetectedVersion.java @@ -1,12 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class DetectedVersion extends ReflectWrapper implements WorldVersion { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.DetectedVersion")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.DetectedVersion")); protected DetectedVersion(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/SharedConstants.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/SharedConstants.java index 7b68f47..ebd62b4 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/SharedConstants.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/SharedConstants.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -8,9 +9,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class SharedConstants extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants")); - private static final ReflectMethod getCurrentVersion = wrapEx(() -> MAPPING.mojMethod("getCurrentVersion")); - private static final ReflectMethod getProtocolVersion = wrapEx(() -> MAPPING.mojMethod("getProtocolVersion")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.SharedConstants")); + private static final ReflectMethod getCurrentVersion = wrapEx(() -> REFLECT.method("getCurrentVersion")); + private static final ReflectMethod getProtocolVersion = wrapEx(() -> REFLECT.method("getProtocolVersion")); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/WorldVersion.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/WorldVersion.java index c389cd4..b644736 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/WorldVersion.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/WorldVersion.java @@ -1,8 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DataVersion; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -14,8 +14,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; @ConcreteWrapper(WorldVersion.__concrete.class) public interface WorldVersion extends ReflectWrapperI { - ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.WorldVersion")); - ReflectMethod getDataVersion = wrapEx(() -> MAPPING.mojMethod("getDataVersion")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.WorldVersion")); + ReflectMethod getDataVersion = wrapEx(() -> REFLECT.method("getDataVersion")); default DataVersion getDataVersion() { return wrap(wrapReflectEx(() -> getDataVersion.invoke(__getRuntimeInstance())), DataVersion.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/BlockPosArgument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/BlockPosArgument.java deleted file mode 100644 index 6ec7a6a..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/BlockPosArgument.java +++ /dev/null @@ -1,24 +0,0 @@ -package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; - -import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; -import fr.pandacube.lib.reflect.ReflectMethod; - -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; - -public class BlockPosArgument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.BlockPosArgument")); - private static final ReflectMethod blockPos = wrapEx(() -> MAPPING.mojMethod("blockPos")); - - @SuppressWarnings("unchecked") - public static ArgumentType blockPos() { - return (ArgumentType) wrapReflectEx(() -> blockPos.invokeStatic()); - } - - protected BlockPosArgument(Object obj) { - super(obj); - } -} diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/CommandSourceStack.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/CommandSourceStack.java index 900d41a..5f310d5 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/CommandSourceStack.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/CommandSourceStack.java @@ -1,12 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class CommandSourceStack extends ReflectWrapperTyped { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.CommandSourceStack")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.CommandSourceStack")); protected CommandSourceStack(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Commands.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Commands.java index 96fb64c..d29270b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Commands.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Commands.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; import com.mojang.brigadier.CommandDispatcher; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Commands extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands")); - public static final ReflectField dispatcher = wrapEx(() -> MAPPING.mojField("dispatcher")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.Commands")); + public static final ReflectField dispatcher = wrapEx(() -> REFLECT.field("dispatcher")); @SuppressWarnings("unchecked") public CommandDispatcher dispatcher() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ComponentArgument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ComponentArgument.java deleted file mode 100644 index f4e4542..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ComponentArgument.java +++ /dev/null @@ -1,24 +0,0 @@ -package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; - -import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; -import fr.pandacube.lib.reflect.ReflectMethod; - -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; - -public class ComponentArgument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ComponentArgument")); - private static final ReflectMethod textComponent = wrapEx(() -> MAPPING.mojMethod("textComponent")); - - @SuppressWarnings("unchecked") - public static ArgumentType textComponent() { - return (ArgumentType) wrapReflectEx(() -> textComponent.invokeStatic()); - } - - protected ComponentArgument(Object obj) { - super(obj); - } -} diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Coordinates.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Coordinates.java index 2c0db63..dcae2ad 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Coordinates.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Coordinates.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -13,8 +14,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; @ConcreteWrapper(Coordinates.__concrete.class) public interface Coordinates extends ReflectWrapperI { - NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Coordinates")); - ReflectMethod getPosition = wrapEx(() -> MAPPING.mojMethod("getPosition", CommandSourceStack.MAPPING)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.coordinates.Coordinates")); + ReflectMethod getPosition = wrapEx(() -> REFLECT.method("getPosition", CommandSourceStack.REFLECT.get())); default Vec3 getPosition(io.papermc.paper.command.brigadier.CommandSourceStack source) { return wrap(wrapReflectEx(() -> getPosition.invoke(__getRuntimeInstance(), source)), Vec3.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntityArgument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntityArgument.java deleted file mode 100644 index 0244246..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntityArgument.java +++ /dev/null @@ -1,43 +0,0 @@ -package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; - -import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; -import fr.pandacube.lib.reflect.ReflectMethod; - -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; - -public class EntityArgument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.EntityArgument")); - private static final ReflectMethod entity = wrapEx(() -> MAPPING.mojMethod("entity")); - private static final ReflectMethod entities = wrapEx(() -> MAPPING.mojMethod("entities")); - private static final ReflectMethod player = wrapEx(() -> MAPPING.mojMethod("player")); - private static final ReflectMethod players = wrapEx(() -> MAPPING.mojMethod("players")); - - @SuppressWarnings("unchecked") - public static ArgumentType entity() { - return (ArgumentType) wrapReflectEx(() -> entity.invokeStatic()); - } - - @SuppressWarnings("unchecked") - public static ArgumentType entities() { - return (ArgumentType) wrapReflectEx(() -> entities.invokeStatic()); - } - - @SuppressWarnings("unchecked") - public static ArgumentType player() { - return (ArgumentType) wrapReflectEx(() -> player.invokeStatic()); - } - - @SuppressWarnings("unchecked") - public static ArgumentType players() { - return (ArgumentType) wrapReflectEx(() -> players.invokeStatic()); - } - - - protected EntityArgument(Object obj) { - super(obj); - } -} diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntitySelector.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntitySelector.java deleted file mode 100644 index 678c245..0000000 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/EntitySelector.java +++ /dev/null @@ -1,46 +0,0 @@ -package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; - -import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectListWrapper; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer; -import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity; -import fr.pandacube.lib.reflect.ReflectMethod; - -import java.util.List; - -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; - -public class EntitySelector extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.selector.EntitySelector")); - private static final ReflectMethod findEntities = wrapEx(() -> MAPPING.mojMethod("findEntities", CommandSourceStack.MAPPING)); - private static final ReflectMethod findPlayers = wrapEx(() -> MAPPING.mojMethod("findPlayers", CommandSourceStack.MAPPING)); - private static final ReflectMethod findSingleEntity = wrapEx(() -> MAPPING.mojMethod("findSingleEntity", CommandSourceStack.MAPPING)); - private static final ReflectMethod findSinglePlayer = wrapEx(() -> MAPPING.mojMethod("findSinglePlayer", CommandSourceStack.MAPPING)); - - @SuppressWarnings("unchecked") - public ReflectListWrapper findEntities(BukkitBrigadierCommandSource source) { - return wrapList((List) wrapReflectEx(() -> findEntities.invoke(__getRuntimeInstance(), source)), Entity.class); - } - - public Entity findSingleEntity(BukkitBrigadierCommandSource source) { - return wrap(wrapReflectEx(() -> findSingleEntity.invoke(__getRuntimeInstance(), source)), Entity.class); - } - - @SuppressWarnings("unchecked") - public ReflectListWrapper findPlayers(BukkitBrigadierCommandSource source) { - return wrapList((List) wrapReflectEx(() -> findPlayers.invoke(__getRuntimeInstance(), source)), ServerPlayer.class); - } - - public ServerPlayer findSinglePlayer(BukkitBrigadierCommandSource source) { - return wrap(wrapReflectEx(() -> findSinglePlayer.invoke(__getRuntimeInstance(), source)), ServerPlayer.class); - } - - - protected EntitySelector(Object obj) { - super(obj); - } -} diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/GameProfileArgument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/GameProfileArgument.java index 67a02bc..110c84b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/GameProfileArgument.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/GameProfileArgument.java @@ -1,17 +1,17 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class GameProfileArgument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument")); - private static final ReflectMethod gameProfile = wrapEx(() -> MAPPING.mojMethod("gameProfile")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.GameProfileArgument")); + private static final ReflectMethod gameProfile = wrapEx(() -> REFLECT.method("gameProfile")); @SuppressWarnings("unchecked") public static ArgumentType gameProfile() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ResourceLocationArgument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ResourceLocationArgument.java index f8b62e3..013bee8 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ResourceLocationArgument.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/ResourceLocationArgument.java @@ -1,17 +1,17 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ResourceLocationArgument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument")); - private static final ReflectMethod id = wrapEx(() -> MAPPING.mojMethod("id")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.ResourceLocationArgument")); + private static final ReflectMethod id = wrapEx(() -> REFLECT.method("id")); @SuppressWarnings("unchecked") public static ArgumentType id() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Vec3Argument.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Vec3Argument.java index 0e58b8b..733a3fa 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Vec3Argument.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/commands/Vec3Argument.java @@ -1,17 +1,17 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; import com.mojang.brigadier.arguments.ArgumentType; - -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Vec3Argument extends ReflectWrapperTyped> { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument")); - private static final ReflectMethod vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.coordinates.Vec3Argument")); + private static final ReflectMethod vec3 = wrapEx(() -> REFLECT.method("vec3", boolean.class)); @SuppressWarnings("unchecked") public static ArgumentType vec3(boolean centerIntegers) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/BlockPos.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/BlockPos.java index 66d378b..534a278 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/BlockPos.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/BlockPos.java @@ -1,11 +1,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class BlockPos extends Vec3i { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.BlockPos")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.core.BlockPos")); protected BlockPos(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/Vec3i.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/Vec3i.java index ad09f5e..fdedec1 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/Vec3i.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/core/Vec3i.java @@ -1,17 +1,18 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Vec3i extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i")); - public static final ReflectMethod getX = wrapEx(() -> MAPPING.mojMethod("getX")); - public static final ReflectMethod getY = wrapEx(() -> MAPPING.mojMethod("getY")); - public static final ReflectMethod getZ = wrapEx(() -> MAPPING.mojMethod("getZ")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.core.Vec3i")); + public static final ReflectMethod getX = wrapEx(() -> REFLECT.method("getX")); + public static final ReflectMethod getY = wrapEx(() -> REFLECT.method("getY")); + public static final ReflectMethod getZ = wrapEx(() -> REFLECT.method("getZ")); public int getX() { return (int) wrapReflectEx(() -> getX.invoke(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CollectionTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CollectionTag.java index e392535..62b1049 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CollectionTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CollectionTag.java @@ -1,7 +1,7 @@ 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.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped; import java.util.AbstractList; @@ -9,7 +9,7 @@ import java.util.AbstractList; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class CollectionTag extends ReflectWrapperTyped> implements Tag { - public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.CollectionTag")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.CollectionTag")); public int size() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java index 4ca8979..31899e6 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java @@ -1,60 +1,60 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; +import fr.pandacube.lib.reflect.ReflectConstructor; +import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; -import fr.pandacube.lib.reflect.ReflectConstructor; -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; +import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; +import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class CompoundTag extends ReflectWrapper implements Tag { - public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.CompoundTag")); - public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor()); - private static final ReflectMethod putBoolean = wrapEx(() -> MAPPING.mojMethod("putBoolean", String.class, boolean.class)); - private static final ReflectMethod putByte = wrapEx(() -> MAPPING.mojMethod("putByte", String.class, byte.class)); - private static final ReflectMethod putByteArray = wrapEx(() -> MAPPING.mojMethod("putByteArray", String.class, byte[].class)); - private static final ReflectMethod putByteArray_List = wrapEx(() -> MAPPING.mojMethod("putByteArray", String.class, List.class)); - private static final ReflectMethod putDouble = wrapEx(() -> MAPPING.mojMethod("putDouble", String.class, double.class)); - private static final ReflectMethod putFloat = wrapEx(() -> MAPPING.mojMethod("putFloat", String.class, float.class)); - private static final ReflectMethod putInt = wrapEx(() -> MAPPING.mojMethod("putInt", String.class, int.class)); - private static final ReflectMethod putIntArray = wrapEx(() -> MAPPING.mojMethod("putIntArray", String.class, int[].class)); - private static final ReflectMethod putIntArray_List = wrapEx(() -> MAPPING.mojMethod("putIntArray", String.class, List.class)); - private static final ReflectMethod putString = wrapEx(() -> MAPPING.mojMethod("putString", String.class, String.class)); - private static final ReflectMethod putUUID = wrapEx(() -> MAPPING.mojMethod("putUUID", String.class, UUID.class)); - private static final ReflectMethod putLong = wrapEx(() -> MAPPING.mojMethod("putLong", String.class, long.class)); - private static final ReflectMethod putLongArray = wrapEx(() -> MAPPING.mojMethod("putLongArray", String.class, long[].class)); - private static final ReflectMethod putLongArray_List = wrapEx(() -> MAPPING.mojMethod("putLongArray", String.class, List.class)); - private static final ReflectMethod putShort = wrapEx(() -> MAPPING.mojMethod("putShort", String.class, short.class)); - private static final ReflectMethod put = wrapEx(() -> MAPPING.mojMethod("put", String.class, Tag.MAPPING)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.CompoundTag")); + public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor()); + private static final ReflectMethod putBoolean = wrapEx(() -> REFLECT.method("putBoolean", String.class, boolean.class)); + private static final ReflectMethod putByte = wrapEx(() -> REFLECT.method("putByte", String.class, byte.class)); + private static final ReflectMethod putByteArray = wrapEx(() -> REFLECT.method("putByteArray", String.class, byte[].class)); + private static final ReflectMethod putByteArray_List = wrapEx(() -> REFLECT.method("putByteArray", String.class, List.class)); + private static final ReflectMethod putDouble = wrapEx(() -> REFLECT.method("putDouble", String.class, double.class)); + private static final ReflectMethod putFloat = wrapEx(() -> REFLECT.method("putFloat", String.class, float.class)); + private static final ReflectMethod putInt = wrapEx(() -> REFLECT.method("putInt", String.class, int.class)); + private static final ReflectMethod putIntArray = wrapEx(() -> REFLECT.method("putIntArray", String.class, int[].class)); + private static final ReflectMethod putIntArray_List = wrapEx(() -> REFLECT.method("putIntArray", String.class, List.class)); + private static final ReflectMethod putString = wrapEx(() -> REFLECT.method("putString", String.class, String.class)); + private static final ReflectMethod putUUID = wrapEx(() -> REFLECT.method("putUUID", String.class, UUID.class)); + private static final ReflectMethod putLong = wrapEx(() -> REFLECT.method("putLong", String.class, long.class)); + private static final ReflectMethod putLongArray = wrapEx(() -> REFLECT.method("putLongArray", String.class, long[].class)); + private static final ReflectMethod putLongArray_List = wrapEx(() -> REFLECT.method("putLongArray", String.class, List.class)); + private static final ReflectMethod putShort = wrapEx(() -> REFLECT.method("putShort", String.class, short.class)); + private static final ReflectMethod put = wrapEx(() -> REFLECT.method("put", String.class, Tag.REFLECT.get())); - private static final ReflectMethod getTagType = wrapEx(() -> MAPPING.mojMethod("getTagType", String.class)); - private static final ReflectMethod getByte = wrapEx(() -> MAPPING.mojMethod("getByte", String.class)); - private static final ReflectMethod getShort = wrapEx(() -> MAPPING.mojMethod("getShort", String.class)); - private static final ReflectMethod getInt = wrapEx(() -> MAPPING.mojMethod("getInt", String.class)); - private static final ReflectMethod getLong = wrapEx(() -> MAPPING.mojMethod("getLong", String.class)); - private static final ReflectMethod getFloat = wrapEx(() -> MAPPING.mojMethod("getFloat", String.class)); - private static final ReflectMethod getDouble = wrapEx(() -> MAPPING.mojMethod("getDouble", String.class)); - private static final ReflectMethod getString = wrapEx(() -> MAPPING.mojMethod("getString", String.class)); - private static final ReflectMethod getByteArray = wrapEx(() -> MAPPING.mojMethod("getByteArray", String.class)); - private static final ReflectMethod getIntArray = wrapEx(() -> MAPPING.mojMethod("getIntArray", String.class)); - private static final ReflectMethod getLongArray = wrapEx(() -> MAPPING.mojMethod("getLongArray", String.class)); - private static final ReflectMethod getCompound = wrapEx(() -> MAPPING.mojMethod("getCompound", String.class)); - private static final ReflectMethod getBoolean = wrapEx(() -> MAPPING.mojMethod("getBoolean", String.class)); - private static final ReflectMethod getList = wrapEx(() -> MAPPING.mojMethod("getList", String.class, int.class)); + private static final ReflectMethod getTagType = wrapEx(() -> REFLECT.method("getTagType", String.class)); + private static final ReflectMethod getByte = wrapEx(() -> REFLECT.method("getByte", String.class)); + private static final ReflectMethod getShort = wrapEx(() -> REFLECT.method("getShort", String.class)); + private static final ReflectMethod getInt = wrapEx(() -> REFLECT.method("getInt", String.class)); + private static final ReflectMethod getLong = wrapEx(() -> REFLECT.method("getLong", String.class)); + private static final ReflectMethod getFloat = wrapEx(() -> REFLECT.method("getFloat", String.class)); + private static final ReflectMethod getDouble = wrapEx(() -> REFLECT.method("getDouble", String.class)); + private static final ReflectMethod getString = wrapEx(() -> REFLECT.method("getString", String.class)); + private static final ReflectMethod getByteArray = wrapEx(() -> REFLECT.method("getByteArray", String.class)); + private static final ReflectMethod getIntArray = wrapEx(() -> REFLECT.method("getIntArray", String.class)); + private static final ReflectMethod getLongArray = wrapEx(() -> REFLECT.method("getLongArray", String.class)); + private static final ReflectMethod getCompound = wrapEx(() -> REFLECT.method("getCompound", String.class)); + private static final ReflectMethod getBoolean = wrapEx(() -> REFLECT.method("getBoolean", String.class)); + private static final ReflectMethod getList = wrapEx(() -> REFLECT.method("getList", String.class, int.class)); - private static final ReflectMethod get = wrapEx(() -> MAPPING.mojMethod("get", String.class)); - private static final ReflectMethod getAllKeys = wrapEx(() -> MAPPING.mojMethod("getAllKeys")); - private static final ReflectMethod entries = wrapEx(() -> MAPPING.mojMethod("entries")); - private static final ReflectMethod size = wrapEx(() -> MAPPING.mojMethod("size")); - private static final ReflectMethod contains = wrapEx(() -> MAPPING.mojMethod("contains", String.class)); - private static final ReflectMethod containsStringInt = wrapEx(() -> MAPPING.mojMethod("contains", String.class, int.class)); + private static final ReflectMethod get = wrapEx(() -> REFLECT.method("get", String.class)); + private static final ReflectMethod getAllKeys = wrapEx(() -> REFLECT.method("getAllKeys")); + private static final ReflectMethod entries = wrapEx(() -> REFLECT.method("entries")); + private static final ReflectMethod size = wrapEx(() -> REFLECT.method("size")); + private static final ReflectMethod contains = wrapEx(() -> REFLECT.method("contains", String.class)); + private static final ReflectMethod containsStringInt = wrapEx(() -> REFLECT.method("contains", String.class, int.class)); public CompoundTag() { this(wrapReflectEx(() -> CONSTRUCTOR.instantiate())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java index 6bee944..8489e11 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/ListTag.java @@ -1,7 +1,7 @@ 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.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectMethod; @@ -9,9 +9,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ListTag extends CollectionTag { - public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.ListTag")); - public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor()); - private static final ReflectMethod getCompound = wrapEx(() -> MAPPING.mojMethod("getCompound", int.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.ListTag")); + public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor()); + private static final ReflectMethod getCompound = wrapEx(() -> REFLECT.method("getCompound", int.class)); public CompoundTag getCompound(int index) { return wrap(wrapReflectEx(() -> getCompound.invoke(__getRuntimeInstance(), index)), CompoundTag.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtAccounter.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtAccounter.java index b536567..ab99a77 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtAccounter.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtAccounter.java @@ -1,18 +1,15 @@ 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.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; 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")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.NbtAccounter")); + private static final ReflectMethod unlimitedHeap = wrapEx(() -> REFLECT.method("unlimitedHeap")); private NbtAccounter(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtIo.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtIo.java index 7e06ae9..3c7e7d5 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtIo.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/NbtIo.java @@ -1,7 +1,7 @@ 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.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -10,9 +10,9 @@ import java.nio.file.Path; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class NbtIo extends ReflectWrapper { - public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo")); - private static final ReflectMethod readCompressed = wrapEx(() -> MAPPING.mojMethod("readCompressed", Path.class, NbtAccounter.MAPPING)); - private static final ReflectMethod writeCompressed = wrapEx(() -> MAPPING.mojMethod("writeCompressed", CompoundTag.MAPPING, Path.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.NbtIo")); + private static final ReflectMethod readCompressed = wrapEx(() -> REFLECT.method("readCompressed", Path.class, NbtAccounter.REFLECT.get())); + private static final ReflectMethod writeCompressed = wrapEx(() -> REFLECT.method("writeCompressed", CompoundTag.REFLECT.get(), Path.class)); private NbtIo(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/StringTag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/StringTag.java index 3a7f79a..42cd355 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/StringTag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/StringTag.java @@ -1,13 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; + import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; - public class StringTag extends ReflectWrapper implements Tag { - public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.StringTag")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.StringTag")); protected StringTag(Object nms) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/Tag.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/Tag.java index 7ad5966..b5e5274 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/Tag.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/Tag.java @@ -1,23 +1,23 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; -import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; -import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; - +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; 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.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI; +import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; +import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; + @ConcreteWrapper(Tag.__concrete.class) public interface Tag extends ReflectWrapperI { - ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.Tag")); - ReflectMethod getAsString = wrapEx(() -> MAPPING.mojMethod("getAsString")); - ReflectField TAG_LIST = wrapEx(() -> MAPPING.mojField("TAG_LIST")); - ReflectField TAG_COMPOUND = wrapEx(() -> MAPPING.mojField("TAG_COMPOUND")); - ReflectField TAG_ANY_NUMERIC = wrapEx(() -> MAPPING.mojField("TAG_ANY_NUMERIC")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.Tag")); + ReflectMethod getAsString = wrapEx(() -> REFLECT.method("getAsString")); + ReflectField TAG_LIST = wrapEx(() -> REFLECT.field("TAG_LIST")); + ReflectField TAG_COMPOUND = wrapEx(() -> REFLECT.field("TAG_COMPOUND")); + ReflectField TAG_ANY_NUMERIC = wrapEx(() -> REFLECT.field("TAG_ANY_NUMERIC")); default String getAsString() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java index a220969..0565616 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/FriendlyByteBuf.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.netty.ByteBuf; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectMethod; @@ -9,9 +10,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class FriendlyByteBuf extends ByteBuf { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.FriendlyByteBuf")); - private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ByteBuf.REFLECT.get())); - private static final ReflectMethod writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.FriendlyByteBuf")); + private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(ByteBuf.REFLECT.get())); + private static final ReflectMethod writeUtf = wrapEx(() -> REFLECT.method("writeUtf", String.class)); public FriendlyByteBuf(ByteBuf parent) { this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(parent)))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/chat/Component.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/chat/Component.java index 2bf2f3b..38bbd48 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/chat/Component.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/chat/Component.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI; @@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; @ConcreteWrapper(Component.__concrete.class) public interface Component extends ReflectWrapperI { - NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.chat.Component")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.chat.Component")); class __concrete extends ReflectWrapper implements Component { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java index 8a7a457..558c880 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundCustomPayloadPacket.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.custom.CustomPacketPayload; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Packet { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket")); - private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(CustomPacketPayload.MAPPING.runtimeClass())); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket")); + private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(CustomPacketPayload.REFLECT.get())); protected ClientboundCustomPayloadPacket(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java index 905abd1..7acbb08 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/ClientboundGameEventPacket.java @@ -1,18 +1,19 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectField; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ClientboundGameEventPacket extends ReflectWrapper implements Packet { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket")); - private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(Type.MAPPING.runtimeClass(), float.class)); - private static final ReflectField FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE")); - private static final ReflectField FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket")); + private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Type.REFLECT.get(), float.class)); + private static final ReflectField FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> REFLECT.field("RAIN_LEVEL_CHANGE")); + private static final ReflectField FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> REFLECT.field("THUNDER_LEVEL_CHANGE")); public static Type RAIN_LEVEL_CHANGE() { return wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class); @@ -31,7 +32,7 @@ public class ClientboundGameEventPacket extends ReflectWrapper implements Packet public static class Type extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket$Type")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket$Type")); protected Type(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/Packet.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/Packet.java index be8f602..6544afb 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/Packet.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/Packet.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI; @@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; @ConcreteWrapper(Packet.__concrete.class) public interface Packet extends ReflectWrapperI { - NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.Packet")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.Packet")); class __concrete extends ReflectWrapper implements Packet { protected __concrete(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/BrandPayload.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/BrandPayload.java index 8085013..7ef1576 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/BrandPayload.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/BrandPayload.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.custom; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -8,8 +9,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class BrandPayload extends ReflectWrapper implements CustomPacketPayload { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.common.custom.BrandPayload")); - private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(String.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.common.custom.BrandPayload")); + private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(String.class)); public BrandPayload(String brand) { this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(brand))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/CustomPacketPayload.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/CustomPacketPayload.java index 217703c..ccf8127 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/CustomPacketPayload.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/network/protocol/custom/CustomPacketPayload.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.custom; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI; @@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; @ConcreteWrapper(CustomPacketPayload.__concrete.class) public interface CustomPacketPayload extends ReflectWrapperI { - NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.common.custom.CustomPacketPayload")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.common.custom.CustomPacketPayload")); class __concrete extends ReflectWrapper implements CustomPacketPayload { protected __concrete(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/resources/ResourceLocation.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/resources/ResourceLocation.java index 3936905..8859da8 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/resources/ResourceLocation.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/resources/ResourceLocation.java @@ -1,12 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class ResourceLocation extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.resources.ResourceLocation")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.resources.ResourceLocation")); protected ResourceLocation(Object obj) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ChunkMap.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ChunkMap.java index 48e2e8d..9c76b31 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ChunkMap.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ChunkMap.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ChunkMap extends ChunkStorage { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ChunkMap")); - private static final ReflectField FIELD_level = wrapEx(() -> MAPPING.mojField("level")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ChunkMap")); + private static final ReflectField FIELD_level = wrapEx(() -> REFLECT.field("level")); public final ServerLevel level; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java index 4dae197..b9cb534 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedPlayerList.java @@ -1,11 +1,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class DedicatedPlayerList extends PlayerList { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedPlayerList")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.DedicatedPlayerList")); protected DedicatedPlayerList(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServer.java index 0b62b0a..525d893 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServer.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class DedicatedServer extends MinecraftServer { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedServer")); - private static final ReflectMethod getLevelIdName = wrapEx(() -> MAPPING.mojMethod("getLevelIdName")); - private static final ReflectMethod getProperties = wrapEx(() -> MAPPING.mojMethod("getProperties")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.DedicatedServer")); + private static final ReflectMethod getLevelIdName = wrapEx(() -> REFLECT.method("getLevelIdName")); + private static final ReflectMethod getProperties = wrapEx(() -> REFLECT.method("getProperties")); public String getLevelIdName() { return (String) wrapReflectEx(() -> getLevelIdName.invoke(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServerProperties.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServerProperties.java index ec94fe6..4c424d9 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServerProperties.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/DedicatedServerProperties.java @@ -1,11 +1,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class DedicatedServerProperties extends Settings { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedServerProperties")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.DedicatedServerProperties")); protected DedicatedServerProperties(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/MinecraftServer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/MinecraftServer.java index 42a5caa..d8b9254 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/MinecraftServer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/MinecraftServer.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -8,8 +9,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class MinecraftServer extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.MinecraftServer")); - private static final ReflectMethod getPlayerList = wrapEx(() -> MAPPING.mojMethod("getPlayerList")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.MinecraftServer")); + private static final ReflectMethod getPlayerList = wrapEx(() -> REFLECT.method("getPlayerList")); public PlayerList getPlayerList() { return wrap(wrapReflectEx(() -> getPlayerList.invoke(__getRuntimeInstance())), PlayerList.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/PlayerList.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/PlayerList.java index e8c08b7..fd27f0b 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/PlayerList.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/PlayerList.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.PlayerDataStorage; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class PlayerList extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.players.PlayerList")); - private static final ReflectField playerIo = wrapEx(() -> MAPPING.mojField("playerIo")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.players.PlayerList")); + private static final ReflectField playerIo = wrapEx(() -> REFLECT.field("playerIo")); public PlayerDataStorage playerIo() { return wrap(wrapReflectEx(() -> playerIo.getValue(__getRuntimeInstance())), PlayerDataStorage.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerChunkCache.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerChunkCache.java index f7737e0..447a500 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerChunkCache.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerChunkCache.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ServerChunkCache extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerChunkCache")); - private static final ReflectField FIELD_chunkMap = wrapEx(() -> MAPPING.mojField("chunkMap")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerChunkCache")); + private static final ReflectField FIELD_chunkMap = wrapEx(() -> REFLECT.field("chunkMap")); public final ChunkMap chunkMap; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerCommonPacketListenerImpl.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerCommonPacketListenerImpl.java index 44d1bbd..15ebaa5 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerCommonPacketListenerImpl.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerCommonPacketListenerImpl.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ServerCommonPacketListenerImpl extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.network.ServerCommonPacketListenerImpl")); - public static final ReflectMethod send = wrapEx(() -> MAPPING.mojMethod("send", Packet.MAPPING)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.network.ServerCommonPacketListenerImpl")); + public static final ReflectMethod send = wrapEx(() -> REFLECT.method("send", Packet.REFLECT.get())); public void send(Packet packet) { wrapReflectEx(() -> send.invoke(__getRuntimeInstance(), unwrap(packet))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerGamePacketListenerImpl.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerGamePacketListenerImpl.java index 17ac09b..afe214c 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerGamePacketListenerImpl.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerGamePacketListenerImpl.java @@ -1,11 +1,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.network.ServerGamePacketListenerImpl")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.network.ServerGamePacketListenerImpl")); protected ServerGamePacketListenerImpl(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerLevel.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerLevel.java index 7035313..8d1f848 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerLevel.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerLevel.java @@ -1,17 +1,18 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProgressListener; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ServerLevel extends Level { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerLevel")); - public static final ReflectMethod save = wrapEx(() -> MAPPING.mojMethod("save", ProgressListener.MAPPING, boolean.class, boolean.class)); - public static final ReflectMethod getChunkSource = wrapEx(() -> MAPPING.mojMethod("getChunkSource")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerLevel")); + public static final ReflectMethod save = wrapEx(() -> REFLECT.method("save", ProgressListener.REFLECT.get(), boolean.class, boolean.class)); + public static final ReflectMethod getChunkSource = wrapEx(() -> REFLECT.method("getChunkSource")); public ServerChunkCache getChunkSource() { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerPlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerPlayer.java index 8ee222f..0fe7051 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerPlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/ServerPlayer.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectMethod; import org.bukkit.entity.Player; @@ -10,10 +11,10 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ServerPlayer extends Entity { // in NMS, ServerPlayer is not a direct subclass of Entity - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerPlayer")); - public static final ReflectField connection = wrapEx(() -> MAPPING.mojField("connection")); - public static final ReflectMethod isTextFilteringEnabled = wrapEx(() -> MAPPING.mojMethod("isTextFilteringEnabled")); - public static final ReflectMethod allowsListing = wrapEx(() -> MAPPING.mojMethod("allowsListing")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerPlayer")); + public static final ReflectField connection = wrapEx(() -> REFLECT.field("connection")); + public static final ReflectMethod isTextFilteringEnabled = wrapEx(() -> REFLECT.method("isTextFilteringEnabled")); + public static final ReflectMethod allowsListing = wrapEx(() -> REFLECT.method("allowsListing")); public boolean isTextFilteringEnabled() { return (boolean) wrapReflectEx(() -> isTextFilteringEnabled.invoke(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/Settings.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/Settings.java index f0fb492..9a10a79 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/Settings.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/server/Settings.java @@ -1,8 +1,9 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import java.util.Properties; @@ -10,8 +11,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Settings extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.Settings")); - public static final ReflectField properties = wrapEx(() -> MAPPING.mojField("properties")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.Settings")); + public static final ReflectField properties = wrapEx(() -> REFLECT.field("properties")); public Properties properties() { return (Properties) wrapReflectEx(() -> properties.getValue(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/util/ProgressListener.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/util/ProgressListener.java index d6c6178..9175bc4 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/util/ProgressListener.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/util/ProgressListener.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.util; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI; @@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; @ConcreteWrapper(ProgressListener.__concrete.class) public interface ProgressListener extends ReflectWrapperI { - NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.util.ProgressListener")); + ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.util.ProgressListener")); class __concrete extends ReflectWrapper implements ProgressListener { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java index 7d16569..4c3fce2 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/AABB.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class AABB extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.AABB")); - private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(double.class, double.class, double.class, double.class, double.class, double.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.phys.AABB")); + private static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(double.class, double.class, double.class, double.class, double.class, double.class)); public AABB(double x1, double y1, double z1, double x2, double y2, double z2) { this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x1, y1, z1, x2, y2, z2))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java index 2e596da..4418e15 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkPos.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectConstructor; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ChunkPos extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.ChunkPos")); - public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.ChunkPos")); + public static final ReflectConstructor CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(int.class, int.class)); public ChunkPos(int x, int z) { this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x, z))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java index 89802e7..8446d79 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java @@ -1,9 +1,10 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -12,8 +13,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ChunkStorage extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.chunk.storage.ChunkStorage")); - private static final ReflectMethod readSync = wrapEx(() -> MAPPING.runtimeReflect().method("readSync", ChunkPos.MAPPING.runtimeReflect().get())); // spigot/paper method + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.chunk.storage.ChunkStorage")); + private static final ReflectMethod readSync = wrapEx(() -> REFLECT.method("readSync", ChunkPos.REFLECT.get())); // spigot/paper method public CompoundTag readSync(ChunkPos pos) { return wrap(wrapReflectEx(() -> readSync.invoke(__getRuntimeInstance(), unwrap(pos))), CompoundTag.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DataVersion.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DataVersion.java index ce70ea9..5c61dff 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DataVersion.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/DataVersion.java @@ -1,6 +1,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -8,9 +9,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class DataVersion extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.storage.DataVersion")); - private static final ReflectMethod getVersion = wrapEx(() -> MAPPING.mojMethod("getVersion")); - private static final ReflectMethod getSeries = wrapEx(() -> MAPPING.mojMethod("getSeries")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.DataVersion")); + private static final ReflectMethod getVersion = wrapEx(() -> REFLECT.method("getVersion")); + private static final ReflectMethod getSeries = wrapEx(() -> REFLECT.method("getSeries")); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Entity.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Entity.java index 16d4624..a78ddc7 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Entity.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Entity.java @@ -1,17 +1,18 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Entity extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.entity.Entity")); - public static final ReflectMethod getBukkitEntity = wrapEx(() -> MAPPING.runtimeReflect().method("getBukkitEntity")); // spigot method - public static final ReflectMethod serializeEntity = wrapEx(() -> MAPPING.runtimeReflect().method("serializeEntity", CompoundTag.MAPPING.runtimeClass())); // paper method + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.entity.Entity")); + public static final ReflectMethod getBukkitEntity = wrapEx(() -> REFLECT.method("getBukkitEntity")); // spigot method + public static final ReflectMethod serializeEntity = wrapEx(() -> REFLECT.method("serializeEntity", CompoundTag.REFLECT.get())); // paper method public org.bukkit.entity.Entity getBukkitEntity() { return (org.bukkit.entity.Entity) wrapReflectEx(() -> getBukkitEntity.invoke(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ItemStack.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ItemStack.java index b95279b..7a87d1d 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ItemStack.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ItemStack.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,9 +10,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ItemStack extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.item.ItemStack")); - private static final ReflectMethod of = wrapEx(() -> MAPPING.mojMethod("of", CompoundTag.MAPPING)); - private static final ReflectMethod save = wrapEx(() -> MAPPING.mojMethod("save", CompoundTag.MAPPING)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.item.ItemStack")); + private static final ReflectMethod of = wrapEx(() -> REFLECT.method("of", CompoundTag.REFLECT.get())); + private static final ReflectMethod save = wrapEx(() -> REFLECT.method("save", CompoundTag.REFLECT.get())); public static ItemStack of(CompoundTag nbt) { return wrap(wrapReflectEx(() -> of.invokeStatic(unwrap(nbt))), ItemStack.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Level.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Level.java index ea77832..19a5b09 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Level.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Level.java @@ -1,18 +1,19 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Level extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.Level")); - public static final ReflectMethod getGameTime = wrapEx(() -> MAPPING.mojMethod("getGameTime")); - public static final ReflectMethod getFreeMapId = wrapEx(() -> MAPPING.mojMethod("getFreeMapId")); - public static final ReflectMethod paperConfig = wrapEx(() -> MAPPING.runtimeReflect().method("paperConfig")); // paper method + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.Level")); + public static final ReflectMethod getGameTime = wrapEx(() -> REFLECT.method("getGameTime")); + public static final ReflectMethod getFreeMapId = wrapEx(() -> REFLECT.method("getFreeMapId")); + public static final ReflectMethod paperConfig = wrapEx(() -> REFLECT.method("paperConfig")); // paper method public long getGameTime() { return (long) wrapReflectEx(() -> getGameTime.invoke(__getRuntimeInstance())); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/MapItemSavedData.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/MapItemSavedData.java index 1d91590..bfd69e5 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/MapItemSavedData.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/MapItemSavedData.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class MapItemSavedData extends SavedData { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData")); - public static final ReflectField colors = wrapEx(() -> MAPPING.mojField("colors")); - public static final ReflectField locked = wrapEx(() -> MAPPING.mojField("locked")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData")); + public static final ReflectField colors = wrapEx(() -> REFLECT.field("colors")); + public static final ReflectField locked = wrapEx(() -> REFLECT.field("locked")); protected MapItemSavedData(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java index 26ab073..d00a4bd 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/PlayerDataStorage.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class PlayerDataStorage extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.storage.PlayerDataStorage")); - public static final ReflectMethod getPlayerData = wrapEx(() -> MAPPING.runtimeReflect().method("getPlayerData", String.class)); // Craftbukkit method + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.PlayerDataStorage")); + public static final ReflectMethod getPlayerData = wrapEx(() -> REFLECT.method("getPlayerData", String.class)); // Craftbukkit method /** * @param playerId UUID of a player as it is used to name the player data file (UUID.toString()) diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/SavedData.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/SavedData.java index 7b9f511..6b23c3f 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/SavedData.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/SavedData.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; -import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; +import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class SavedData extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.SavedData")); - private static final ReflectMethod setDirty = wrapEx(() -> MAPPING.mojMethod("setDirty")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.saveddata.SavedData")); + private static final ReflectMethod setDirty = wrapEx(() -> REFLECT.method("setDirty")); protected SavedData(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Vec3.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Vec3.java index 18096f5..a1833c9 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Vec3.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/Vec3.java @@ -1,12 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class Vec3 extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.Vec3")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.phys.Vec3")); protected Vec3(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/VoxelShape.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/VoxelShape.java index c14ecf2..6437505 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/VoxelShape.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/VoxelShape.java @@ -1,12 +1,13 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; -import fr.pandacube.lib.paper.reflect.NMSReflect; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; public class VoxelShape extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.shapes.VoxelShape")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.phys.shapes.VoxelShape")); protected VoxelShape(Object obj) { super(obj); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/BambooStalkBlock.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/BambooStalkBlock.java index ec5fbfc..2509b82 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/BambooStalkBlock.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/BambooStalkBlock.java @@ -1,15 +1,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectField; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class BambooStalkBlock extends Block { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.BambooStalkBlock")); - public static final ReflectField COLLISION_SHAPE = wrapEx(() -> MAPPING.mojField("COLLISION_SHAPE")); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.block.BambooStalkBlock")); + public static final ReflectField COLLISION_SHAPE = wrapEx(() -> REFLECT.field("COLLISION_SHAPE")); public static VoxelShape COLLISION_SHAPE() { return wrap(wrapReflectEx(COLLISION_SHAPE::getStaticValue), VoxelShape.class); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/Block.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/Block.java index eeb04a7..9505d86 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/Block.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/block/Block.java @@ -1,7 +1,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block; -import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; @@ -9,8 +10,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class Block extends ReflectWrapper { - public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.Block")); - private static final ReflectMethod box = wrapEx(() -> MAPPING.mojMethod("box", double.class, double.class, double.class, double.class, double.class, double.class)); + public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.block.Block")); + private static final ReflectMethod box = wrapEx(() -> REFLECT.method("box", double.class, double.class, double.class, double.class, double.class, double.class)); public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/PaperAdventure.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/PaperAdventure.java index 46fcfba..8905815 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/PaperAdventure.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/paper/PaperAdventure.java @@ -11,7 +11,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class PaperAdventure extends ReflectWrapper { public static final ReflectClass REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.adventure.PaperAdventure")); - private static final ReflectMethod asAdventure = wrapEx(() -> REFLECT.method("asAdventure", Component.MAPPING.runtimeClass())); + private static final ReflectMethod asAdventure = wrapEx(() -> REFLECT.method("asAdventure", Component.REFLECT.get())); public static net.kyori.adventure.text.Component asAdventure(Component component) { return (net.kyori.adventure.text.Component) wrapReflectEx(() -> asAdventure.invokeStatic(unwrap(component)));