diff options
author | Luck <git@lucko.me> | 2019-08-03 15:48:34 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2019-08-03 15:48:34 +0100 |
commit | 4308eda6fd4ce3d637ad29b50f53d870ec1facbc (patch) | |
tree | 893f48b04d89ada7ed3f7e436a28ad538c49fe41 /spark-forge/src/main/java/me/lucko/spark | |
parent | 9d5aad9413ec8a219549f626db6e33ccca2f5acf (diff) | |
download | spark-4308eda6fd4ce3d637ad29b50f53d870ec1facbc.tar.gz spark-4308eda6fd4ce3d637ad29b50f53d870ec1facbc.tar.bz2 spark-4308eda6fd4ce3d637ad29b50f53d870ec1facbc.zip |
more cleanup work, fix build
Diffstat (limited to 'spark-forge/src/main/java/me/lucko/spark')
-rw-r--r-- | spark-forge/src/main/java/me/lucko/spark/forge/ForgeClientSparkPlugin.java | 8 | ||||
-rw-r--r-- | spark-forge/src/main/java/me/lucko/spark/forge/ForgeServerSparkPlugin.java | 15 |
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 |