Compare commits
2 Commits
0ff2ae1296
...
7f56645ba5
Author | SHA1 | Date | |
---|---|---|---|
7f56645ba5 | |||
827c13887c |
@ -89,14 +89,6 @@
|
|||||||
<artifactId>paper-mojangapi</artifactId>
|
<artifactId>paper-mojangapi</artifactId>
|
||||||
<version>${paper.version}-SNAPSHOT</version>
|
<version>${paper.version}-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Needed to read obfuscation mapping file. Already included in Paper -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.fabricmc</groupId>
|
|
||||||
<artifactId>mapping-io</artifactId>
|
|
||||||
<version>0.5.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -366,7 +366,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
*/
|
*/
|
||||||
public Vector tryGetMinecraftVec3Argument(CommandContext<CommandSourceStack> context, String argument,
|
public Vector tryGetMinecraftVec3Argument(CommandContext<CommandSourceStack> context, String argument,
|
||||||
Vector deflt) {
|
Vector deflt) {
|
||||||
return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(),
|
return tryGetArgument(context, argument, Coordinates.REFLECT.get(),
|
||||||
nmsCoordinate -> CraftVector.toBukkit(
|
nmsCoordinate -> CraftVector.toBukkit(
|
||||||
ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getPosition(context.getSource())
|
ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getPosition(context.getSource())
|
||||||
),
|
),
|
||||||
|
@ -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<String, ClassMapping> CLASSES_BY_OBF = new TreeMap<>();
|
|
||||||
/* package */ static final Map<String, ClassMapping> 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<ClassMapping> 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<ClassMapping> 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<ClassMapping> 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("<!DOCTYPE html><html><head>\n"
|
|
||||||
+ "<title>" + title + "</title>\n"
|
|
||||||
+ """
|
|
||||||
<style>
|
|
||||||
html {
|
|
||||||
background-color: #2F2F2F;
|
|
||||||
color: white;
|
|
||||||
font-size: 14px;
|
|
||||||
font-family: Consolas, monospace;
|
|
||||||
}
|
|
||||||
a:not(.cl) {
|
|
||||||
color: #1290C3;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 100%;
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
tr:nth-child(2n) {
|
|
||||||
background-color: #373737;
|
|
||||||
}
|
|
||||||
tr:hover {
|
|
||||||
background-color: #555;
|
|
||||||
}
|
|
||||||
tr > *:first-child {
|
|
||||||
padding-right: .5em;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
b.pu {
|
|
||||||
color: #0C0;
|
|
||||||
}
|
|
||||||
b.pt {
|
|
||||||
color: #FC0;
|
|
||||||
}
|
|
||||||
b.pv {
|
|
||||||
color: #F00;
|
|
||||||
}
|
|
||||||
b.pk {
|
|
||||||
color: #66F;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding-top: 0;
|
|
||||||
padding-bottom: 0;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
font-size: 1.1em;
|
|
||||||
border-top: solid 1px white;
|
|
||||||
}
|
|
||||||
.kw {
|
|
||||||
color: #CC6C1D;
|
|
||||||
}
|
|
||||||
.cl {
|
|
||||||
color: #1290C3;
|
|
||||||
}
|
|
||||||
.mtd {
|
|
||||||
color: #1EB540;
|
|
||||||
}
|
|
||||||
.fld {
|
|
||||||
color: #8DDAF8;
|
|
||||||
}
|
|
||||||
.st {
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
.st.fn {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head><body>
|
|
||||||
"""
|
|
||||||
+ "<h1>" + title + "</h1>\n"
|
|
||||||
+ """
|
|
||||||
<p>
|
|
||||||
<b>C</b>: <span class='kw'>class</span>
|
|
||||||
<b>E</b>: <span class='kw'>enum</span>
|
|
||||||
<b>I</b>: <span class='kw'>interface</span>
|
|
||||||
<b>@</b>: <span class='kw'>@interface</span>
|
|
||||||
<b>R</b>: <span class='kw'>record</span><br>
|
|
||||||
<b>●</b>: field
|
|
||||||
<b>c</b>: constructor
|
|
||||||
<b>⬤</b>: method<br>
|
|
||||||
<b class='pu'>⬤</b>: <span class='kw'>public</span>
|
|
||||||
<b class='pt'>⬤</b>: <span class='kw'>protected</span>
|
|
||||||
<b class='pk'>⬤</b>: package
|
|
||||||
<b class='pv'>⬤</b>: <span class='kw'>private</span><br>
|
|
||||||
<sup>S</sup>: <span class='kw'>static</span>
|
|
||||||
<sup>A</sup>: <span class='kw'>abstract</span>
|
|
||||||
<sup>F</sup>: <span class='kw'>final</span>
|
|
||||||
</p>
|
|
||||||
<table>
|
|
||||||
""");
|
|
||||||
out.println("<tr><th>ns</th><th>" + OBF_NAMESPACE + "</th><th>" + MOJ_NAMESPACE + "</th></tr>");
|
|
||||||
for (ClassMapping clazz : CLASSES_BY_OBF.values()) {
|
|
||||||
clazz.printHTML(out);
|
|
||||||
}
|
|
||||||
out.println("</table><p>Generated by <a href='https://github.com/marcbal'>marcbal</a>"
|
|
||||||
+ " using <a href='https://github.com/PandacubeFr/PandaLib/blob/master/Paper/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java'>this tool</a>"
|
|
||||||
+ " running on <a href='https://papermc.io/'>" + Bukkit.getName() + "</a> version " + Bukkit.getVersion() + "</p>"
|
|
||||||
+ "</body></html>");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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<MethodId, MemberMapping<MethodId, ReflectMethod<?>>> methodsByObf = new TreeMap<>();
|
|
||||||
private final Map<MethodId, MemberMapping<MethodId, ReflectMethod<?>>> methodsByMoj = new TreeMap<>();
|
|
||||||
private final Map<String, MemberMapping<String, ReflectField<?>>> fieldsByObf = new TreeMap<>();
|
|
||||||
private final Map<String, MemberMapping<String, ReflectField<?>>> 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<MethodId, ReflectMethod<?>> 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<String, ReflectField<?>> 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 "<a href='#c" + id + "'" + htmlTitle + " class='cl'>" + classSimpleName + "</a>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* package */ NMSTypeWrapper toType(boolean obf) {
|
|
||||||
return new NMSTypeWrapper(obf ? obfName : mojName, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void printHTML(PrintStream out) {
|
|
||||||
String modifiersHTML = classModifiersToHTML(runtimeClass());
|
|
||||||
out.println("<tr id='c" + id + "'><th>" + modifiersHTML + "</th><th>" + nameToHTML(true) + "</th><th>" + nameToHTML(false) + "</th></tr>");
|
|
||||||
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 + ".") : "") + "<b class='cl'>" + classSimpleName + "</b>";
|
|
||||||
|
|
||||||
NMSTypeWrapper superClass = superClass(obf);
|
|
||||||
String superClassHTML = superClass == null ? "" : (" <span class='kw'>extends</span> " + superClass.toHTML(obf));
|
|
||||||
|
|
||||||
List<NMSTypeWrapper> superInterfaces = superInterfaces(obf);
|
|
||||||
String superInterfacesHTML = superInterfaces.isEmpty() ? ""
|
|
||||||
: (" <span class='kw'>implements</span> " + 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<NMSTypeWrapper> superInterfaces(boolean obf) {
|
|
||||||
Class<?>[] interfaces = runtimeClass().getInterfaces();
|
|
||||||
List<NMSTypeWrapper> 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<NMSTypeWrapper> obfParams = new ArrayList<>();
|
|
||||||
List<NMSTypeWrapper> 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("<tr>"
|
|
||||||
+ "<td>" + elementModifiersToHTML("c", ct.getModifiers()) + "</td>"
|
|
||||||
+ "<td><b class='mtd'>" + classObfSimpleName + "</b>(" + obfParams.stream().map(t -> t.toHTML(true)).collect(Collectors.joining(", ")) + ")</td>"
|
|
||||||
+ "<td><b class='mtd'>" + classMojSimpleName + "</b>(" + mojParams.stream().map(t -> t.toHTML(false)).collect(Collectors.joining(", ")) + ")</td>"
|
|
||||||
+ "</tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private record MethodId(String name, List<NMSTypeWrapper> parametersType) implements Comparable<MethodId> {
|
|
||||||
@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 "<span class='" + cl + "'>" + name + "</span>(" + paramsHTML + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
String paramsStr = parametersType.stream().map(NMSTypeWrapper::toString).collect(Collectors.joining(", "));
|
|
||||||
return name + "(" + paramsStr + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private record MemberDesc<I extends Comparable<I>>(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 = "<span class='" + cl + "'>" + n + "</span>";
|
|
||||||
}
|
|
||||||
return returnType.toHTML(isObfClass) + " " + identifierHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MemberDesc<MethodId> 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<NMSTypeWrapper> 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<String> 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<I extends Comparable<I>, R extends ReflectMember<?, ?, ?, ?>> {
|
|
||||||
private final String htmlTypeChar;
|
|
||||||
/* package */ final MemberDesc<I> obfDesc, mojDesc;
|
|
||||||
/* package */ ClassMapping declaringClass;
|
|
||||||
private MemberMapping(String htmlType, MemberDesc<I> obfDesc, MemberDesc<I> 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("<tr>"
|
|
||||||
+ "<td>" + elementModifiersToHTML(htmlTypeChar, mod) + "</td>"
|
|
||||||
+ "<td>" + obfDesc.toHTML(true, isStatic, isFinal) + "</td>"
|
|
||||||
+ "<td>" + mojDesc.toHTML(false, isStatic, isFinal) + "</td>"
|
|
||||||
+ "</tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* package */ MemberDesc<I> 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<MethodId, ReflectMethod<?>> 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<String, ReflectField<?>> 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 = "<b class='";
|
|
||||||
|
|
||||||
if (Modifier.isPublic(elModifiers))
|
|
||||||
html += "pu";
|
|
||||||
else if (Modifier.isProtected(elModifiers))
|
|
||||||
html += "pt";
|
|
||||||
else if (Modifier.isPrivate(elModifiers))
|
|
||||||
html += "pv";
|
|
||||||
else
|
|
||||||
html += "pk";
|
|
||||||
|
|
||||||
html += "'>" + elementHTMLType + "</b>";
|
|
||||||
|
|
||||||
boolean isStatic = Modifier.isStatic(elModifiers);
|
|
||||||
boolean isAbstract = Modifier.isAbstract(elModifiers);
|
|
||||||
boolean isFinal = Modifier.isFinal(elModifiers);
|
|
||||||
|
|
||||||
if (isStatic || isAbstract || isFinal) {
|
|
||||||
html += "<sup>";
|
|
||||||
if (isStatic)
|
|
||||||
html += "S";
|
|
||||||
if (isAbstract)
|
|
||||||
html += "A";
|
|
||||||
if (isFinal)
|
|
||||||
html += "F";
|
|
||||||
html += "</sup>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ● (field)
|
|
||||||
// ⬤ (method)
|
|
||||||
|
|
||||||
}
|
|
@ -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<NMSTypeWrapper> {
|
|
||||||
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 = "<span" + htmlTitle + " class='cl'>" + classSimpleName + "</span>";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
typeHTML = "<span class='" + (isPrimitive() ? "kw" : "cl") + "'>" + classSimpleName + "</span>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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<NMSTypeWrapper> toTypeList(List<Object> paramsType) {
|
|
||||||
List<NMSTypeWrapper> 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<NMSTypeWrapper> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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.DetectedVersion;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.SharedConstants;
|
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.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.CommandSourceStack;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
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.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.GameProfileArgument;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ResourceLocationArgument;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ResourceLocationArgument;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Vec3Argument;
|
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.
|
* @throws Exception if a problem occurs when initializing wrapper classes.
|
||||||
*/
|
*/
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
NMSReflect.init();
|
|
||||||
synchronized (PandalibPaperReflect.class) {
|
synchronized (PandalibPaperReflect.class) {
|
||||||
if (isInit)
|
if (isInit)
|
||||||
return;
|
return;
|
||||||
@ -127,76 +122,72 @@ public class PandalibPaperReflect {
|
|||||||
thAcc.catchThrowable(() -> initWrapper(MCTypeRegistry.class, MCTypeRegistry.REFLECT.get()));
|
thAcc.catchThrowable(() -> initWrapper(MCTypeRegistry.class, MCTypeRegistry.REFLECT.get()));
|
||||||
|
|
||||||
// minecraft.commands
|
// minecraft.commands
|
||||||
thAcc.catchThrowable(() -> initWrapper(BlockPosArgument.class, BlockPosArgument.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Commands.class, Commands.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Commands.class, Commands.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CommandSourceStack.class, CommandSourceStack.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(CommandSourceStack.class, CommandSourceStack.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Coordinates.class, Coordinates.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ComponentArgument.class, ComponentArgument.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(GameProfileArgument.class, GameProfileArgument.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Coordinates.class, Coordinates.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ResourceLocationArgument.class, ResourceLocationArgument.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(EntityArgument.class, EntityArgument.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Vec3Argument.class, Vec3Argument.REFLECT.get()));
|
||||||
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()));
|
|
||||||
// minecraft.core
|
// minecraft.core
|
||||||
thAcc.catchThrowable(() -> initWrapper(BlockPos.class, BlockPos.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(BlockPos.class, BlockPos.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Vec3i.class, Vec3i.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Vec3i.class, Vec3i.REFLECT.get()));
|
||||||
// minecraft.nbt
|
// minecraft.nbt
|
||||||
thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CollectionTag.class, CollectionTag.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CompoundTag.class, CompoundTag.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ListTag.class, ListTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ListTag.class, ListTag.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(NbtAccounter.class, NbtAccounter.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(NbtAccounter.class, NbtAccounter.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(NbtIo.class, NbtIo.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(NbtIo.class, NbtIo.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(StringTag.class, StringTag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(StringTag.class, StringTag.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Tag.class, Tag.REFLECT.get()));
|
||||||
// minecraft.network.chat
|
// minecraft.network.chat
|
||||||
thAcc.catchThrowable(() -> initWrapper(Component.class, Component.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Component.class, Component.REFLECT.get()));
|
||||||
// minecraft.network.protocol.custom
|
// minecraft.network.protocol.custom
|
||||||
thAcc.catchThrowable(() -> initWrapper(BrandPayload.class, BrandPayload.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(BrandPayload.class, BrandPayload.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(CustomPacketPayload.class, CustomPacketPayload.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(CustomPacketPayload.class, CustomPacketPayload.REFLECT.get()));
|
||||||
// minecraft.network.protocol
|
// minecraft.network.protocol
|
||||||
thAcc.catchThrowable(() -> initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Packet.class, Packet.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Packet.class, Packet.REFLECT.get()));
|
||||||
// minecraft.network
|
// minecraft.network
|
||||||
thAcc.catchThrowable(() -> initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.REFLECT.get()));
|
||||||
// minecraft.resources
|
// minecraft.resources
|
||||||
thAcc.catchThrowable(() -> initWrapper(ResourceLocation.class, ResourceLocation.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ResourceLocation.class, ResourceLocation.REFLECT.get()));
|
||||||
// minecraft.server
|
// minecraft.server
|
||||||
thAcc.catchThrowable(() -> initWrapper(ChunkMap.class, ChunkMap.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ChunkMap.class, ChunkMap.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(DedicatedServer.class, DedicatedServer.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(DedicatedServer.class, DedicatedServer.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(MinecraftServer.class, MinecraftServer.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(MinecraftServer.class, MinecraftServer.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(PlayerList.class, PlayerList.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(PlayerList.class, PlayerList.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ServerChunkCache.class, ServerChunkCache.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ServerChunkCache.class, ServerChunkCache.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ServerCommonPacketListenerImpl.class, ServerCommonPacketListenerImpl.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ServerCommonPacketListenerImpl.class, ServerCommonPacketListenerImpl.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ServerLevel.class, ServerLevel.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ServerLevel.class, ServerLevel.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ServerPlayer.class, ServerPlayer.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ServerPlayer.class, ServerPlayer.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Settings.class, Settings.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Settings.class, Settings.REFLECT.get()));
|
||||||
// minecraft.util
|
// minecraft.util
|
||||||
thAcc.catchThrowable(() -> initWrapper(ProgressListener.class, ProgressListener.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ProgressListener.class, ProgressListener.REFLECT.get()));
|
||||||
// minecraft.world.block
|
// minecraft.world.block
|
||||||
thAcc.catchThrowable(() -> initWrapper(Block.class, Block.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Block.class, Block.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(BambooStalkBlock.class, BambooStalkBlock.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(BambooStalkBlock.class, BambooStalkBlock.REFLECT.get()));
|
||||||
// minecraft.world
|
// minecraft.world
|
||||||
thAcc.catchThrowable(() -> initWrapper(AABB.class, AABB.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(AABB.class, AABB.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ChunkPos.class, ChunkPos.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ChunkPos.class, ChunkPos.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ChunkStorage.class, ChunkStorage.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ChunkStorage.class, ChunkStorage.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(DataVersion.class, DataVersion.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(DataVersion.class, DataVersion.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Entity.class, Entity.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Entity.class, Entity.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(ItemStack.class, ItemStack.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(ItemStack.class, ItemStack.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Level.class, Level.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Level.class, Level.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(MapItemSavedData.class, MapItemSavedData.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(MapItemSavedData.class, MapItemSavedData.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(PlayerDataStorage.class, PlayerDataStorage.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(PlayerDataStorage.class, PlayerDataStorage.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(SavedData.class, SavedData.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(SavedData.class, SavedData.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(Vec3.class, Vec3.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(Vec3.class, Vec3.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(VoxelShape.class, VoxelShape.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(VoxelShape.class, VoxelShape.REFLECT.get()));
|
||||||
// minecraft
|
// minecraft
|
||||||
thAcc.catchThrowable(() -> initWrapper(DetectedVersion.class, DetectedVersion.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(DetectedVersion.class, DetectedVersion.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(SharedConstants.class, SharedConstants.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(SharedConstants.class, SharedConstants.REFLECT.get()));
|
||||||
thAcc.catchThrowable(() -> initWrapper(WorldVersion.class, WorldVersion.MAPPING.runtimeClass()));
|
thAcc.catchThrowable(() -> initWrapper(WorldVersion.class, WorldVersion.REFLECT.get()));
|
||||||
|
|
||||||
// netty
|
// netty
|
||||||
thAcc.catchThrowable(() -> initWrapper(ByteBuf.class, ByteBuf.REFLECT.get()));
|
thAcc.catchThrowable(() -> initWrapper(ByteBuf.class, ByteBuf.REFLECT.get()));
|
||||||
|
@ -12,7 +12,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class CraftItemStack extends ReflectWrapperTyped<ItemStack> {
|
public class CraftItemStack extends ReflectWrapperTyped<ItemStack> {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("inventory.CraftItemStack"));
|
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 final ReflectMethod<?> asNMSCopy = wrapEx(() -> REFLECT.method("asNMSCopy", ItemStack.class));
|
||||||
|
|
||||||
public static ItemStack asCraftMirror(fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack original) {
|
public static ItemStack asCraftMirror(fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ItemStack original) {
|
||||||
|
@ -15,7 +15,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
public class CraftNamespacedKey extends ReflectWrapper {
|
public class CraftNamespacedKey extends ReflectWrapper {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey"));
|
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<?> 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) {
|
public static ResourceLocation toMinecraft(NamespacedKey key) {
|
||||||
return wrap(wrapReflectEx(() -> toMinecraft.invokeStatic(key)), ResourceLocation.class);
|
return wrap(wrapReflectEx(() -> toMinecraft.invokeStatic(key)), ResourceLocation.class);
|
||||||
|
@ -15,8 +15,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class CraftVector extends ReflectWrapper {
|
public class CraftVector extends ReflectWrapper {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector"));
|
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_Vec3 = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", Vec3.REFLECT.get()));
|
||||||
public static final ReflectMethod<?> toBukkit_BlockPos = ThrowableUtil.wrapEx(() -> REFLECT.method("toBukkit", BlockPos.MAPPING.runtimeClass()));
|
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<?> toNMS = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
||||||
public static final ReflectMethod<?> toBlockPos = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
public static final ReflectMethod<?> toBlockPos = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
|
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper"));
|
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 ReflectField<?> vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand"));
|
||||||
public static final ReflectMethod<?> getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class));
|
public static final ReflectMethod<?> getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class));
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class MCDataConverter extends ReflectWrapper {
|
public class MCDataConverter extends ReflectWrapper {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("ca.spottedleaf.dataconverter.minecraft.MCDataConverter"));
|
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) {
|
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);
|
return wrap(wrapReflectEx(() -> convertTag.invokeStatic(unwrap(type), unwrap(data), fromVersion, toVersion)), CompoundTag.class);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
|
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 fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class DetectedVersion extends ReflectWrapper implements WorldVersion {
|
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) {
|
protected DetectedVersion(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
|
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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class SharedConstants extends ReflectWrapper {
|
public class SharedConstants extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.SharedConstants"));
|
||||||
private static final ReflectMethod<?> getCurrentVersion = wrapEx(() -> MAPPING.mojMethod("getCurrentVersion"));
|
private static final ReflectMethod<?> getCurrentVersion = wrapEx(() -> REFLECT.method("getCurrentVersion"));
|
||||||
private static final ReflectMethod<?> getProtocolVersion = wrapEx(() -> MAPPING.mojMethod("getProtocolVersion"));
|
private static final ReflectMethod<?> getProtocolVersion = wrapEx(() -> REFLECT.method("getProtocolVersion"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
@ -14,8 +14,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(WorldVersion.__concrete.class)
|
@ConcreteWrapper(WorldVersion.__concrete.class)
|
||||||
public interface WorldVersion extends ReflectWrapperI {
|
public interface WorldVersion extends ReflectWrapperI {
|
||||||
ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.WorldVersion"));
|
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.WorldVersion"));
|
||||||
ReflectMethod<?> getDataVersion = wrapEx(() -> MAPPING.mojMethod("getDataVersion"));
|
ReflectMethod<?> getDataVersion = wrapEx(() -> REFLECT.method("getDataVersion"));
|
||||||
|
|
||||||
default DataVersion getDataVersion() {
|
default DataVersion getDataVersion() {
|
||||||
return wrap(wrapReflectEx(() -> getDataVersion.invoke(__getRuntimeInstance())), DataVersion.class);
|
return wrap(wrapReflectEx(() -> getDataVersion.invoke(__getRuntimeInstance())), DataVersion.class);
|
||||||
|
@ -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<ArgumentType<?>> {
|
|
||||||
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<Object> blockPos() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> blockPos.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BlockPosArgument(Object obj) {
|
|
||||||
super(obj);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
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 fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class CommandSourceStack extends ReflectWrapperTyped<io.papermc.paper.command.brigadier.CommandSourceStack> {
|
public class CommandSourceStack extends ReflectWrapperTyped<io.papermc.paper.command.brigadier.CommandSourceStack> {
|
||||||
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) {
|
protected CommandSourceStack(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
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.ReflectField;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Commands extends ReflectWrapper {
|
public class Commands extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.Commands"));
|
||||||
public static final ReflectField<?> dispatcher = wrapEx(() -> MAPPING.mojField("dispatcher"));
|
public static final ReflectField<?> dispatcher = wrapEx(() -> REFLECT.field("dispatcher"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CommandDispatcher<CommandSourceStack> dispatcher() {
|
public CommandDispatcher<CommandSourceStack> dispatcher() {
|
||||||
|
@ -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<ArgumentType<?>> {
|
|
||||||
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<Object> textComponent() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> textComponent.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ComponentArgument(Object obj) {
|
|
||||||
super(obj);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
@ -13,8 +14,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(Coordinates.__concrete.class)
|
@ConcreteWrapper(Coordinates.__concrete.class)
|
||||||
public interface Coordinates extends ReflectWrapperI {
|
public interface Coordinates extends ReflectWrapperI {
|
||||||
NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Coordinates"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.coordinates.Coordinates"));
|
||||||
ReflectMethod<?> getPosition = wrapEx(() -> MAPPING.mojMethod("getPosition", CommandSourceStack.MAPPING));
|
ReflectMethod<?> getPosition = wrapEx(() -> REFLECT.method("getPosition", CommandSourceStack.REFLECT.get()));
|
||||||
|
|
||||||
default Vec3 getPosition(io.papermc.paper.command.brigadier.CommandSourceStack source) {
|
default Vec3 getPosition(io.papermc.paper.command.brigadier.CommandSourceStack source) {
|
||||||
return wrap(wrapReflectEx(() -> getPosition.invoke(__getRuntimeInstance(), source)), Vec3.class);
|
return wrap(wrapReflectEx(() -> getPosition.invoke(__getRuntimeInstance(), source)), Vec3.class);
|
||||||
|
@ -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<ArgumentType<?>> {
|
|
||||||
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<Object> entity() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> entity.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static ArgumentType<Object> entities() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> entities.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static ArgumentType<Object> player() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> player.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static ArgumentType<Object> players() {
|
|
||||||
return (ArgumentType<Object>) wrapReflectEx(() -> players.invokeStatic());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected EntityArgument(Object obj) {
|
|
||||||
super(obj);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<Entity> findEntities(BukkitBrigadierCommandSource source) {
|
|
||||||
return wrapList((List<Object>) 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<ServerPlayer> findPlayers(BukkitBrigadierCommandSource source) {
|
|
||||||
return wrapList((List<Object>) 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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.GameProfileArgument"));
|
||||||
private static final ReflectMethod<?> gameProfile = wrapEx(() -> MAPPING.mojMethod("gameProfile"));
|
private static final ReflectMethod<?> gameProfile = wrapEx(() -> REFLECT.method("gameProfile"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> gameProfile() {
|
public static ArgumentType<Object> gameProfile() {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.ResourceLocationArgument"));
|
||||||
private static final ReflectMethod<?> id = wrapEx(() -> MAPPING.mojMethod("id"));
|
private static final ReflectMethod<?> id = wrapEx(() -> REFLECT.method("id"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> id() {
|
public static ArgumentType<Object> id() {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));
|
||||||
private static final ReflectMethod<?> vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class));
|
private static final ReflectMethod<?> vec3 = wrapEx(() -> REFLECT.method("vec3", boolean.class));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> vec3(boolean centerIntegers) {
|
public static ArgumentType<Object> vec3(boolean centerIntegers) {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class BlockPos extends Vec3i {
|
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) {
|
protected BlockPos(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Vec3i extends ReflectWrapper {
|
public class Vec3i extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.core.Vec3i"));
|
||||||
public static final ReflectMethod<?> getX = wrapEx(() -> MAPPING.mojMethod("getX"));
|
public static final ReflectMethod<?> getX = wrapEx(() -> REFLECT.method("getX"));
|
||||||
public static final ReflectMethod<?> getY = wrapEx(() -> MAPPING.mojMethod("getY"));
|
public static final ReflectMethod<?> getY = wrapEx(() -> REFLECT.method("getY"));
|
||||||
public static final ReflectMethod<?> getZ = wrapEx(() -> MAPPING.mojMethod("getZ"));
|
public static final ReflectMethod<?> getZ = wrapEx(() -> REFLECT.method("getZ"));
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return (int) wrapReflectEx(() -> getX.invoke(__getRuntimeInstance()));
|
return (int) wrapReflectEx(() -> getX.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
@ -9,7 +9,7 @@ import java.util.AbstractList;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class CollectionTag extends ReflectWrapperTyped<AbstractList<?>> implements Tag {
|
public class CollectionTag extends ReflectWrapperTyped<AbstractList<?>> 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() {
|
public int size() {
|
||||||
|
@ -1,60 +1,60 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
|
||||||
|
|
||||||
public class CompoundTag extends ReflectWrapper implements Tag {
|
public class CompoundTag extends ReflectWrapper implements Tag {
|
||||||
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.CompoundTag"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.CompoundTag"));
|
||||||
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor());
|
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor());
|
||||||
private static final ReflectMethod<?> putBoolean = wrapEx(() -> MAPPING.mojMethod("putBoolean", String.class, boolean.class));
|
private static final ReflectMethod<?> putBoolean = wrapEx(() -> REFLECT.method("putBoolean", String.class, boolean.class));
|
||||||
private static final ReflectMethod<?> putByte = wrapEx(() -> MAPPING.mojMethod("putByte", String.class, byte.class));
|
private static final ReflectMethod<?> putByte = wrapEx(() -> REFLECT.method("putByte", String.class, byte.class));
|
||||||
private static final ReflectMethod<?> putByteArray = wrapEx(() -> MAPPING.mojMethod("putByteArray", String.class, byte[].class));
|
private static final ReflectMethod<?> putByteArray = wrapEx(() -> REFLECT.method("putByteArray", String.class, byte[].class));
|
||||||
private static final ReflectMethod<?> putByteArray_List = wrapEx(() -> MAPPING.mojMethod("putByteArray", String.class, List.class));
|
private static final ReflectMethod<?> putByteArray_List = wrapEx(() -> REFLECT.method("putByteArray", String.class, List.class));
|
||||||
private static final ReflectMethod<?> putDouble = wrapEx(() -> MAPPING.mojMethod("putDouble", String.class, double.class));
|
private static final ReflectMethod<?> putDouble = wrapEx(() -> REFLECT.method("putDouble", String.class, double.class));
|
||||||
private static final ReflectMethod<?> putFloat = wrapEx(() -> MAPPING.mojMethod("putFloat", String.class, float.class));
|
private static final ReflectMethod<?> putFloat = wrapEx(() -> REFLECT.method("putFloat", String.class, float.class));
|
||||||
private static final ReflectMethod<?> putInt = wrapEx(() -> MAPPING.mojMethod("putInt", String.class, int.class));
|
private static final ReflectMethod<?> putInt = wrapEx(() -> REFLECT.method("putInt", String.class, int.class));
|
||||||
private static final ReflectMethod<?> putIntArray = wrapEx(() -> MAPPING.mojMethod("putIntArray", String.class, int[].class));
|
private static final ReflectMethod<?> putIntArray = wrapEx(() -> REFLECT.method("putIntArray", String.class, int[].class));
|
||||||
private static final ReflectMethod<?> putIntArray_List = wrapEx(() -> MAPPING.mojMethod("putIntArray", String.class, List.class));
|
private static final ReflectMethod<?> putIntArray_List = wrapEx(() -> REFLECT.method("putIntArray", String.class, List.class));
|
||||||
private static final ReflectMethod<?> putString = wrapEx(() -> MAPPING.mojMethod("putString", String.class, String.class));
|
private static final ReflectMethod<?> putString = wrapEx(() -> REFLECT.method("putString", String.class, String.class));
|
||||||
private static final ReflectMethod<?> putUUID = wrapEx(() -> MAPPING.mojMethod("putUUID", String.class, UUID.class));
|
private static final ReflectMethod<?> putUUID = wrapEx(() -> REFLECT.method("putUUID", String.class, UUID.class));
|
||||||
private static final ReflectMethod<?> putLong = wrapEx(() -> MAPPING.mojMethod("putLong", String.class, long.class));
|
private static final ReflectMethod<?> putLong = wrapEx(() -> REFLECT.method("putLong", String.class, long.class));
|
||||||
private static final ReflectMethod<?> putLongArray = wrapEx(() -> MAPPING.mojMethod("putLongArray", String.class, long[].class));
|
private static final ReflectMethod<?> putLongArray = wrapEx(() -> REFLECT.method("putLongArray", String.class, long[].class));
|
||||||
private static final ReflectMethod<?> putLongArray_List = wrapEx(() -> MAPPING.mojMethod("putLongArray", String.class, List.class));
|
private static final ReflectMethod<?> putLongArray_List = wrapEx(() -> REFLECT.method("putLongArray", String.class, List.class));
|
||||||
private static final ReflectMethod<?> putShort = wrapEx(() -> MAPPING.mojMethod("putShort", String.class, short.class));
|
private static final ReflectMethod<?> putShort = wrapEx(() -> REFLECT.method("putShort", String.class, short.class));
|
||||||
private static final ReflectMethod<?> put = wrapEx(() -> MAPPING.mojMethod("put", String.class, Tag.MAPPING));
|
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<?> getTagType = wrapEx(() -> REFLECT.method("getTagType", String.class));
|
||||||
private static final ReflectMethod<?> getByte = wrapEx(() -> MAPPING.mojMethod("getByte", String.class));
|
private static final ReflectMethod<?> getByte = wrapEx(() -> REFLECT.method("getByte", String.class));
|
||||||
private static final ReflectMethod<?> getShort = wrapEx(() -> MAPPING.mojMethod("getShort", String.class));
|
private static final ReflectMethod<?> getShort = wrapEx(() -> REFLECT.method("getShort", String.class));
|
||||||
private static final ReflectMethod<?> getInt = wrapEx(() -> MAPPING.mojMethod("getInt", String.class));
|
private static final ReflectMethod<?> getInt = wrapEx(() -> REFLECT.method("getInt", String.class));
|
||||||
private static final ReflectMethod<?> getLong = wrapEx(() -> MAPPING.mojMethod("getLong", String.class));
|
private static final ReflectMethod<?> getLong = wrapEx(() -> REFLECT.method("getLong", String.class));
|
||||||
private static final ReflectMethod<?> getFloat = wrapEx(() -> MAPPING.mojMethod("getFloat", String.class));
|
private static final ReflectMethod<?> getFloat = wrapEx(() -> REFLECT.method("getFloat", String.class));
|
||||||
private static final ReflectMethod<?> getDouble = wrapEx(() -> MAPPING.mojMethod("getDouble", String.class));
|
private static final ReflectMethod<?> getDouble = wrapEx(() -> REFLECT.method("getDouble", String.class));
|
||||||
private static final ReflectMethod<?> getString = wrapEx(() -> MAPPING.mojMethod("getString", String.class));
|
private static final ReflectMethod<?> getString = wrapEx(() -> REFLECT.method("getString", String.class));
|
||||||
private static final ReflectMethod<?> getByteArray = wrapEx(() -> MAPPING.mojMethod("getByteArray", String.class));
|
private static final ReflectMethod<?> getByteArray = wrapEx(() -> REFLECT.method("getByteArray", String.class));
|
||||||
private static final ReflectMethod<?> getIntArray = wrapEx(() -> MAPPING.mojMethod("getIntArray", String.class));
|
private static final ReflectMethod<?> getIntArray = wrapEx(() -> REFLECT.method("getIntArray", String.class));
|
||||||
private static final ReflectMethod<?> getLongArray = wrapEx(() -> MAPPING.mojMethod("getLongArray", String.class));
|
private static final ReflectMethod<?> getLongArray = wrapEx(() -> REFLECT.method("getLongArray", String.class));
|
||||||
private static final ReflectMethod<?> getCompound = wrapEx(() -> MAPPING.mojMethod("getCompound", String.class));
|
private static final ReflectMethod<?> getCompound = wrapEx(() -> REFLECT.method("getCompound", String.class));
|
||||||
private static final ReflectMethod<?> getBoolean = wrapEx(() -> MAPPING.mojMethod("getBoolean", String.class));
|
private static final ReflectMethod<?> getBoolean = wrapEx(() -> REFLECT.method("getBoolean", String.class));
|
||||||
private static final ReflectMethod<?> getList = wrapEx(() -> MAPPING.mojMethod("getList", String.class, int.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<?> get = wrapEx(() -> REFLECT.method("get", String.class));
|
||||||
private static final ReflectMethod<?> getAllKeys = wrapEx(() -> MAPPING.mojMethod("getAllKeys"));
|
private static final ReflectMethod<?> getAllKeys = wrapEx(() -> REFLECT.method("getAllKeys"));
|
||||||
private static final ReflectMethod<?> entries = wrapEx(() -> MAPPING.mojMethod("entries"));
|
private static final ReflectMethod<?> entries = wrapEx(() -> REFLECT.method("entries"));
|
||||||
private static final ReflectMethod<?> size = wrapEx(() -> MAPPING.mojMethod("size"));
|
private static final ReflectMethod<?> size = wrapEx(() -> REFLECT.method("size"));
|
||||||
private static final ReflectMethod<?> contains = wrapEx(() -> MAPPING.mojMethod("contains", String.class));
|
private static final ReflectMethod<?> contains = wrapEx(() -> REFLECT.method("contains", String.class));
|
||||||
private static final ReflectMethod<?> containsStringInt = wrapEx(() -> MAPPING.mojMethod("contains", String.class, int.class));
|
private static final ReflectMethod<?> containsStringInt = wrapEx(() -> REFLECT.method("contains", String.class, int.class));
|
||||||
|
|
||||||
public CompoundTag() {
|
public CompoundTag() {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate()));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate()));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ListTag extends CollectionTag {
|
public class ListTag extends CollectionTag {
|
||||||
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.ListTag"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.ListTag"));
|
||||||
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor());
|
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor());
|
||||||
private static final ReflectMethod<?> getCompound = wrapEx(() -> MAPPING.mojMethod("getCompound", int.class));
|
private static final ReflectMethod<?> getCompound = wrapEx(() -> REFLECT.method("getCompound", int.class));
|
||||||
|
|
||||||
public CompoundTag getCompound(int index) {
|
public CompoundTag getCompound(int index) {
|
||||||
return wrap(wrapReflectEx(() -> getCompound.invoke(__getRuntimeInstance(), index)), CompoundTag.class);
|
return wrap(wrapReflectEx(() -> getCompound.invoke(__getRuntimeInstance(), index)), CompoundTag.class);
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class NbtAccounter extends ReflectWrapper {
|
public class NbtAccounter extends ReflectWrapper {
|
||||||
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtAccounter"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.NbtAccounter"));
|
||||||
private static final ReflectMethod<?> unlimitedHeap = wrapEx(() -> MAPPING.mojMethod("unlimitedHeap"));
|
private static final ReflectMethod<?> unlimitedHeap = wrapEx(() -> REFLECT.method("unlimitedHeap"));
|
||||||
|
|
||||||
private NbtAccounter(Object obj) {
|
private NbtAccounter(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
@ -10,9 +10,9 @@ import java.nio.file.Path;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class NbtIo extends ReflectWrapper {
|
public class NbtIo extends ReflectWrapper {
|
||||||
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.NbtIo"));
|
||||||
private static final ReflectMethod<?> readCompressed = wrapEx(() -> MAPPING.mojMethod("readCompressed", Path.class, NbtAccounter.MAPPING));
|
private static final ReflectMethod<?> readCompressed = wrapEx(() -> REFLECT.method("readCompressed", Path.class, NbtAccounter.REFLECT.get()));
|
||||||
private static final ReflectMethod<?> writeCompressed = wrapEx(() -> MAPPING.mojMethod("writeCompressed", CompoundTag.MAPPING, Path.class));
|
private static final ReflectMethod<?> writeCompressed = wrapEx(() -> REFLECT.method("writeCompressed", CompoundTag.REFLECT.get(), Path.class));
|
||||||
|
|
||||||
private NbtIo(Object obj) {
|
private NbtIo(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
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 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 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) {
|
protected StringTag(Object nms) {
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.ReflectField;
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
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)
|
@ConcreteWrapper(Tag.__concrete.class)
|
||||||
public interface Tag extends ReflectWrapperI {
|
public interface Tag extends ReflectWrapperI {
|
||||||
ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.Tag"));
|
ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.nbt.Tag"));
|
||||||
ReflectMethod<?> getAsString = wrapEx(() -> MAPPING.mojMethod("getAsString"));
|
ReflectMethod<?> getAsString = wrapEx(() -> REFLECT.method("getAsString"));
|
||||||
ReflectField<?> TAG_LIST = wrapEx(() -> MAPPING.mojField("TAG_LIST"));
|
ReflectField<?> TAG_LIST = wrapEx(() -> REFLECT.field("TAG_LIST"));
|
||||||
ReflectField<?> TAG_COMPOUND = wrapEx(() -> MAPPING.mojField("TAG_COMPOUND"));
|
ReflectField<?> TAG_COMPOUND = wrapEx(() -> REFLECT.field("TAG_COMPOUND"));
|
||||||
ReflectField<?> TAG_ANY_NUMERIC = wrapEx(() -> MAPPING.mojField("TAG_ANY_NUMERIC"));
|
ReflectField<?> TAG_ANY_NUMERIC = wrapEx(() -> REFLECT.field("TAG_ANY_NUMERIC"));
|
||||||
|
|
||||||
|
|
||||||
default String getAsString() {
|
default String getAsString() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network;
|
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.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.ReflectConstructor;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class FriendlyByteBuf extends ByteBuf {
|
public class FriendlyByteBuf extends ByteBuf {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.FriendlyByteBuf"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.FriendlyByteBuf"));
|
||||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ByteBuf.REFLECT.get()));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(ByteBuf.REFLECT.get()));
|
||||||
private static final ReflectMethod<?> writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class));
|
private static final ReflectMethod<?> writeUtf = wrapEx(() -> REFLECT.method("writeUtf", String.class));
|
||||||
|
|
||||||
public FriendlyByteBuf(ByteBuf parent) {
|
public FriendlyByteBuf(ByteBuf parent) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(parent))));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(parent))));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat;
|
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.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||||
@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(Component.__concrete.class)
|
@ConcreteWrapper(Component.__concrete.class)
|
||||||
public interface Component extends ReflectWrapperI {
|
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 {
|
class __concrete extends ReflectWrapper implements Component {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
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.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.ReflectConstructor;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Packet {
|
public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Packet {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket"));
|
||||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(CustomPacketPayload.MAPPING.runtimeClass()));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(CustomPacketPayload.REFLECT.get()));
|
||||||
|
|
||||||
protected ClientboundCustomPayloadPacket(Object obj) {
|
protected ClientboundCustomPayloadPacket(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
import fr.pandacube.lib.reflect.ReflectField;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ClientboundGameEventPacket extends ReflectWrapper implements Packet {
|
public class ClientboundGameEventPacket extends ReflectWrapper implements Packet {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket"));
|
||||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(Type.MAPPING.runtimeClass(), float.class));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Type.REFLECT.get(), float.class));
|
||||||
private static final ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE"));
|
private static final ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> REFLECT.field("RAIN_LEVEL_CHANGE"));
|
||||||
private static final ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE"));
|
private static final ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> REFLECT.field("THUNDER_LEVEL_CHANGE"));
|
||||||
|
|
||||||
public static Type RAIN_LEVEL_CHANGE() {
|
public static Type RAIN_LEVEL_CHANGE() {
|
||||||
return wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class);
|
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 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) {
|
protected Type(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
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.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||||
@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(Packet.__concrete.class)
|
@ConcreteWrapper(Packet.__concrete.class)
|
||||||
public interface Packet extends ReflectWrapperI {
|
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 {
|
class __concrete extends ReflectWrapper implements Packet {
|
||||||
protected __concrete(Object obj) {
|
protected __concrete(Object obj) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.custom;
|
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.ReflectConstructor;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class BrandPayload extends ReflectWrapper implements CustomPacketPayload {
|
public class BrandPayload extends ReflectWrapper implements CustomPacketPayload {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.common.custom.BrandPayload"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.network.protocol.common.custom.BrandPayload"));
|
||||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(String.class));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(String.class));
|
||||||
|
|
||||||
public BrandPayload(String brand) {
|
public BrandPayload(String brand) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(brand)));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(brand)));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.custom;
|
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.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||||
@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(CustomPacketPayload.__concrete.class)
|
@ConcreteWrapper(CustomPacketPayload.__concrete.class)
|
||||||
public interface CustomPacketPayload extends ReflectWrapperI {
|
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 {
|
class __concrete extends ReflectWrapper implements CustomPacketPayload {
|
||||||
protected __concrete(Object obj) {
|
protected __concrete(Object obj) {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources;
|
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 fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class ResourceLocation extends ReflectWrapper {
|
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) {
|
protected ResourceLocation(Object obj) {
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.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 fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ChunkMap extends ChunkStorage {
|
public class ChunkMap extends ChunkStorage {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ChunkMap"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ChunkMap"));
|
||||||
private static final ReflectField<?> FIELD_level = wrapEx(() -> MAPPING.mojField("level"));
|
private static final ReflectField<?> FIELD_level = wrapEx(() -> REFLECT.field("level"));
|
||||||
|
|
||||||
public final ServerLevel level;
|
public final ServerLevel level;
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class DedicatedPlayerList extends PlayerList {
|
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) {
|
protected DedicatedPlayerList(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class DedicatedServer extends MinecraftServer {
|
public class DedicatedServer extends MinecraftServer {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedServer"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.DedicatedServer"));
|
||||||
private static final ReflectMethod<?> getLevelIdName = wrapEx(() -> MAPPING.mojMethod("getLevelIdName"));
|
private static final ReflectMethod<?> getLevelIdName = wrapEx(() -> REFLECT.method("getLevelIdName"));
|
||||||
private static final ReflectMethod<?> getProperties = wrapEx(() -> MAPPING.mojMethod("getProperties"));
|
private static final ReflectMethod<?> getProperties = wrapEx(() -> REFLECT.method("getProperties"));
|
||||||
|
|
||||||
public String getLevelIdName() {
|
public String getLevelIdName() {
|
||||||
return (String) wrapReflectEx(() -> getLevelIdName.invoke(__getRuntimeInstance()));
|
return (String) wrapReflectEx(() -> getLevelIdName.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class DedicatedServerProperties extends Settings {
|
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) {
|
protected DedicatedServerProperties(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class MinecraftServer extends ReflectWrapper {
|
public class MinecraftServer extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.MinecraftServer"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.MinecraftServer"));
|
||||||
private static final ReflectMethod<?> getPlayerList = wrapEx(() -> MAPPING.mojMethod("getPlayerList"));
|
private static final ReflectMethod<?> getPlayerList = wrapEx(() -> REFLECT.method("getPlayerList"));
|
||||||
|
|
||||||
public PlayerList getPlayerList() {
|
public PlayerList getPlayerList() {
|
||||||
return wrap(wrapReflectEx(() -> getPlayerList.invoke(__getRuntimeInstance())), PlayerList.class);
|
return wrap(wrapReflectEx(() -> getPlayerList.invoke(__getRuntimeInstance())), PlayerList.class);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.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.ReflectField;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class PlayerList extends ReflectWrapper {
|
public class PlayerList extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.players.PlayerList"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.players.PlayerList"));
|
||||||
private static final ReflectField<?> playerIo = wrapEx(() -> MAPPING.mojField("playerIo"));
|
private static final ReflectField<?> playerIo = wrapEx(() -> REFLECT.field("playerIo"));
|
||||||
|
|
||||||
public PlayerDataStorage playerIo() {
|
public PlayerDataStorage playerIo() {
|
||||||
return wrap(wrapReflectEx(() -> playerIo.getValue(__getRuntimeInstance())), PlayerDataStorage.class);
|
return wrap(wrapReflectEx(() -> playerIo.getValue(__getRuntimeInstance())), PlayerDataStorage.class);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectField;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerChunkCache extends ReflectWrapper {
|
public class ServerChunkCache extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerChunkCache"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerChunkCache"));
|
||||||
private static final ReflectField<?> FIELD_chunkMap = wrapEx(() -> MAPPING.mojField("chunkMap"));
|
private static final ReflectField<?> FIELD_chunkMap = wrapEx(() -> REFLECT.field("chunkMap"));
|
||||||
|
|
||||||
public final ChunkMap chunkMap;
|
public final ChunkMap chunkMap;
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerCommonPacketListenerImpl extends ReflectWrapper {
|
public class ServerCommonPacketListenerImpl extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.network.ServerCommonPacketListenerImpl"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.network.ServerCommonPacketListenerImpl"));
|
||||||
public static final ReflectMethod<?> send = wrapEx(() -> MAPPING.mojMethod("send", Packet.MAPPING));
|
public static final ReflectMethod<?> send = wrapEx(() -> REFLECT.method("send", Packet.REFLECT.get()));
|
||||||
|
|
||||||
public void send(Packet packet) {
|
public void send(Packet packet) {
|
||||||
wrapReflectEx(() -> send.invoke(__getRuntimeInstance(), unwrap(packet)));
|
wrapReflectEx(() -> send.invoke(__getRuntimeInstance(), unwrap(packet)));
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl {
|
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) {
|
protected ServerGamePacketListenerImpl(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.util.ProgressListener;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
|
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 fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerLevel extends Level {
|
public class ServerLevel extends Level {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerLevel"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerLevel"));
|
||||||
public static final ReflectMethod<?> save = wrapEx(() -> MAPPING.mojMethod("save", ProgressListener.MAPPING, boolean.class, boolean.class));
|
public static final ReflectMethod<?> save = wrapEx(() -> REFLECT.method("save", ProgressListener.REFLECT.get(), boolean.class, boolean.class));
|
||||||
public static final ReflectMethod<?> getChunkSource = wrapEx(() -> MAPPING.mojMethod("getChunkSource"));
|
public static final ReflectMethod<?> getChunkSource = wrapEx(() -> REFLECT.method("getChunkSource"));
|
||||||
|
|
||||||
|
|
||||||
public ServerChunkCache getChunkSource() {
|
public ServerChunkCache getChunkSource() {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.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.ReflectField;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerPlayer extends Entity { // in NMS, ServerPlayer is not a direct subclass of Entity
|
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 ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.level.ServerPlayer"));
|
||||||
public static final ReflectField<?> connection = wrapEx(() -> MAPPING.mojField("connection"));
|
public static final ReflectField<?> connection = wrapEx(() -> REFLECT.field("connection"));
|
||||||
public static final ReflectMethod<?> isTextFilteringEnabled = wrapEx(() -> MAPPING.mojMethod("isTextFilteringEnabled"));
|
public static final ReflectMethod<?> isTextFilteringEnabled = wrapEx(() -> REFLECT.method("isTextFilteringEnabled"));
|
||||||
public static final ReflectMethod<?> allowsListing = wrapEx(() -> MAPPING.mojMethod("allowsListing"));
|
public static final ReflectMethod<?> allowsListing = wrapEx(() -> REFLECT.method("allowsListing"));
|
||||||
|
|
||||||
public boolean isTextFilteringEnabled() {
|
public boolean isTextFilteringEnabled() {
|
||||||
return (boolean) wrapReflectEx(() -> isTextFilteringEnabled.invoke(__getRuntimeInstance()));
|
return (boolean) wrapReflectEx(() -> isTextFilteringEnabled.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectField;
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -10,8 +11,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Settings extends ReflectWrapper {
|
public class Settings extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.Settings"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.server.dedicated.Settings"));
|
||||||
public static final ReflectField<?> properties = wrapEx(() -> MAPPING.mojField("properties"));
|
public static final ReflectField<?> properties = wrapEx(() -> REFLECT.field("properties"));
|
||||||
|
|
||||||
public Properties properties() {
|
public Properties properties() {
|
||||||
return (Properties) wrapReflectEx(() -> properties.getValue(__getRuntimeInstance()));
|
return (Properties) wrapReflectEx(() -> properties.getValue(__getRuntimeInstance()));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.util;
|
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.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
|
||||||
@ -9,7 +10,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
|
|
||||||
@ConcreteWrapper(ProgressListener.__concrete.class)
|
@ConcreteWrapper(ProgressListener.__concrete.class)
|
||||||
public interface ProgressListener extends ReflectWrapperI {
|
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 {
|
class __concrete extends ReflectWrapper implements ProgressListener {
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class AABB extends ReflectWrapper {
|
public class AABB extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.AABB"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("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));
|
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) {
|
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x1, y1, z1, x2, y2, z2)));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x1, y1, z1, x2, y2, z2)));
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ChunkPos extends ReflectWrapper {
|
public class ChunkPos extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.ChunkPos"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.ChunkPos"));
|
||||||
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class));
|
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(int.class, int.class));
|
||||||
|
|
||||||
public ChunkPos(int x, int z) {
|
public ChunkPos(int x, int z) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x, z)));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x, z)));
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.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.ReflectMethod;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ChunkStorage extends ReflectWrapper {
|
public class ChunkStorage extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.chunk.storage.ChunkStorage"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.chunk.storage.ChunkStorage"));
|
||||||
private static final ReflectMethod<?> readSync = wrapEx(() -> MAPPING.runtimeReflect().method("readSync", ChunkPos.MAPPING.runtimeReflect().get())); // spigot/paper method
|
private static final ReflectMethod<?> readSync = wrapEx(() -> REFLECT.method("readSync", ChunkPos.REFLECT.get())); // spigot/paper method
|
||||||
|
|
||||||
public CompoundTag readSync(ChunkPos pos) {
|
public CompoundTag readSync(ChunkPos pos) {
|
||||||
return wrap(wrapReflectEx(() -> readSync.invoke(__getRuntimeInstance(), unwrap(pos))), CompoundTag.class);
|
return wrap(wrapReflectEx(() -> readSync.invoke(__getRuntimeInstance(), unwrap(pos))), CompoundTag.class);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class DataVersion extends ReflectWrapper {
|
public class DataVersion extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.storage.DataVersion"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.DataVersion"));
|
||||||
private static final ReflectMethod<?> getVersion = wrapEx(() -> MAPPING.mojMethod("getVersion"));
|
private static final ReflectMethod<?> getVersion = wrapEx(() -> REFLECT.method("getVersion"));
|
||||||
private static final ReflectMethod<?> getSeries = wrapEx(() -> MAPPING.mojMethod("getSeries"));
|
private static final ReflectMethod<?> getSeries = wrapEx(() -> REFLECT.method("getSeries"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.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.ReflectMethod;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Entity extends ReflectWrapper {
|
public class Entity extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.entity.Entity"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.entity.Entity"));
|
||||||
public static final ReflectMethod<?> getBukkitEntity = wrapEx(() -> MAPPING.runtimeReflect().method("getBukkitEntity")); // spigot method
|
public static final ReflectMethod<?> getBukkitEntity = wrapEx(() -> REFLECT.method("getBukkitEntity")); // spigot method
|
||||||
public static final ReflectMethod<?> serializeEntity = wrapEx(() -> MAPPING.runtimeReflect().method("serializeEntity", CompoundTag.MAPPING.runtimeClass())); // paper method
|
public static final ReflectMethod<?> serializeEntity = wrapEx(() -> REFLECT.method("serializeEntity", CompoundTag.REFLECT.get())); // paper method
|
||||||
|
|
||||||
public org.bukkit.entity.Entity getBukkitEntity() {
|
public org.bukkit.entity.Entity getBukkitEntity() {
|
||||||
return (org.bukkit.entity.Entity) wrapReflectEx(() -> getBukkitEntity.invoke(__getRuntimeInstance()));
|
return (org.bukkit.entity.Entity) wrapReflectEx(() -> getBukkitEntity.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ItemStack extends ReflectWrapper {
|
public class ItemStack extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.item.ItemStack"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.item.ItemStack"));
|
||||||
private static final ReflectMethod<?> of = wrapEx(() -> MAPPING.mojMethod("of", CompoundTag.MAPPING));
|
private static final ReflectMethod<?> of = wrapEx(() -> REFLECT.method("of", CompoundTag.REFLECT.get()));
|
||||||
private static final ReflectMethod<?> save = wrapEx(() -> MAPPING.mojMethod("save", CompoundTag.MAPPING));
|
private static final ReflectMethod<?> save = wrapEx(() -> REFLECT.method("save", CompoundTag.REFLECT.get()));
|
||||||
|
|
||||||
public static ItemStack of(CompoundTag nbt) {
|
public static ItemStack of(CompoundTag nbt) {
|
||||||
return wrap(wrapReflectEx(() -> of.invokeStatic(unwrap(nbt))), ItemStack.class);
|
return wrap(wrapReflectEx(() -> of.invokeStatic(unwrap(nbt))), ItemStack.class);
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.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.ReflectMethod;
|
||||||
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Level extends ReflectWrapper {
|
public class Level extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.Level"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.Level"));
|
||||||
public static final ReflectMethod<?> getGameTime = wrapEx(() -> MAPPING.mojMethod("getGameTime"));
|
public static final ReflectMethod<?> getGameTime = wrapEx(() -> REFLECT.method("getGameTime"));
|
||||||
public static final ReflectMethod<?> getFreeMapId = wrapEx(() -> MAPPING.mojMethod("getFreeMapId"));
|
public static final ReflectMethod<?> getFreeMapId = wrapEx(() -> REFLECT.method("getFreeMapId"));
|
||||||
public static final ReflectMethod<?> paperConfig = wrapEx(() -> MAPPING.runtimeReflect().method("paperConfig")); // paper method
|
public static final ReflectMethod<?> paperConfig = wrapEx(() -> REFLECT.method("paperConfig")); // paper method
|
||||||
|
|
||||||
public long getGameTime() {
|
public long getGameTime() {
|
||||||
return (long) wrapReflectEx(() -> getGameTime.invoke(__getRuntimeInstance()));
|
return (long) wrapReflectEx(() -> getGameTime.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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 fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class MapItemSavedData extends SavedData {
|
public class MapItemSavedData extends SavedData {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData"));
|
||||||
public static final ReflectField<?> colors = wrapEx(() -> MAPPING.mojField("colors"));
|
public static final ReflectField<?> colors = wrapEx(() -> REFLECT.field("colors"));
|
||||||
public static final ReflectField<?> locked = wrapEx(() -> MAPPING.mojField("locked"));
|
public static final ReflectField<?> locked = wrapEx(() -> REFLECT.field("locked"));
|
||||||
|
|
||||||
protected MapItemSavedData(Object obj) {
|
protected MapItemSavedData(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class PlayerDataStorage extends ReflectWrapper {
|
public class PlayerDataStorage extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.storage.PlayerDataStorage"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.storage.PlayerDataStorage"));
|
||||||
public static final ReflectMethod<?> getPlayerData = wrapEx(() -> MAPPING.runtimeReflect().method("getPlayerData", String.class)); // Craftbukkit method
|
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())
|
* @param playerId UUID of a player as it is used to name the player data file (UUID.toString())
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
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.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class SavedData extends ReflectWrapper {
|
public class SavedData extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.SavedData"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.saveddata.SavedData"));
|
||||||
private static final ReflectMethod<?> setDirty = wrapEx(() -> MAPPING.mojMethod("setDirty"));
|
private static final ReflectMethod<?> setDirty = wrapEx(() -> REFLECT.method("setDirty"));
|
||||||
|
|
||||||
protected SavedData(Object obj) {
|
protected SavedData(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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 fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class Vec3 extends ReflectWrapper {
|
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) {
|
protected Vec3(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
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 fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class VoxelShape extends ReflectWrapper {
|
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) {
|
protected VoxelShape(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block;
|
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.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 fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class BambooStalkBlock extends Block {
|
public class BambooStalkBlock extends Block {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.BambooStalkBlock"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("net.minecraft.world.level.block.BambooStalkBlock"));
|
||||||
public static final ReflectField<?> COLLISION_SHAPE = wrapEx(() -> MAPPING.mojField("COLLISION_SHAPE"));
|
public static final ReflectField<?> COLLISION_SHAPE = wrapEx(() -> REFLECT.field("COLLISION_SHAPE"));
|
||||||
|
|
||||||
public static VoxelShape COLLISION_SHAPE() {
|
public static VoxelShape COLLISION_SHAPE() {
|
||||||
return wrap(wrapReflectEx(COLLISION_SHAPE::getStaticValue), VoxelShape.class);
|
return wrap(wrapReflectEx(COLLISION_SHAPE::getStaticValue), VoxelShape.class);
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block;
|
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.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.ReflectMethod;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
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;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Block extends ReflectWrapper {
|
public class Block extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.Block"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("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));
|
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) {
|
public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||||
|
@ -11,7 +11,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class PaperAdventure extends ReflectWrapper {
|
public class PaperAdventure extends ReflectWrapper {
|
||||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.adventure.PaperAdventure"));
|
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) {
|
public static net.kyori.adventure.text.Component asAdventure(Component component) {
|
||||||
return (net.kyori.adventure.text.Component) wrapReflectEx(() -> asAdventure.invokeStatic(unwrap(component)));
|
return (net.kyori.adventure.text.Component) wrapReflectEx(() -> asAdventure.invokeStatic(unwrap(component)));
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package fr.pandacube.lib.util.function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function that can possibly throw a checked exception.
|
||||||
|
* @param <T> the parameter for this function.
|
||||||
|
* @param <R> the return value for this function.
|
||||||
|
* @param <E> the exception type that this interface method can throw.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface FunctionException<T, R, E extends Exception> {
|
||||||
|
/**
|
||||||
|
* Run on the specified parameters to return an int value.
|
||||||
|
*
|
||||||
|
* @param t the parameter of the function.
|
||||||
|
* @return the result of the function.
|
||||||
|
* @throws E if the function fails.
|
||||||
|
*/
|
||||||
|
R apply(T t) throws E;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user