2017-03-24 14:25:29 +01:00
|
|
|
package com.massivecraft.factions.comparator;
|
2013-04-25 16:54:55 +02:00
|
|
|
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2018-12-20 01:35:30 +01:00
|
|
|
import com.massivecraft.factions.entity.Rank;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.Named;
|
2017-04-07 04:21:23 +02:00
|
|
|
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
|
2013-04-25 16:54:55 +02:00
|
|
|
|
2017-04-07 04:21:23 +02:00
|
|
|
public class ComparatorMPlayerRole extends ComparatorAbstract<MPlayer> implements Named
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// INSTANCE & CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2017-03-24 14:25:29 +01:00
|
|
|
private static ComparatorMPlayerRole i = new ComparatorMPlayerRole();
|
|
|
|
public static ComparatorMPlayerRole get() { return i; }
|
2013-04-25 16:54:55 +02:00
|
|
|
|
2015-11-06 02:10:29 +01:00
|
|
|
// -------------------------------------------- //
|
2017-04-07 04:21:23 +02:00
|
|
|
// OVERRIDE
|
2015-11-06 02:10:29 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName()
|
|
|
|
{
|
|
|
|
return "Rank";
|
|
|
|
}
|
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
@Override
|
2017-04-07 04:21:23 +02:00
|
|
|
public int compareInner(MPlayer m1, MPlayer m2)
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
// Rank
|
2018-12-20 01:35:30 +01:00
|
|
|
if (m1.getFaction() != m2.getFaction()) throw new IllegalArgumentException("Noncomparable players");
|
|
|
|
Rank r1 = m1.getRank();
|
|
|
|
Rank r2 = m2.getRank();
|
|
|
|
return r2.getPriority() - r1.getPriority() ;
|
2013-04-25 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|