本文整理汇总了Java中org.bukkit.entity.Entity.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getClass方法的具体用法?Java Entity.getClass怎么用?Java Entity.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.getClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntitiesByClass
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> clazz) {
Collection<T> list = new ArrayList<T>();
for (Object entity: world.loadedEntityList) {
if (entity instanceof net.minecraft.entity.Entity) {
Entity bukkitEntity = ((net.minecraft.entity.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
continue;
}
Class<?> bukkitClass = bukkitEntity.getClass();
if (clazz.isAssignableFrom(bukkitClass)) {
list.add((T) bukkitEntity);
}
}
}
return list;
}
示例2: getEntitiesByClasses
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
Collection<Entity> list = new ArrayList<Entity>();
for (Object entity: world.loadedEntityList) {
if (entity instanceof net.minecraft.entity.Entity) {
Entity bukkitEntity = ((net.minecraft.entity.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
continue;
}
Class<?> bukkitClass = bukkitEntity.getClass();
for (Class<?> clazz : classes) {
if (clazz.isAssignableFrom(bukkitClass)) {
list.add(bukkitEntity);
break;
}
}
}
}
return list;
}
示例3: EntityInfo
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public EntityInfo(Entity entity, @Nullable ParticipantState owner) {
super(owner);
this.entityType = entity.getType();
this.entityClass = entity.getClass();
this.customName = entity.getCustomName();
this.nameKey = NMSHacks.getTranslationKey(entity);
}
示例4: get
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static @Nullable MatchEntityState get(Entity entity) {
Match match = Matches.get(entity.getWorld());
String customName = entity instanceof Player ? null : entity.getCustomName();
return match == null ? null : new MatchEntityState(match, entity.getClass(), entity.getUniqueId(), entity.getEntityLocation(), customName);
}