diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-02 22:24:28 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-09-02 22:24:28 +0100 |
commit | fe0cd5405b68ee437fc179558d5e9086323fbcc8 (patch) | |
tree | 777b5a60990c31b0e2b35f6075d10e1d1e0c4b50 /src | |
parent | db691ff5c8894296f1ab94c58bba330ee481ceb5 (diff) | |
download | craftbukkit-fe0cd5405b68ee437fc179558d5e9086323fbcc8.tar craftbukkit-fe0cd5405b68ee437fc179558d5e9086323fbcc8.tar.gz craftbukkit-fe0cd5405b68ee437fc179558d5e9086323fbcc8.tar.lz craftbukkit-fe0cd5405b68ee437fc179558d5e9086323fbcc8.tar.xz craftbukkit-fe0cd5405b68ee437fc179558d5e9086323fbcc8.zip |
Implemented new broadcast method
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 27367d55..30959af2 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -53,6 +53,7 @@ import net.minecraft.server.ItemStack; import net.minecraft.server.WorldMap; import net.minecraft.server.WorldMapCollection; import org.bukkit.*; +import org.bukkit.permissions.Permissible; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.ServicesManager; @@ -226,13 +227,7 @@ public final class CraftServer implements Server { } public int broadcastMessage(String message) { - Player[] players = getOnlinePlayers(); - - for (Player player : players) { - player.sendMessage(message); - } - - return players.length; + return broadcast(message, BROADCAST_CHANNEL_USERS); } public Player getPlayer(final EntityPlayer entity) { @@ -796,4 +791,19 @@ public final class CraftServer implements Server { public void shutdown() { console.a(); } + + public int broadcast(String message, String permission) { + int count = 0; + Set<Permissible> permissibles = getPluginManager().getPermissionSubscriptions(permission); + + for (Permissible permissible : permissibles) { + if (permissible instanceof CommandSender) { + CommandSender user = (CommandSender)permissible; + user.sendMessage(message); + count++; + } + } + + return count; + } } |