Skip to content

Commit

Permalink
refactor: replace guava's Iterables with Java's stream API (#3823)
Browse files Browse the repository at this point in the history
  • Loading branch information
StealWonders authored Oct 3, 2022
1 parent 1b717c9 commit 5786e8c
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,8 +38,11 @@ public class ForceFieldListener {

private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) {
Set<PlotPlayer<?>> 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())) {
Expand All @@ -54,8 +56,11 @@ private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) {
}

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())) {
Expand Down

0 comments on commit 5786e8c

Please sign in to comment.