From 3f123922bae9b57ab312ecdd1d31d2fb266ebc8d Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Mon, 1 May 2017 12:15:25 -0700 Subject: [PATCH] Have getMPlayersWhere use MUtil's transform method Minor reduction in redundant code and safely handles null passed as the predicate Added a new signature of getMPlayers which accomadates for all of MUtil.transform's parameters, similar to what is available in CollAbstract. --- src/com/massivecraft/factions/entity/Faction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index af6f7603..3868a110 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -31,6 +31,7 @@ import org.bukkit.entity.Player; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -984,14 +985,14 @@ public class Faction extends Entity implements FactionsParticipator return new MassiveList<>(FactionsIndex.get().getMPlayers(this)); } + public List getMPlayers(Predicate where, Comparator orderby, Integer limit, Integer offset) + { + return MUtil.transform(this.getMPlayers(), where, orderby, limit, offset); + } + public List getMPlayersWhere(Predicate predicate) { - List ret = this.getMPlayers(); - for (Iterator it = ret.iterator(); it.hasNext();) - { - if ( ! predicate.apply(it.next())) it.remove(); - } - return ret; + return this.getMPlayers(predicate, null, null, null); } public List getMPlayersWhereOnline(boolean online)