diff options
8 files changed, 13 insertions, 8 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java index 1fcb571..c713a2c 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java @@ -102,8 +102,9 @@ public class SparkBukkitPlugin extends JavaPlugin implements SparkPlugin<Command } @Override - public Set<CommandSender> getSenders() { + public Set<CommandSender> getSendersWithPermission(String permission) { Set<CommandSender> senders = new HashSet<>(getServer().getOnlinePlayers()); + senders.removeIf(sender -> !sender.hasPermission(permission)); senders.add(getServer().getConsoleSender()); return senders; } diff --git a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java index 5c39d34..0bc118a 100644 --- a/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java +++ b/spark-bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java @@ -68,8 +68,9 @@ public class SparkBungeeCordPlugin extends Plugin implements SparkPlugin<Command } @Override - public Set<CommandSender> getSenders() { + public Set<CommandSender> getSendersWithPermission(String permission) { Set<CommandSender> senders = new HashSet<>(getProxy().getPlayers()); + senders.removeIf(sender -> !sender.hasPermission(permission)); senders.add(getProxy().getConsole()); return senders; } diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java index 7a3a353..481a615 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java +++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlugin.java @@ -34,7 +34,7 @@ public interface SparkPlugin<S> { String getLabel(); - Set<S> getSenders(); + Set<S> getSendersWithPermission(String permission); void sendMessage(S sender, String message); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java index 0df2950..9d604bd 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java @@ -43,7 +43,7 @@ public class CommandResponseHandler<S> { } public void allSenders(Consumer<? super S> action) { - Set<S> senders = this.platform.getPlugin().getSenders(); + Set<S> senders = this.platform.getPlugin().getSendersWithPermission("spark"); senders.add(this.sender); senders.forEach(action); } diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java index 2c6c2fb..b214308 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java @@ -43,7 +43,7 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin { } @Override - public Set<ICommandSender> getSenders() { + public Set<ICommandSender> getSendersWithPermission(String permission) { return new HashSet<>(Collections.singleton(Minecraft.getMinecraft().player)); } diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java index 98740c0..167aa94 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java @@ -37,9 +37,10 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin { } @Override - public Set<ICommandSender> getSenders() { + public Set<ICommandSender> getSendersWithPermission(String permission) { MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance(); Set<ICommandSender> senders = new HashSet<>(mcServer.getPlayerList().getPlayers()); + senders.removeIf(sender -> !sender.canUseCommand(4, permission)); senders.add(mcServer); return senders; } diff --git a/spark-sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java b/spark-sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java index 6d0c56a..159cbc7 100644 --- a/spark-sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java +++ b/spark-sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java @@ -107,8 +107,9 @@ public class SparkSpongePlugin implements SparkPlugin<CommandSource> { } @Override - public Set<CommandSource> getSenders() { + public Set<CommandSource> getSendersWithPermission(String permission) { Set<CommandSource> senders = new HashSet<>(this.game.getServer().getOnlinePlayers()); + senders.removeIf(sender -> !sender.hasPermission(permission)); senders.add(this.game.getServer().getConsole()); return senders; } diff --git a/spark-velocity/src/main/java/me/lucko/spark/velocity/SparkVelocityPlugin.java b/spark-velocity/src/main/java/me/lucko/spark/velocity/SparkVelocityPlugin.java index fef48e7..749319d 100644 --- a/spark-velocity/src/main/java/me/lucko/spark/velocity/SparkVelocityPlugin.java +++ b/spark-velocity/src/main/java/me/lucko/spark/velocity/SparkVelocityPlugin.java @@ -103,8 +103,9 @@ public class SparkVelocityPlugin implements SparkPlugin<CommandSource>, Command } @Override - public Set<CommandSource> getSenders() { + public Set<CommandSource> getSendersWithPermission(String permission) { Set<CommandSource> senders = new HashSet<>(this.proxy.getAllPlayers()); + senders.removeIf(sender -> !sender.hasPermission(permission)); senders.add(this.proxy.getConsoleCommandSource()); return senders; } |