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.
This commit is contained in:
TheComputerGeek2 2017-05-01 12:15:25 -07:00 committed by Olof Larsson
parent faf736a013
commit 3f123922ba

View File

@ -31,6 +31,7 @@ import org.bukkit.entity.Player;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -984,14 +985,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
return new MassiveList<>(FactionsIndex.get().getMPlayers(this)); return new MassiveList<>(FactionsIndex.get().getMPlayers(this));
} }
public List<MPlayer> getMPlayers(Predicate<? super MPlayer> where, Comparator<? super MPlayer> orderby, Integer limit, Integer offset)
{
return MUtil.transform(this.getMPlayers(), where, orderby, limit, offset);
}
public List<MPlayer> getMPlayersWhere(Predicate<? super MPlayer> predicate) public List<MPlayer> getMPlayersWhere(Predicate<? super MPlayer> predicate)
{ {
List<MPlayer> ret = this.getMPlayers(); return this.getMPlayers(predicate, null, null, null);
for (Iterator<MPlayer> it = ret.iterator(); it.hasNext();)
{
if ( ! predicate.apply(it.next())) it.remove();
}
return ret;
} }
public List<MPlayer> getMPlayersWhereOnline(boolean online) public List<MPlayer> getMPlayersWhereOnline(boolean online)