diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 26abc17566..e4cc45aa10 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -531,9 +531,37 @@ public class CraftWorld implements World { } @SuppressWarnings("unchecked") + @Deprecated public Collection getEntitiesByClass(Class... classes) { + return (Collection)getEntitiesByClasses(classes); + } + + @SuppressWarnings("unchecked") + public Collection getEntitiesByClass(Class clazz) { Collection list = new ArrayList(); + 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 getEntitiesByClasses(Class... classes) { + Collection list = new ArrayList(); + 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; } }