1
0
mirror of https://github.com/PaperMC/Paper.git synced 2025-03-02 11:22:01 +01:00

SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2024-02-17 14:04:58 +11:00
parent 3cfdcf8a3e
commit 6dc11b5d28

View File

@ -486,8 +486,14 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
CraftEntityTypes.EntityTypeData<?, ?> entityTypeData = CraftEntityTypes.getEntityTypeData(clazz);
if (entityTypeData == null || entityTypeData.spawnFunction() == null) {
if (CraftEntity.class.isAssignableFrom(clazz)) {
// SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
throw new IllegalArgumentException(String.format("Cannot spawn an entity from its CraftBukkit implementation class '%s' use the Bukkit class instead. "
+ "You can get the Bukkit representation via Entity#getType()#getEntityClass()", clazz.getName()));
} else {
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName());
}
}
if (!entityTypeData.entityType().isEnabledByFeature(getHandle().getMinecraftWorld().getWorld())) {
throw new IllegalArgumentException("Cannot spawn an entity for " + clazz.getName() + " because it is not an enabled feature");