From 52023a31ffbe49dae710f3744de43da6bc65adf8 Mon Sep 17 00:00:00 2001 From: TheComputerGeek2 Date: Tue, 7 Mar 2017 11:28:52 -0800 Subject: [PATCH] Clean up the requirements --- .../factions/cmd/req/ReqBankCommandsEnabled.java | 11 ++++++----- .../factions/cmd/req/ReqFactionHomesEnabled.java | 6 +++++- .../massivecraft/factions/cmd/req/ReqHasFaction.java | 6 +++++- .../factions/cmd/req/ReqHasntFaction.java | 6 +++++- .../factions/cmd/req/ReqRoleIsAtLeast.java | 8 ++++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java b/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java index 48c0ea8d..4dd95bcc 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java +++ b/src/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java @@ -10,6 +10,10 @@ import com.massivecraft.massivecore.util.Txt; public class ReqBankCommandsEnabled extends RequirementAbstract { + // -------------------------------------------- // + // SERIALIZABLE + // -------------------------------------------- // + private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -32,11 +36,8 @@ public class ReqBankCommandsEnabled extends RequirementAbstract @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - if ( ! MConf.get().bankEnabled) - { - return Txt.parse("Faction banks are disabled."); - } - return Txt.parse("Faction economy features are disabled."); + String what = !MConf.get().bankEnabled ? "banks" : "economy features"; + return Txt.parse("Faction %s are disabled.", what); } } diff --git a/src/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java b/src/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java index bce28afe..ef6cc6f0 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java +++ b/src/com/massivecraft/factions/cmd/req/ReqFactionHomesEnabled.java @@ -9,6 +9,10 @@ import com.massivecraft.massivecore.util.Txt; public class ReqFactionHomesEnabled extends RequirementAbstract { + // -------------------------------------------- // + // SERIALIZABLE + // -------------------------------------------- // + private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -31,7 +35,7 @@ public class ReqFactionHomesEnabled extends RequirementAbstract @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - return Txt.parse("Homes must be enabled on the server to "+(command == null ? "do that" : command.getDesc())+"."); + return Txt.parse("Homes must be enabled on the server to %s.", getDesc(command)); } } diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java b/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java index de81afd4..51fa153d 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java +++ b/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java @@ -10,6 +10,10 @@ import com.massivecraft.massivecore.util.Txt; public class ReqHasFaction extends RequirementAbstract { + // -------------------------------------------- // + // SERIALIZABLE + // -------------------------------------------- // + private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -35,7 +39,7 @@ public class ReqHasFaction extends RequirementAbstract @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - return Txt.parse("You must belong to a faction to "+(command == null ? "do that" : command.getDesc())+"."); + return Txt.parse("You must belong to a faction to %s.", getDesc(command)); } } diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java b/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java index 9c8b1e1b..c5cb0984 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java +++ b/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java @@ -10,6 +10,10 @@ import com.massivecraft.massivecore.util.Txt; public class ReqHasntFaction extends RequirementAbstract { + // -------------------------------------------- // + // SERIALIZABLE + // -------------------------------------------- // + private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -35,7 +39,7 @@ public class ReqHasntFaction extends RequirementAbstract @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - return Txt.parse("You must leave your current faction before you "+(command == null ? "do that" : command.getDesc())+"."); + return Txt.parse("You must leave your current faction before you %s.", getDesc(command)); } } diff --git a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java b/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java index 4f05ac95..50abfc1d 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java +++ b/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java @@ -11,6 +11,10 @@ import com.massivecraft.massivecore.util.Txt; public class ReqRoleIsAtLeast extends RequirementAbstract { + // -------------------------------------------- // + // SERIALIZABLE + // -------------------------------------------- // + private static final long serialVersionUID = 1L; // -------------------------------------------- // @@ -37,13 +41,13 @@ public class ReqRoleIsAtLeast extends RequirementAbstract if (MUtil.isntSender(sender)) return false; MPlayer mplayer = MPlayer.get(sender); - return mplayer.getRole().isAtLeast(this.rel); + return mplayer.getRole().isAtLeast(this.getRel()); } @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - return Txt.parse("You must be %s or higher to "+(command == null ? "do that" : command.getDesc())+".", Txt.getNicedEnum(this.rel)); + return Txt.parse("You must be %s or higher to %s.", Txt.getNicedEnum(this.getRel()), getDesc(command)); } }