Fixed and improved entity name detection. issue #26

This commit is contained in:
t3hk0d3 2012-06-07 12:10:00 +04:00
parent 09af72ede3
commit 7c3d4f781f
2 changed files with 11 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import org.bukkit.entity.*;
public enum EntityCategory {
PLAYER("player", Player.class),
ITEM("item", Item.class),
ANIMAL("animal", Animals.class, Squid.class),
MONSTER("monster", Monster.class, Slime.class, EnderDragon.class, Ghast.class ),
NPC("npc", NPC.class),

View File

@ -26,7 +26,6 @@ import org.bukkit.entity.*;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import ru.tehkode.permissions.PermissionManager;
import ru.tehkode.permissions.bukkit.PermissionsEx;
@ -71,7 +70,16 @@ public abstract class ModifyworldListener implements Listener {
}
protected String getEntityName(Entity entity) {
String entityName = entity.toString().substring(5).toLowerCase();
if (entity instanceof ComplexEntityPart) {
return getEntityName(((ComplexEntityPart)entity).getParent());
}
String entityName = entity.getType().toString().toLowerCase().replace("_", "");
if (entity instanceof Item) {
entityName = getItemPermission(((Item) entity).getItemStack());
}
if (entity instanceof Player) {
return "player." + ((Player) entity).getName();