Add Shearable API

This commit is contained in:
Owen1212055
2021-10-17 15:39:48 -04:00
parent 6e271dc9e4
commit 2e77028ed4
7 changed files with 67 additions and 4 deletions

View File

@@ -0,0 +1,30 @@
package io.papermc.paper.entity;
import com.destroystokyo.paper.entity.ai.MobGoalHelper;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;
import java.util.List;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.Shearable;
import org.bukkit.support.environment.Normal;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@Normal
class ShearableTest {
static List<Class<Shearable>> nmsShearables() {
try (final ScanResult result = new ClassGraph().enableClassInfo().whitelistPackages("net.minecraft.world.entity").scan()) {
return result.getClassesImplementing(Shearable.class.getName()).loadClasses(Shearable.class);
}
}
@SuppressWarnings("unchecked")
@ParameterizedTest
@MethodSource("nmsShearables")
void ensureImplementsShearable(final Class<? extends Shearable> shearableNmsClass) {
final Class<? extends org.bukkit.entity.Mob> bukkitClass = MobGoalHelper.toBukkitClass((Class<? extends Mob>) shearableNmsClass);
Assertions.assertTrue(io.papermc.paper.entity.Shearable.class.isAssignableFrom(bukkitClass), bukkitClass.getName() + " does not implement Shearable");
}
}