This commit is contained in:
NotMyFault 2021-02-15 12:24:33 +01:00
parent 0a721b18ce
commit af987016fc
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.entity.metadata.EntityProperties;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.Ambient; import org.bukkit.entity.Ambient;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
@ -47,6 +48,19 @@ import static com.google.common.base.Preconditions.checkNotNull;
class BukkitEntityProperties implements EntityProperties { class BukkitEntityProperties implements EntityProperties {
private static final boolean HAS_ABSTRACT_VILLAGER;
static {
boolean temp;
try {
Class.forName("org.bukkit.entity.AbstractVillager");
temp = true;
} catch (ClassNotFoundException e) {
temp = false;
}
HAS_ABSTRACT_VILLAGER = temp;
}
private final Entity entity; private final Entity entity;
BukkitEntityProperties(Entity entity) { BukkitEntityProperties(Entity entity) {
@ -121,6 +135,9 @@ class BukkitEntityProperties implements EntityProperties {
@Override @Override
public boolean isNPC() { public boolean isNPC() {
if (HAS_ABSTRACT_VILLAGER) {
return entity instanceof AbstractVillager;
}
return entity instanceof Villager; return entity instanceof Villager;
} }