2013-04-25 16:54:55 +02:00
|
|
|
package com.massivecraft.factions;
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
2014-09-17 13:17:33 +02:00
|
|
|
import com.massivecraft.factions.entity.MPlayer;
|
2013-04-25 16:54:55 +02:00
|
|
|
|
2014-09-17 13:17:33 +02:00
|
|
|
public class PlayerRoleComparator implements Comparator<MPlayer>
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// INSTANCE & CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
private static PlayerRoleComparator i = new PlayerRoleComparator();
|
|
|
|
public static PlayerRoleComparator get() { return i; }
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE: COMPARATOR
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2014-09-17 13:17:33 +02:00
|
|
|
public int compare(MPlayer o1, MPlayer o2)
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
// Null
|
|
|
|
if (o1 == null && o2 == null) ret = 0;
|
|
|
|
if (o1 == null) ret = -1;
|
|
|
|
if (o2 == null) ret = +1;
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
|
|
|
// Rank
|
2013-06-20 09:59:36 +02:00
|
|
|
Rel r1 = o1.getRole();
|
|
|
|
Rel r2 = o2.getRole();
|
2013-06-18 09:07:05 +02:00
|
|
|
return r2.getValue() - r1.getValue();
|
2013-04-25 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|