Adopt MaterialRerouting

Adopts the paper-api to the material rerouting infrastructure introduced
by upstream.
This commit is contained in:
Bjarne Koll
2024-06-13 11:02:36 +02:00
parent 165e93c7c6
commit 99cd3b6813
2 changed files with 92 additions and 0 deletions

View File

@@ -56,6 +56,9 @@ public class MaterialReroutingTest {
.filter(entry -> !entry.getName().endsWith("ItemType.class"))
.filter(entry -> !entry.getName().endsWith("Registry.class"))
.filter(entry -> !entry.getName().startsWith("org/bukkit/material"))
// Paper start - types that cannot be translated to ItemType/BlockType
.filter(entry -> !entry.getName().equals("com/destroystokyo/paper/MaterialSetTag.class"))
// Paper end - types that cannot be translated to ItemType/BlockType
.map(entry -> {
try {
return MaterialReroutingTest.jarFile.getInputStream(entry);
@@ -93,6 +96,10 @@ public class MaterialReroutingTest {
continue;
}
}
// Paper start - filter out more methods from rerouting test
if (methodNode.name.startsWith("lambda$")) continue;
if (isInternal(methodNode.invisibleAnnotations)) continue;
// Paper end - filter out more methods from rerouting test
if (!Commodore.rerouteMethods(ApiVersion.CURRENT, MaterialReroutingTest.MATERIAL_METHOD_REROUTE, (methodNode.access & Opcodes.ACC_STATIC) != 0, classNode.name, methodNode.name, methodNode.desc, a -> { })) {
missingReroute.add(methodNode.name + " " + methodNode.desc + " " + methodNode.signature);
@@ -109,6 +116,13 @@ public class MaterialReroutingTest {
}
}
// Paper start - filter out more methods from rerouting test
private static boolean isInternal(final List<org.objectweb.asm.tree.AnnotationNode> annotationNodes) {
return annotationNodes != null
&& annotationNodes.stream().anyMatch(a -> a.desc.equals("Lorg/jetbrains/annotations/ApiStatus$Internal;"));
}
// Paper end - filter out more methods from rerouting test
@AfterAll
public static void clear() throws IOException {
if (MaterialReroutingTest.jarFile != null) {