Factions/src/com/massivecraft/factions/comparator/ComparatorMPlayerInactivity.java

45 lines
1.1 KiB
Java
Raw Normal View History

package com.massivecraft.factions.comparator;
2015-01-25 00:13:19 +01:00
import com.massivecraft.factions.entity.MPlayer;
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;
2015-01-25 00:13:19 +01:00
2017-04-07 04:21:23 +02:00
public class ComparatorMPlayerInactivity extends ComparatorAbstract<MPlayer> implements Named
2015-01-25 00:13:19 +01:00
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ComparatorMPlayerInactivity i = new ComparatorMPlayerInactivity();
public static ComparatorMPlayerInactivity get() { return i; }
2015-01-25 00:13:19 +01: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 "Time";
}
2015-01-25 00:13:19 +01:00
@Override
2017-04-07 04:21:23 +02:00
public int compareInner(MPlayer m1, MPlayer m2)
2015-01-25 00:13:19 +01:00
{
// Online
boolean o1 = m1.isOnline();
boolean o2 = m2.isOnline();
if (o1 && o2) return 0;
else if (o1) return -1;
else if (o2) return +1;
// Inactivity Time
long r1 = m1.getLastActivityMillis();
long r2 = m2.getLastActivityMillis();
return (int) (r1 - r2);
}
}