Rename and relocate Comparators and Predicates
This commit is contained in:
parent
2dfce5ea3a
commit
83b12fddc8
@ -1,6 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FactionListComparator;
|
||||
import com.massivecraft.factions.comparator.ComparatorFactionList;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
@ -71,7 +71,7 @@ public class CmdFactionsList extends FactionsCommand
|
||||
public void run()
|
||||
{
|
||||
// Pager Items
|
||||
final List<Faction> factions = FactionColl.get().getAll(FactionListComparator.get(sender));
|
||||
final List<Faction> factions = FactionColl.get().getAll(ComparatorFactionList.get(sender));
|
||||
pager.setItems(factions);
|
||||
|
||||
// Pager Message
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.PlayerInactivityComparator;
|
||||
import com.massivecraft.factions.comparator.ComparatorMPlayerInactivity;
|
||||
import com.massivecraft.factions.cmd.type.TypeFaction;
|
||||
import com.massivecraft.factions.cmd.type.TypeSortMPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
@ -43,7 +43,7 @@ public class CmdFactionsStatus extends FactionsCommand
|
||||
// Args
|
||||
int page = this.readArg();
|
||||
Faction faction = this.readArg(msenderFaction);
|
||||
Comparator<MPlayer> sortedBy = this.readArg(PlayerInactivityComparator.get());
|
||||
Comparator<MPlayer> sortedBy = this.readArg(ComparatorMPlayerInactivity.get());
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermStatus().has(msender, faction, true)) return;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.massivecraft.factions.cmd.type;
|
||||
|
||||
import com.massivecraft.factions.PlayerInactivityComparator;
|
||||
import com.massivecraft.factions.PlayerPowerComparator;
|
||||
import com.massivecraft.factions.PlayerRoleComparator;
|
||||
import com.massivecraft.factions.comparator.ComparatorMPlayerInactivity;
|
||||
import com.massivecraft.factions.comparator.ComparatorMPlayerPower;
|
||||
import com.massivecraft.factions.comparator.ComparatorMPlayerRole;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.command.type.TypeAbstractChoice;
|
||||
|
||||
@ -20,9 +20,9 @@ public class TypeSortMPlayer extends TypeAbstractChoice<Comparator<MPlayer>>
|
||||
{
|
||||
super(Comparator.class);
|
||||
this.setAll(
|
||||
PlayerRoleComparator.get(),
|
||||
PlayerPowerComparator.get(),
|
||||
PlayerInactivityComparator.get()
|
||||
ComparatorMPlayerRole.get(),
|
||||
ComparatorMPlayerPower.get(),
|
||||
ComparatorMPlayerInactivity.get()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.comparator.ComparatorComparable;
|
||||
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class FactionListComparator implements Comparator<Faction>
|
||||
public class ComparatorFactionList implements Comparator<Faction>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
@ -21,8 +21,8 @@ public class FactionListComparator implements Comparator<Faction>
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static FactionListComparator get(Object watcherObject) { return new FactionListComparator(watcherObject); }
|
||||
public FactionListComparator(Object watcherObject)
|
||||
public static ComparatorFactionList get(Object watcherObject) { return new ComparatorFactionList(watcherObject); }
|
||||
public ComparatorFactionList(Object watcherObject)
|
||||
{
|
||||
this.watcher = new WeakReference<>(IdUtil.getSender(watcherObject));
|
||||
}
|
@ -1,18 +1,18 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class PlayerInactivityComparator implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerInactivity implements Comparator<MPlayer>, Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PlayerInactivityComparator i = new PlayerInactivityComparator();
|
||||
public static PlayerInactivityComparator get() { return i; }
|
||||
private static ComparatorMPlayerInactivity i = new ComparatorMPlayerInactivity();
|
||||
public static ComparatorMPlayerInactivity get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
@ -1,18 +1,18 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class PlayerPowerComparator implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerPower implements Comparator<MPlayer>, Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PlayerPowerComparator i = new PlayerPowerComparator();
|
||||
public static PlayerPowerComparator get() { return i; }
|
||||
private static ComparatorMPlayerPower i = new ComparatorMPlayerPower();
|
||||
public static ComparatorMPlayerPower get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
@ -1,18 +1,19 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.comparator;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.Named;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class PlayerRoleComparator implements Comparator<MPlayer>, Named
|
||||
public class ComparatorMPlayerRole implements Comparator<MPlayer>, Named
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PlayerRoleComparator i = new PlayerRoleComparator();
|
||||
public static PlayerRoleComparator get() { return i; }
|
||||
private static ComparatorMPlayerRole i = new ComparatorMPlayerRole();
|
||||
public static ComparatorMPlayerRole get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE: NAMED
|
@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.engine;
|
||||
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.PlayerRoleComparator;
|
||||
import com.massivecraft.factions.comparator.ComparatorMPlayerRole;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
@ -143,7 +143,7 @@ public class EngineShow extends Engine
|
||||
List<String> followerNamesOffline = new ArrayList<>();
|
||||
|
||||
List<MPlayer> followers = faction.getMPlayers();
|
||||
Collections.sort(followers, PlayerRoleComparator.get());
|
||||
Collections.sort(followers, ComparatorMPlayerRole.get());
|
||||
for (MPlayer follower : followers)
|
||||
{
|
||||
if (follower.isOnline(sender))
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.massivecraft.factions.entity;
|
||||
|
||||
import com.massivecraft.factions.FactionEqualsPredicate;
|
||||
import com.massivecraft.factions.predicate.PredicateCommandSenderFaction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsParticipator;
|
||||
import com.massivecraft.factions.Lang;
|
||||
import com.massivecraft.factions.PredicateRole;
|
||||
import com.massivecraft.factions.predicate.PredicateMPlayerRole;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.RelationParticipator;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
@ -1070,7 +1070,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
|
||||
|
||||
public List<MPlayer> getMPlayersWhereRole(Rel role)
|
||||
{
|
||||
return this.getMPlayersWhere(PredicateRole.get(role));
|
||||
return this.getMPlayersWhere(PredicateMPlayerRole.get(role));
|
||||
}
|
||||
|
||||
public MPlayer getLeader()
|
||||
@ -1221,34 +1221,34 @@ public class Faction extends Entity<Faction> implements FactionsParticipator
|
||||
|
||||
public boolean sendMessage(Object message)
|
||||
{
|
||||
return MixinMessage.get().messagePredicate(new FactionEqualsPredicate(this), message);
|
||||
return MixinMessage.get().messagePredicate(new PredicateCommandSenderFaction(this), message);
|
||||
}
|
||||
|
||||
public boolean sendMessage(Object... messages)
|
||||
{
|
||||
return MixinMessage.get().messagePredicate(new FactionEqualsPredicate(this), messages);
|
||||
return MixinMessage.get().messagePredicate(new PredicateCommandSenderFaction(this), messages);
|
||||
}
|
||||
|
||||
public boolean sendMessage(Collection<Object> messages)
|
||||
{
|
||||
return MixinMessage.get().messagePredicate(new FactionEqualsPredicate(this), messages);
|
||||
return MixinMessage.get().messagePredicate(new PredicateCommandSenderFaction(this), messages);
|
||||
}
|
||||
|
||||
// CONVENIENCE MSG
|
||||
|
||||
public boolean msg(String msg)
|
||||
{
|
||||
return MixinMessage.get().msgPredicate(new FactionEqualsPredicate(this), msg);
|
||||
return MixinMessage.get().msgPredicate(new PredicateCommandSenderFaction(this), msg);
|
||||
}
|
||||
|
||||
public boolean msg(String msg, Object... args)
|
||||
{
|
||||
return MixinMessage.get().msgPredicate(new FactionEqualsPredicate(this), msg, args);
|
||||
return MixinMessage.get().msgPredicate(new PredicateCommandSenderFaction(this), msg, args);
|
||||
}
|
||||
|
||||
public boolean msg(Collection<String> msgs)
|
||||
{
|
||||
return MixinMessage.get().msgPredicate(new FactionEqualsPredicate(this), msgs);
|
||||
return MixinMessage.get().msgPredicate(new PredicateCommandSenderFaction(this), msgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.predicate;
|
||||
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class FactionEqualsPredicate implements Predicate<CommandSender>, Serializable
|
||||
public class PredicateCommandSenderFaction implements Predicate<CommandSender>, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -23,7 +23,7 @@ public class FactionEqualsPredicate implements Predicate<CommandSender>, Seriali
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public FactionEqualsPredicate(Faction faction)
|
||||
public PredicateCommandSenderFaction(Faction faction)
|
||||
{
|
||||
this.factionId = faction.getId();
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package com.massivecraft.factions;
|
||||
package com.massivecraft.factions.predicate;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.massivecore.predicate.Predicate;
|
||||
|
||||
public class PredicateRole implements Predicate<MPlayer>
|
||||
public class PredicateMPlayerRole implements Predicate<MPlayer>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
@ -16,8 +17,8 @@ public class PredicateRole implements Predicate<MPlayer>
|
||||
// INSTANCE AND CONTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static PredicateRole get(Rel role) { return new PredicateRole(role); }
|
||||
public PredicateRole(Rel role)
|
||||
public static PredicateMPlayerRole get(Rel role) { return new PredicateMPlayerRole(role); }
|
||||
public PredicateMPlayerRole(Rel role)
|
||||
{
|
||||
this.role = role;
|
||||
}
|
Loading…
Reference in New Issue
Block a user