mirror of
https://github.com/PEXPlugins/Modifyworld.git
synced 2024-11-21 11:26:13 +01:00
Fixed and improved entity name detection. issue #26
This commit is contained in:
parent
09af72ede3
commit
7c3d4f781f
@ -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),
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user