aboutsummaryrefslogtreecommitdiff
path: root/spark-forge/src/main/java/me
diff options
context:
space:
mode:
Diffstat (limited to 'spark-forge/src/main/java/me')
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java8
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java15
2 files changed, 9 insertions, 14 deletions
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 ec6a0fc..5dd2ded 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
@@ -20,7 +20,6 @@
package me.lucko.spark.forge;
-import me.lucko.spark.common.CommandSender;
import me.lucko.spark.common.sampler.TickCounter;
import net.minecraft.client.Minecraft;
import net.minecraft.command.ICommandSender;
@@ -28,9 +27,8 @@ import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
+import java.util.stream.Stream;
public class ForgeClientSparkPlugin extends ForgeSparkPlugin {
@@ -48,8 +46,8 @@ public class ForgeClientSparkPlugin extends ForgeSparkPlugin {
}
@Override
- public Set<CommandSender> getSendersWithPermission(String permission) {
- return new HashSet<>(Collections.singleton(new ForgeCommandSender(Minecraft.getMinecraft().player, this)));
+ public Stream<ForgeCommandSender> getSendersWithPermission(String permission) {
+ return Stream.of(new ForgeCommandSender(Minecraft.getMinecraft().player, this));
}
@Override
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 ba56f44..3c686ae 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
@@ -20,7 +20,6 @@
package me.lucko.spark.forge;
-import me.lucko.spark.common.CommandSender;
import me.lucko.spark.common.sampler.TickCounter;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
@@ -28,10 +27,8 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class ForgeServerSparkPlugin extends ForgeSparkPlugin {
public ForgeServerSparkPlugin(SparkForgeMod mod) {
@@ -44,12 +41,12 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin {
}
@Override
- public Set<CommandSender> getSendersWithPermission(String permission) {
+ public Stream<ForgeCommandSender> getSendersWithPermission(String permission) {
MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance();
- List<ICommandSender> senders = new LinkedList<>(mcServer.getPlayerList().getPlayers());
- senders.removeIf(sender -> !sender.canUseCommand(4, permission));
- senders.add(mcServer);
- return senders.stream().map(sender -> new ForgeCommandSender(sender, this)).collect(Collectors.toSet());
+ return Stream.concat(
+ mcServer.getPlayerList().getPlayers().stream().filter(player -> player.canUseCommand(4, permission)),
+ Stream.of(mcServer)
+ ).map(sender -> new ForgeCommandSender(sender, this));
}
@Override