diff --git a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java index 87b1f48797..56d2eb4b92 100644 --- a/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java +++ b/paper-server/src/test/java/org/bukkit/event/EntityRemoveEventTest.java @@ -18,7 +18,7 @@ import org.objectweb.asm.tree.MethodNode; @Normal public class EntityRemoveEventTest { - @ClassNodeTest(value = {ClassNodeTest.ClassType.CRAFT_BUKKIT, ClassNodeTest.ClassType.MINECRAFT_MODIFIED, ClassNodeTest.ClassType.MINECRAFT_UNMODIFIED}, + @ClassNodeTest(value = ClassNodeTest.ClassType.CRAFT_BUKKIT, excludedClasses = EntityAccess.class, excludedPackages = "net/minecraft/gametest/framework") public void testForMissing(ClassNode classNode) throws ClassNotFoundException { diff --git a/paper-server/src/test/java/org/bukkit/support/provider/ClassNodeArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/ClassNodeArgumentProvider.java index 44eae40868..8a9319acba 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/ClassNodeArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/ClassNodeArgumentProvider.java @@ -44,8 +44,6 @@ public class ClassNodeArgumentProvider implements ArgumentsProvider, AnnotationC newValues[i] = switch (this.classTypes[i]) { case BUKKIT -> ClassReaderTest.ClassType.BUKKIT; case CRAFT_BUKKIT -> ClassReaderTest.ClassType.CRAFT_BUKKIT; - case MINECRAFT_UNMODIFIED -> ClassReaderTest.ClassType.MINECRAFT_UNMODIFIED; - case MINECRAFT_MODIFIED -> ClassReaderTest.ClassType.MINECRAFT_MODIFIED; }; } diff --git a/paper-server/src/test/java/org/bukkit/support/provider/ClassReaderArgumentProvider.java b/paper-server/src/test/java/org/bukkit/support/provider/ClassReaderArgumentProvider.java index 5386eee2ff..da065a157a 100644 --- a/paper-server/src/test/java/org/bukkit/support/provider/ClassReaderArgumentProvider.java +++ b/paper-server/src/test/java/org/bukkit/support/provider/ClassReaderArgumentProvider.java @@ -1,6 +1,5 @@ package org.bukkit.support.provider; -import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -13,8 +12,6 @@ import java.nio.file.Path; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Stream; -import net.minecraft.WorldVersion; -import net.minecraft.server.Main; import org.bukkit.Bukkit; import org.bukkit.support.test.ClassReaderTest; import org.junit.jupiter.api.extension.ExtensionContext; @@ -27,15 +24,12 @@ public class ClassReaderArgumentProvider implements ArgumentsProvider, Annotatio // Needs to be a class, which is present in the source, and not a test class private static final URI CRAFT_BUKKIT_CLASSES; - // Needs to be a class, which is from the minecraft package and not patch by CraftBukkit - private static final URI MINECRAFT_CLASSES; // Needs to be a class, which is from the bukkit package and not a CraftBukkit class private static final URI BUKKIT_CLASSES; static { try { - CRAFT_BUKKIT_CLASSES = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI(); - MINECRAFT_CLASSES = WorldVersion.class.getProtectionDomain().getCodeSource().getLocation().toURI(); + CRAFT_BUKKIT_CLASSES = org.bukkit.craftbukkit.Main.class.getProtectionDomain().getCodeSource().getLocation().toURI(); BUKKIT_CLASSES = Bukkit.class.getProtectionDomain().getCodeSource().getLocation().toURI(); } catch (URISyntaxException e) { throw new RuntimeException(e); @@ -63,19 +57,11 @@ public class ClassReaderArgumentProvider implements ArgumentsProvider, Annotatio } public Stream getClassReaders() { - assertNotEquals(ClassReaderArgumentProvider.CRAFT_BUKKIT_CLASSES, ClassReaderArgumentProvider.MINECRAFT_CLASSES, """ - The Minecraft and CraftBukkit uri point to the same directory / file. - Please make sure the CRAFT_BUKKIT_CLASSES points to the test class directory and MINECRAFT_CLASSES to the minecraft server jar. - """); Stream result = Stream.empty(); - if (this.contains(ClassReaderTest.ClassType.MINECRAFT_UNMODIFIED)) { - result = Stream.concat(result, this.readMinecraftClasses()); - } - - if (this.contains(ClassReaderTest.ClassType.CRAFT_BUKKIT) || this.contains(ClassReaderTest.ClassType.MINECRAFT_MODIFIED)) { - result = Stream.concat(result, this.readCraftBukkitAndOrMinecraftModifiedClasses(this.contains(ClassReaderTest.ClassType.CRAFT_BUKKIT), this.contains(ClassReaderTest.ClassType.MINECRAFT_MODIFIED))); + if (this.contains(ClassReaderTest.ClassType.CRAFT_BUKKIT)) { + result = Stream.concat(result, this.createCraftBukkitClasses()); } if (this.contains(ClassReaderTest.ClassType.BUKKIT)) { @@ -103,10 +89,6 @@ public class ClassReaderArgumentProvider implements ArgumentsProvider, Annotatio return false; } - private Stream readMinecraftClasses() { - return this.readJarFile(ClassReaderArgumentProvider.MINECRAFT_CLASSES, true); - } - private Stream readBukkitClasses() { return this.readJarFile(ClassReaderArgumentProvider.BUKKIT_CLASSES, false); } @@ -159,13 +141,12 @@ public class ClassReaderArgumentProvider implements ArgumentsProvider, Annotatio return true; } - private Stream readCraftBukkitAndOrMinecraftModifiedClasses(boolean craftBukkit, boolean minecraftModified) { + private Stream createCraftBukkitClasses() { try { return Files.walk(Path.of(ClassReaderArgumentProvider.CRAFT_BUKKIT_CLASSES)) .map(Path::toFile) .filter(File::isFile) .filter(file -> file.getName().endsWith(".class")) - .filter(file -> this.shouldInclude(this.removeHomeDirectory(file), craftBukkit, minecraftModified)) .filter(file -> this.filterPackageNames(this.removeHomeDirectory(file))) .filter(file -> this.filterClass(this.removeHomeDirectory(file))) .map(file -> { @@ -184,22 +165,6 @@ public class ClassReaderArgumentProvider implements ArgumentsProvider, Annotatio return file.getAbsolutePath().substring(ClassReaderArgumentProvider.CRAFT_BUKKIT_CLASSES.getPath().length()); } - private boolean shouldInclude(String name, boolean craftBukkit, boolean minecraftModified) { - if (craftBukkit && minecraftModified) { - return true; - } - - if (craftBukkit) { - return name.startsWith("org/bukkit/craftbukkit/"); - } - - if (minecraftModified) { - return name.startsWith("net/minecraft/"); - } - - return false; - } - private void closeJarFile(JarFile jarFile) { try { jarFile.close(); diff --git a/paper-server/src/test/java/org/bukkit/support/test/ClassNodeTest.java b/paper-server/src/test/java/org/bukkit/support/test/ClassNodeTest.java index 41b284dbe5..b9fcccb203 100644 --- a/paper-server/src/test/java/org/bukkit/support/test/ClassNodeTest.java +++ b/paper-server/src/test/java/org/bukkit/support/test/ClassNodeTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.params.provider.ArgumentsSource; @ParameterizedTest public @interface ClassNodeTest { - ClassType[] value() default {ClassType.BUKKIT, ClassType.CRAFT_BUKKIT, ClassType.MINECRAFT_UNMODIFIED, ClassType.MINECRAFT_MODIFIED}; + ClassType[] value() default {ClassType.BUKKIT, ClassType.CRAFT_BUKKIT}; Class[] excludedClasses() default {}; @@ -23,7 +23,5 @@ public @interface ClassNodeTest { enum ClassType { BUKKIT, CRAFT_BUKKIT, - MINECRAFT_UNMODIFIED, - MINECRAFT_MODIFIED, } } diff --git a/paper-server/src/test/java/org/bukkit/support/test/ClassReaderTest.java b/paper-server/src/test/java/org/bukkit/support/test/ClassReaderTest.java index 9ebec1ff65..1ebe57127b 100644 --- a/paper-server/src/test/java/org/bukkit/support/test/ClassReaderTest.java +++ b/paper-server/src/test/java/org/bukkit/support/test/ClassReaderTest.java @@ -14,7 +14,7 @@ import org.junit.jupiter.params.provider.ArgumentsSource; @ParameterizedTest public @interface ClassReaderTest { - ClassType[] value() default {ClassType.BUKKIT, ClassType.CRAFT_BUKKIT, ClassType.MINECRAFT_UNMODIFIED, ClassType.MINECRAFT_MODIFIED}; + ClassType[] value() default {ClassType.BUKKIT, ClassType.CRAFT_BUKKIT}; Class[] excludedClasses() default {}; @@ -23,7 +23,5 @@ public @interface ClassReaderTest { enum ClassType { BUKKIT, CRAFT_BUKKIT, - MINECRAFT_UNMODIFIED, - MINECRAFT_MODIFIED, } }