From 83b12fddc8fa2c3534ceb97a36ea6b8214c0f1f9 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 24 Mar 2017 14:25:29 +0100 Subject: [PATCH] Rename and relocate Comparators and Predicates --- .../factions/cmd/CmdFactionsList.java | 4 ++-- .../factions/cmd/CmdFactionsStatus.java | 4 ++-- .../factions/cmd/type/TypeSortMPlayer.java | 12 ++++++------ .../ComparatorFactionList.java} | 8 ++++---- .../ComparatorMPlayerInactivity.java} | 8 ++++---- .../ComparatorMPlayerPower.java} | 8 ++++---- .../ComparatorMPlayerRole.java} | 9 +++++---- .../factions/engine/EngineShow.java | 4 ++-- .../massivecraft/factions/entity/Faction.java | 18 +++++++++--------- .../PredicateCommandSenderFaction.java} | 6 +++--- .../PredicateMPlayerRole.java} | 9 +++++---- 11 files changed, 46 insertions(+), 44 deletions(-) rename src/com/massivecraft/factions/{FactionListComparator.java => comparator/ComparatorFactionList.java} (82%) rename src/com/massivecraft/factions/{PlayerInactivityComparator.java => comparator/ComparatorMPlayerInactivity.java} (76%) rename src/com/massivecraft/factions/{PlayerPowerComparator.java => comparator/ComparatorMPlayerPower.java} (77%) rename src/com/massivecraft/factions/{PlayerRoleComparator.java => comparator/ComparatorMPlayerRole.java} (72%) rename src/com/massivecraft/factions/{FactionEqualsPredicate.java => predicate/PredicateCommandSenderFaction.java} (81%) rename src/com/massivecraft/factions/{PredicateRole.java => predicate/PredicateMPlayerRole.java} (71%) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/com/massivecraft/factions/cmd/CmdFactionsList.java index 5407e654..ac78b5ee 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -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 factions = FactionColl.get().getAll(FactionListComparator.get(sender)); + final List factions = FactionColl.get().getAll(ComparatorFactionList.get(sender)); pager.setItems(factions); // Pager Message diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java index b54d7866..405b4c04 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java @@ -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 sortedBy = this.readArg(PlayerInactivityComparator.get()); + Comparator sortedBy = this.readArg(ComparatorMPlayerInactivity.get()); // MPerm if ( ! MPerm.getPermStatus().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/type/TypeSortMPlayer.java b/src/com/massivecraft/factions/cmd/type/TypeSortMPlayer.java index 7e608e91..404e2e2c 100644 --- a/src/com/massivecraft/factions/cmd/type/TypeSortMPlayer.java +++ b/src/com/massivecraft/factions/cmd/type/TypeSortMPlayer.java @@ -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> { super(Comparator.class); this.setAll( - PlayerRoleComparator.get(), - PlayerPowerComparator.get(), - PlayerInactivityComparator.get() + ComparatorMPlayerRole.get(), + ComparatorMPlayerPower.get(), + ComparatorMPlayerInactivity.get() ); } diff --git a/src/com/massivecraft/factions/FactionListComparator.java b/src/com/massivecraft/factions/comparator/ComparatorFactionList.java similarity index 82% rename from src/com/massivecraft/factions/FactionListComparator.java rename to src/com/massivecraft/factions/comparator/ComparatorFactionList.java index 0d903f59..e2274525 100644 --- a/src/com/massivecraft/factions/FactionListComparator.java +++ b/src/com/massivecraft/factions/comparator/ComparatorFactionList.java @@ -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 +public class ComparatorFactionList implements Comparator { // -------------------------------------------- // // FIELDS @@ -21,8 +21,8 @@ public class FactionListComparator implements Comparator // 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)); } diff --git a/src/com/massivecraft/factions/PlayerInactivityComparator.java b/src/com/massivecraft/factions/comparator/ComparatorMPlayerInactivity.java similarity index 76% rename from src/com/massivecraft/factions/PlayerInactivityComparator.java rename to src/com/massivecraft/factions/comparator/ComparatorMPlayerInactivity.java index beace4ee..94c4845c 100644 --- a/src/com/massivecraft/factions/PlayerInactivityComparator.java +++ b/src/com/massivecraft/factions/comparator/ComparatorMPlayerInactivity.java @@ -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, Named +public class ComparatorMPlayerInactivity implements Comparator, 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 diff --git a/src/com/massivecraft/factions/PlayerPowerComparator.java b/src/com/massivecraft/factions/comparator/ComparatorMPlayerPower.java similarity index 77% rename from src/com/massivecraft/factions/PlayerPowerComparator.java rename to src/com/massivecraft/factions/comparator/ComparatorMPlayerPower.java index fd1e2242..978d2d37 100644 --- a/src/com/massivecraft/factions/PlayerPowerComparator.java +++ b/src/com/massivecraft/factions/comparator/ComparatorMPlayerPower.java @@ -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, Named +public class ComparatorMPlayerPower implements Comparator, 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 diff --git a/src/com/massivecraft/factions/PlayerRoleComparator.java b/src/com/massivecraft/factions/comparator/ComparatorMPlayerRole.java similarity index 72% rename from src/com/massivecraft/factions/PlayerRoleComparator.java rename to src/com/massivecraft/factions/comparator/ComparatorMPlayerRole.java index 43a84073..874f32f2 100644 --- a/src/com/massivecraft/factions/PlayerRoleComparator.java +++ b/src/com/massivecraft/factions/comparator/ComparatorMPlayerRole.java @@ -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, Named +public class ComparatorMPlayerRole implements Comparator, 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 diff --git a/src/com/massivecraft/factions/engine/EngineShow.java b/src/com/massivecraft/factions/engine/EngineShow.java index 384abc21..da88a545 100644 --- a/src/com/massivecraft/factions/engine/EngineShow.java +++ b/src/com/massivecraft/factions/engine/EngineShow.java @@ -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 followerNamesOffline = new ArrayList<>(); List followers = faction.getMPlayers(); - Collections.sort(followers, PlayerRoleComparator.get()); + Collections.sort(followers, ComparatorMPlayerRole.get()); for (MPlayer follower : followers) { if (follower.isOnline(sender)) diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index dae18c5c..63f9c508 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -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 implements FactionsParticipator public List 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 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 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 msgs) { - return MixinMessage.get().msgPredicate(new FactionEqualsPredicate(this), msgs); + return MixinMessage.get().msgPredicate(new PredicateCommandSenderFaction(this), msgs); } } diff --git a/src/com/massivecraft/factions/FactionEqualsPredicate.java b/src/com/massivecraft/factions/predicate/PredicateCommandSenderFaction.java similarity index 81% rename from src/com/massivecraft/factions/FactionEqualsPredicate.java rename to src/com/massivecraft/factions/predicate/PredicateCommandSenderFaction.java index 36c71cfb..7b8fcdc1 100644 --- a/src/com/massivecraft/factions/FactionEqualsPredicate.java +++ b/src/com/massivecraft/factions/predicate/PredicateCommandSenderFaction.java @@ -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, Serializable +public class PredicateCommandSenderFaction implements Predicate, Serializable { private static final long serialVersionUID = 1L; @@ -23,7 +23,7 @@ public class FactionEqualsPredicate implements Predicate, Seriali // CONSTRUCT // -------------------------------------------- // - public FactionEqualsPredicate(Faction faction) + public PredicateCommandSenderFaction(Faction faction) { this.factionId = faction.getId(); } diff --git a/src/com/massivecraft/factions/PredicateRole.java b/src/com/massivecraft/factions/predicate/PredicateMPlayerRole.java similarity index 71% rename from src/com/massivecraft/factions/PredicateRole.java rename to src/com/massivecraft/factions/predicate/PredicateMPlayerRole.java index 177825d5..b56eeb21 100644 --- a/src/com/massivecraft/factions/PredicateRole.java +++ b/src/com/massivecraft/factions/predicate/PredicateMPlayerRole.java @@ -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 +public class PredicateMPlayerRole implements Predicate { // -------------------------------------------- // // FIELDS @@ -16,8 +17,8 @@ public class PredicateRole implements Predicate // 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; }