From 76c834a8497c027419a0f7c9b271a6fc55fda18c Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 27 Jun 2015 15:46:19 +1000 Subject: [PATCH] Clean up World.getPlayers(). Original idea from CyberTiger, PR #150 --- .../java/org/bukkit/craftbukkit/CraftWorld.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 8c9ead5570..554e3b784e 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -721,16 +721,13 @@ public class CraftWorld implements World { } public List getPlayers() { - List list = new ArrayList(); + List list = new ArrayList(world.players.size()); - for (Object o : world.entityList) { - if (o instanceof net.minecraft.server.Entity) { - net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o; - Entity bukkitEntity = mcEnt.getBukkitEntity(); + for (EntityHuman human : world.players) { + HumanEntity bukkitEntity = human.getBukkitEntity(); - if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { - list.add((Player) bukkitEntity); - } + if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { + list.add((Player) bukkitEntity); } }