From af987016fc33f7aee2bd8971c6ae40e4ac1dcd64 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 15 Feb 2021 12:24:33 +0100 Subject: [PATCH] Fixes #910 --- .../bukkit/BukkitEntityProperties.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityProperties.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityProperties.java index 08d2a2f84..7e9e785f7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityProperties.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitEntityProperties.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.worldedit.entity.metadata.EntityProperties; +import org.bukkit.entity.AbstractVillager; import org.bukkit.entity.Ambient; import org.bukkit.entity.Animals; import org.bukkit.entity.ArmorStand; @@ -47,6 +48,19 @@ import static com.google.common.base.Preconditions.checkNotNull; 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; BukkitEntityProperties(Entity entity) { @@ -121,6 +135,9 @@ class BukkitEntityProperties implements EntityProperties { @Override public boolean isNPC() { + if (HAS_ABSTRACT_VILLAGER) { + return entity instanceof AbstractVillager; + } return entity instanceof Villager; }