From 4308eda6fd4ce3d637ad29b50f53d870ec1facbc Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 3 Aug 2019 15:48:34 +0100 Subject: more cleanup work, fix build --- .../java/me/lucko/spark/forge/ForgeClientSparkPlugin.java | 8 +++----- .../java/me/lucko/spark/forge/ForgeServerSparkPlugin.java | 15 ++++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'spark-forge/src/main/java/me/lucko/spark') 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 getSendersWithPermission(String permission) { - return new HashSet<>(Collections.singleton(new ForgeCommandSender(Minecraft.getMinecraft().player, this))); + public Stream 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 getSendersWithPermission(String permission) { + public Stream getSendersWithPermission(String permission) { MinecraftServer mcServer = FMLCommonHandler.instance().getMinecraftServerInstance(); - List 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 -- cgit