Cleanup comparators
This commit is contained in:
parent
31823f5311
commit
89400cdb36
@ -1,14 +1,14 @@
|
||||
package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorComparable;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ComparatorFactionList implements Comparator<Faction>
|
||||
public class ComparatorFactionList extends ComparatorAbstract<Faction>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
@ -28,28 +28,19 @@ public class ComparatorFactionList implements Comparator<Faction>
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: COMPARATOR
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2)
|
||||
public int compareInner(Faction f1, Faction f2)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// Null
|
||||
if (f1 == null && f2 == null) ret = 0;
|
||||
if (f1 == null) ret = -1;
|
||||
if (f2 == null) ret = +1;
|
||||
if (ret != 0) return ret;
|
||||
|
||||
// None a.k.a. Wilderness
|
||||
if (f1.isNone() && f2.isNone()) ret = 0;
|
||||
if (f1.isNone()) ret = -1;
|
||||
if (f2.isNone()) ret = +1;
|
||||
if (ret != 0) return ret;
|
||||
if (f1.isNone() && f2.isNone()) return 0;
|
||||
if (f1.isNone()) return -1;
|
||||
if (f2.isNone()) return 1;
|
||||
|
||||
// Players Online
|
||||
ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size();
|
||||
int ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size();
|
||||
if (ret != 0) return ret;
|
||||
|
||||
// Players Total
|
||||
|
@ -2,10 +2,9 @@ package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ComparatorMPlayerInactivity implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerInactivity extends ComparatorAbstract<MPlayer> implements Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -15,7 +14,7 @@ public class ComparatorMPlayerInactivity implements Comparator<MPlayer>, Named
|
||||
public static ComparatorMPlayerInactivity get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
@ -24,18 +23,9 @@ public class ComparatorMPlayerInactivity implements Comparator<MPlayer>, Named
|
||||
return "Time";
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: COMPARATOR
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int compare(MPlayer m1, MPlayer m2)
|
||||
public int compareInner(MPlayer m1, MPlayer m2)
|
||||
{
|
||||
// Null
|
||||
if (m1 == null && m2 == null) return 0;
|
||||
else if (m1 == null) return -1;
|
||||
else if (m2 == null) return +1;
|
||||
|
||||
// Online
|
||||
boolean o1 = m1.isOnline();
|
||||
boolean o2 = m2.isOnline();
|
||||
|
@ -2,10 +2,9 @@ package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ComparatorMPlayerPower implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerPower extends ComparatorAbstract<MPlayer> implements Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -15,7 +14,7 @@ public class ComparatorMPlayerPower implements Comparator<MPlayer>, Named
|
||||
public static ComparatorMPlayerPower get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
@ -24,32 +23,15 @@ public class ComparatorMPlayerPower implements Comparator<MPlayer>, Named
|
||||
return "Power";
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: COMPARATOR
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int compare(MPlayer m1, MPlayer m2)
|
||||
public int compareInner(MPlayer m1, MPlayer m2)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
// Null
|
||||
if (m1 == null && m2 == null) return 0;
|
||||
else if (m1 == null) return -1;
|
||||
else if (m2 == null) return +1;
|
||||
|
||||
// Power
|
||||
int p1 = m1.getPowerRounded();
|
||||
int p2 = m2.getPowerRounded();
|
||||
ret = p1 - p2;
|
||||
int ret = m1.getPowerRounded() - m2.getPowerRounded();
|
||||
if (ret != 0) return ret;
|
||||
|
||||
// MaxPower
|
||||
int max1 = m1.getPowerMaxRounded();
|
||||
int max2 = m2.getPowerMaxRounded();
|
||||
ret = max1 - max2;
|
||||
|
||||
return ret;
|
||||
return m1.getPowerMaxRounded() - m2.getPowerMaxRounded();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,9 @@ package com.massivecraft.factions.comparator;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorAbstract;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ComparatorMPlayerRole implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerRole extends ComparatorAbstract<MPlayer> implements Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
@ -16,7 +15,7 @@ public class ComparatorMPlayerRole implements Comparator<MPlayer>, Named
|
||||
public static ComparatorMPlayerRole get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
@ -25,24 +24,13 @@ public class ComparatorMPlayerRole implements Comparator<MPlayer>, Named
|
||||
return "Rank";
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: COMPARATOR
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public int compare(MPlayer m1, MPlayer m2)
|
||||
public int compareInner(MPlayer m1, MPlayer m2)
|
||||
{
|
||||
// Null
|
||||
if (m1 == null && m2 == null) return 0;
|
||||
else if (m1 == null) return -1;
|
||||
else if (m2 == null) return +1;
|
||||
|
||||
// Rank
|
||||
Rel r1 = m1.getRole();
|
||||
Rel r2 = m2.getRole();
|
||||
return r2.getValue() - r1.getValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user