Factions/src/com/massivecraft/factions/comparator/ComparatorMPlayerRole.java
Magnus Ulf f347c1058a Rank rework
This makes an under the hood rank-rework. Nothing is changed from the player perspective.
2018-12-20 15:17:20 +01:00

38 lines
1.1 KiB
Java

package com.massivecraft.factions.comparator;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Rank;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
public class ComparatorMPlayerRole extends ComparatorAbstract<MPlayer> implements Named
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ComparatorMPlayerRole i = new ComparatorMPlayerRole();
public static ComparatorMPlayerRole get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String getName()
{
return "Rank";
}
@Override
public int compareInner(MPlayer m1, MPlayer m2)
{
// Rank
if (m1.getFaction() != m2.getFaction()) throw new IllegalArgumentException("Noncomparable players");
Rank r1 = m1.getRank();
Rank r2 = m2.getRank();
return r2.getPriority() - r1.getPriority() ;
}
}