From 7a99005f7b891e97f91431ecc6005edccbaec983 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 25 Apr 2013 13:53:22 +0200 Subject: [PATCH] Tweaking requirements, removing declaim aliases and shortening the author list by using minecraft name only. --- plugin.yml | 2 +- .../factions/cmd/CmdFactionsCreate.java | 8 +--- .../factions/cmd/CmdFactionsDescription.java | 2 + .../factions/cmd/CmdFactionsHome.java | 6 +-- .../factions/cmd/CmdFactionsInvite.java | 2 + .../factions/cmd/CmdFactionsLeave.java | 5 +-- .../factions/cmd/CmdFactionsName.java | 2 + .../factions/cmd/CmdFactionsOpen.java | 2 + .../cmd/CmdFactionsRelationAbstract.java | 2 + .../factions/cmd/CmdFactionsUnclaim.java | 4 +- .../factions/cmd/CmdFactionsUnclaimall.java | 4 +- .../factions/cmd/req/ReqHasFaction.java | 37 +++++++++++++++++++ .../factions/cmd/req/ReqHasntFaction.java | 37 +++++++++++++++++++ 13 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 src/com/massivecraft/factions/cmd/req/ReqHasFaction.java create mode 100644 src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java diff --git a/plugin.yml b/plugin.yml index eaa7b299..ee7daad5 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ main: com.massivecraft.factions.Factions name: Factions version: 2.0.0_dev website: http://massivecraft.com/factions -authors: [Olof "Cayorion" Larsson, Brett Flannigan] +authors: [Cayorion, Brettflan] depend: [mcore] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag] permissions: diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java index a2359d76..bb2016be 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasntFaction; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.Faction; @@ -26,6 +27,7 @@ public class CmdFactionsCreate extends FCommand this.addRequiredArg("name"); this.addRequirements(ReqFactionsEnabled.get()); + this.addRequirements(ReqHasntFaction.get()); this.addRequirements(ReqHasPerm.get(Perm.CREATE.node)); } @@ -36,12 +38,6 @@ public class CmdFactionsCreate extends FCommand String newName = this.arg(0); // Verify - if (usender.getFaction().isNormal()) - { - msg("You must leave your current faction first."); - return; - } - FactionColl coll = FactionColls.get().get(usender); if (coll.isNameTaken(newName)) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java b/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java index b802614d..f729d27f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.event.FactionsEventDescriptionChange; import com.massivecraft.mcore.cmd.req.ReqHasPerm; @@ -19,6 +20,7 @@ public class CmdFactionsDescription extends FCommand this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index a4551c67..725a14b2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -9,7 +9,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.entity.UPlayer; @@ -28,10 +28,10 @@ public class CmdFactionsHome extends FCommand { this.addAliases("home"); - this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); this.addRequirements(ReqFactionsEnabled.get()); + this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); - this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT)); } @Override diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java index 22b02ded..dc078e10 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.event.FactionsEventInvitedChange; import com.massivecraft.mcore.cmd.arg.ARBoolean; @@ -22,6 +23,7 @@ public class CmdFactionsInvite extends FCommand this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.INVITE.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java b/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java index 7606a0af..ddf36068 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java @@ -1,9 +1,8 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.mcore.cmd.req.ReqHasPerm; public class CmdFactionsLeave extends FCommand { @@ -14,7 +13,7 @@ public class CmdFactionsLeave extends FCommand { this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node)); - this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT)); + this.addRequirements(ReqHasFaction.get()); } @Override diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsName.java b/src/com/massivecraft/factions/cmd/CmdFactionsName.java index 7a56bd0e..3df516c2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsName.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsName.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; @@ -23,6 +24,7 @@ public class CmdFactionsName extends FCommand this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.NAME.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java index d0e8c576..8db88cbf 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java @@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.event.FactionsEventOpenChange; import com.massivecraft.mcore.cmd.arg.ARBoolean; @@ -18,6 +19,7 @@ public class CmdFactionsOpen extends FCommand this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.OPEN.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index f3db3068..3767e874 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.FactionsEventRelationChange; @@ -19,6 +20,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand { this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index f0b94dec..51e29114 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.FPerm; @@ -13,10 +14,11 @@ public class CmdFactionsUnclaim extends FCommand { public CmdFactionsUnclaim() { - this.addAliases("unclaim", "declaim"); + this.addAliases("unclaim"); this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index a6ba068f..6c091a8c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; +import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.BoardColls; @@ -21,10 +22,11 @@ public class CmdFactionsUnclaimall extends FCommand { public CmdFactionsUnclaimall() { - this.addAliases("unclaimall", "declaimall"); + this.addAliases("unclaimall"); this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node)); + this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java b/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java new file mode 100644 index 00000000..15db295f --- /dev/null +++ b/src/com/massivecraft/factions/cmd/req/ReqHasFaction.java @@ -0,0 +1,37 @@ +package com.massivecraft.factions.cmd.req; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.mcore.cmd.MCommand; +import com.massivecraft.mcore.cmd.req.ReqAbstract; +import com.massivecraft.mcore.util.Txt; + +public class ReqHasFaction extends ReqAbstract +{ + private static final long serialVersionUID = 1L; + + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ReqHasFaction i = new ReqHasFaction(); + public static ReqHasFaction get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public boolean apply(CommandSender sender, MCommand command) + { + return UPlayer.get(sender).hasFaction(); + } + + @Override + public String createErrorMessage(CommandSender sender, MCommand command) + { + return Txt.parse("You must belong to a faction to "+(command == null ? "do that" : command.getDesc())+"."); + } + +} diff --git a/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java b/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java new file mode 100644 index 00000000..974a04b2 --- /dev/null +++ b/src/com/massivecraft/factions/cmd/req/ReqHasntFaction.java @@ -0,0 +1,37 @@ +package com.massivecraft.factions.cmd.req; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.mcore.cmd.MCommand; +import com.massivecraft.mcore.cmd.req.ReqAbstract; +import com.massivecraft.mcore.util.Txt; + +public class ReqHasntFaction extends ReqAbstract +{ + private static final long serialVersionUID = 1L; + + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ReqHasntFaction i = new ReqHasntFaction(); + public static ReqHasntFaction get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public boolean apply(CommandSender sender, MCommand command) + { + return !UPlayer.get(sender).hasFaction(); + } + + @Override + public String createErrorMessage(CommandSender sender, MCommand command) + { + return Txt.parse("You must leave your current faction before you "+(command == null ? "do that" : command.getDesc())+"."); + } + +}