Fix trailing whitespace and correctly check both permisions systems in WorldGurdPlugin.broadcastNotification()

This commit is contained in:
zml2008 2012-03-10 17:56:02 -08:00
parent 3d6d774b17
commit 5454832918

View File

@ -28,6 +28,7 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
@ -43,6 +44,7 @@
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -740,7 +742,7 @@ public void createDefaultConfiguration(File actual,
} }
/** /**
* Notifies all with the notify permission. * Notifies all with the worldguard.notify permission.
* This will check both superperms and WEPIF, * This will check both superperms and WEPIF,
* but makes sure WEPIF checks don't result in duplicate notifications * but makes sure WEPIF checks don't result in duplicate notifications
* *
@ -748,9 +750,10 @@ public void createDefaultConfiguration(File actual,
*/ */
public void broadcastNotification(String msg) { public void broadcastNotification(String msg) {
getServer().broadcast(msg, "worldguard.notify"); getServer().broadcast(msg, "worldguard.notify");
Set<Permissible> subs = getServer().getPluginManager().getPermissionSubscriptions("worldguard.notify");
for (Player player : getServer().getOnlinePlayers()) { for (Player player : getServer().getOnlinePlayers()) {
if (hasPermission(player, "worldguard.notify") && if (!subs.contains(player) &&
!player.hasPermission("worldguard.notify")) { // Make sure the player wasn't already broadcasted to. hasPermission(player, "worldguard.notify")) { // Make sure the player wasn't already broadcasted to.
player.sendMessage(msg); player.sendMessage(msg);
} }
} }