From 5786e8cc7a5657e06b34d7b4978a2df5033d715f Mon Sep 17 00:00:00 2001 From: StealWonders <6114858+StealWonders@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:51:05 +0200 Subject: [PATCH] refactor: replace guava's Iterables with Java's stream API (#3823) --- .../bukkit/listener/ForceFieldListener.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java index 32c0ce853..8c4b5b9b6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ForceFieldListener.java @@ -18,7 +18,6 @@ */ package com.plotsquared.bukkit.listener; -import com.google.common.collect.Iterables; import com.plotsquared.bukkit.player.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.core.location.Location; @@ -39,8 +38,11 @@ public class ForceFieldListener { private static Set> getNearbyPlayers(Player player, Plot plot) { Set> players = new HashSet<>(); - for (Player nearPlayer : Iterables - .filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) { + for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream() + .filter(entity -> entity instanceof Player) + .map(entity -> (Player) entity) + .toList() + ) { PlotPlayer plotPlayer; if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot .equals(plotPlayer.getCurrentPlot())) { @@ -54,8 +56,11 @@ public class ForceFieldListener { } private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) { - for (Player nearPlayer : Iterables - .filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) { + for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream() + .filter(entity -> entity instanceof Player) + .map(entity -> (Player) entity) + .toList() + ) { PlotPlayer plotPlayer; if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot .equals(plotPlayer.getCurrentPlot())) {