Archiviert
13
0

Add getEntitesByClass(Class<T>), getEntitiesByClasses(Class<?>...), deprecate getEntitiesByClass(Class<T>...)

Dieser Commit ist enthalten in:
Mike Primm 2012-01-27 21:49:55 -06:00 committet von EvilSeph
Ursprung 137880b727
Commit 5316c43a82

Datei anzeigen

@ -531,9 +531,37 @@ public class CraftWorld implements World {
}
@SuppressWarnings("unchecked")
@Deprecated
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T>... classes) {
return (Collection<T>)getEntitiesByClasses(classes);
}
@SuppressWarnings("unchecked")
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> clazz) {
Collection<T> list = new ArrayList<T>();
for (Object entity: world.entityList) {
if (entity instanceof net.minecraft.server.Entity) {
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
if (bukkitEntity == null) {
continue;
}
Class<?> bukkitClass = bukkitEntity.getClass();
if (clazz.isAssignableFrom(bukkitClass)) {
list.add((T) bukkitEntity);
}
}
}
return list;
}
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
Collection<Entity> list = new ArrayList<Entity>();
for (Object entity: world.entityList) {
if (entity instanceof net.minecraft.server.Entity) {
Entity bukkitEntity = ((net.minecraft.server.Entity) entity).getBukkitEntity();
@ -546,7 +574,7 @@ public class CraftWorld implements World {
for (Class<?> clazz : classes) {
if (clazz.isAssignableFrom(bukkitClass)) {
list.add((T) bukkitEntity);
list.add(bukkitEntity);
break;
}
}