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;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.Named;
|
2013-04-25 16:54:55 +02:00
|
|
|
|
2015-11-06 02:10:29 +01:00
|
|
|
public class PlayerRoleComparator implements Comparator<MPlayer>, Named
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// INSTANCE & CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
private static PlayerRoleComparator i = new PlayerRoleComparator();
|
|
|
|
public static PlayerRoleComparator get() { return i; }
|
|
|
|
|
2015-11-06 02:10:29 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE: NAMED
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName()
|
|
|
|
{
|
|
|
|
return "Rank";
|
|
|
|
}
|
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE: COMPARATOR
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2015-01-25 00:13:19 +01:00
|
|
|
public int compare(MPlayer m1, MPlayer m2)
|
2013-04-25 16:54:55 +02:00
|
|
|
{
|
|
|
|
// Null
|
2015-01-25 00:13:19 +01:00
|
|
|
if (m1 == null && m2 == null) return 0;
|
|
|
|
else if (m1 == null) return -1;
|
|
|
|
else if (m2 == null) return +1;
|
2013-04-25 16:54:55 +02:00
|
|
|
|
|
|
|
// Rank
|
2015-01-25 00:13:19 +01:00
|
|
|
Rel r1 = m1.getRole();
|
|
|
|
Rel r2 = m2.getRole();
|
2013-06-18 09:07:05 +02:00
|
|
|
return r2.getValue() - r1.getValue();
|
2013-04-25 16:54:55 +02:00
|
|
|
}
|
|
|
|
|
2015-11-06 02:10:29 +01:00
|
|
|
|
|
|
|
|
2013-04-25 16:54:55 +02:00
|
|
|
}
|