本文整理匯總了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);
}