Attempt to fix #31

But the real question is why some MPlayers had no id. I really have no clue why.
This commit is contained in:
Magnus Ulf
2019-05-03 09:59:10 +02:00
parent 61bea411f5
commit 51135db452
3 changed files with 15 additions and 16 deletions

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.comparator.ComparatorFactionList;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.comparator.ComparatorFactionList;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPlayer;
@@ -9,11 +9,15 @@ import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.Parameter;
import com.massivecraft.massivecore.pager.Pager;
import com.massivecraft.massivecore.pager.Stringifier;
import com.massivecraft.massivecore.predicate.PredicateAnd;
import com.massivecraft.massivecore.predicate.PredicateVisibleTo;
import com.massivecraft.massivecore.store.SenderColl;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import java.util.List;
import java.util.function.Predicate;
public class CmdFactionsList extends FactionsCommand
{
@@ -41,7 +45,9 @@ public class CmdFactionsList extends FactionsCommand
// NOTE: The faction list is quite slow and mostly thread safe.
// We run it asynchronously to spare the primary server thread.
Predicate<MPlayer> predicateOnline = PredicateAnd.get(mp -> mp.getId() != null, SenderColl.PREDICATE_ONLINE, PredicateVisibleTo.get(sender));
// Pager Create
final Pager<Faction> pager = new Pager<>(this, "Faction List", page, (Stringifier<Faction>) (faction, index) -> {
if (faction.isNone())
@@ -52,7 +58,7 @@ public class CmdFactionsList extends FactionsCommand
{
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getName(msender),
faction.getMPlayersWhereOnlineTo(sender).size(),
faction.getMPlayersWhere(predicateOnline).size(),
faction.getMPlayers().size(),
faction.getLandCount(),
faction.getPowerRounded(),