mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 06:06:45 +01:00
refactor: replace guava's Iterables with Java's stream API (#3823)
This commit is contained in:
parent
1b717c9b10
commit
5786e8cc7a
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.listener;
|
package com.plotsquared.bukkit.listener;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
@ -39,8 +38,11 @@ public class ForceFieldListener {
|
|||||||
|
|
||||||
private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) {
|
private static Set<PlotPlayer<?>> getNearbyPlayers(Player player, Plot plot) {
|
||||||
Set<PlotPlayer<?>> players = new HashSet<>();
|
Set<PlotPlayer<?>> players = new HashSet<>();
|
||||||
for (Player nearPlayer : Iterables
|
for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream()
|
||||||
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
.filter(entity -> entity instanceof Player)
|
||||||
|
.map(entity -> (Player) entity)
|
||||||
|
.toList()
|
||||||
|
) {
|
||||||
PlotPlayer<?> plotPlayer;
|
PlotPlayer<?> plotPlayer;
|
||||||
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
||||||
.equals(plotPlayer.getCurrentPlot())) {
|
.equals(plotPlayer.getCurrentPlot())) {
|
||||||
@ -54,8 +56,11 @@ public class ForceFieldListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PlotPlayer<?> hasNearbyPermitted(Player player, Plot plot) {
|
private static PlotPlayer<?> hasNearbyPermitted(Player player, Plot plot) {
|
||||||
for (Player nearPlayer : Iterables
|
for (Player nearPlayer : player.getNearbyEntities(5d, 5d, 5d).stream()
|
||||||
.filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
|
.filter(entity -> entity instanceof Player)
|
||||||
|
.map(entity -> (Player) entity)
|
||||||
|
.toList()
|
||||||
|
) {
|
||||||
PlotPlayer<?> plotPlayer;
|
PlotPlayer<?> plotPlayer;
|
||||||
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
if ((plotPlayer = BukkitUtil.adapt(nearPlayer)) == null || !plot
|
||||||
.equals(plotPlayer.getCurrentPlot())) {
|
.equals(plotPlayer.getCurrentPlot())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user