From 83225286529cad64814df990d9ccaae40ff3ba21 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 4 Feb 2015 01:30:07 +0100 Subject: [PATCH] MassiveCore Change - ArgReaders use Exceptions --- .../cmd/CmdFactionsAccessAbstract.java | 5 ++-- .../cmd/CmdFactionsAccessFaction.java | 6 ++--- .../factions/cmd/CmdFactionsAccessPlayer.java | 6 ++--- .../factions/cmd/CmdFactionsAdmin.java | 4 ++-- .../factions/cmd/CmdFactionsDisband.java | 4 ++-- .../factions/cmd/CmdFactionsFaction.java | 4 ++-- .../factions/cmd/CmdFactionsFlagList.java | 4 ++-- .../factions/cmd/CmdFactionsFlagSet.java | 6 ++--- .../factions/cmd/CmdFactionsFlagShow.java | 5 ++-- .../factions/cmd/CmdFactionsHome.java | 4 ++-- .../factions/cmd/CmdFactionsInviteAdd.java | 4 ++-- .../factions/cmd/CmdFactionsInviteList.java | 5 ++-- .../factions/cmd/CmdFactionsInviteRemove.java | 4 ++-- .../factions/cmd/CmdFactionsJoin.java | 7 +++--- .../factions/cmd/CmdFactionsKick.java | 4 ++-- .../factions/cmd/CmdFactionsList.java | 4 ++-- .../factions/cmd/CmdFactionsMap.java | 3 ++- .../factions/cmd/CmdFactionsMoneyBalance.java | 6 ++--- .../factions/cmd/CmdFactionsMoneyDeposit.java | 5 ++-- .../cmd/CmdFactionsMoneyTransferFf.java | 8 ++----- .../cmd/CmdFactionsMoneyTransferFp.java | 8 ++----- .../cmd/CmdFactionsMoneyTransferPf.java | 8 ++----- .../cmd/CmdFactionsMoneyWithdraw.java | 6 ++--- .../factions/cmd/CmdFactionsName.java | 4 ++-- .../factions/cmd/CmdFactionsPermList.java | 4 ++-- .../factions/cmd/CmdFactionsPermSet.java | 7 ++---- .../factions/cmd/CmdFactionsPermShow.java | 5 ++-- .../factions/cmd/CmdFactionsPlayer.java | 4 ++-- .../factions/cmd/CmdFactionsPowerBoost.java | 6 ++--- .../factions/cmd/CmdFactionsRank.java | 5 ++-- .../cmd/CmdFactionsRelationAbstract.java | 4 ++-- .../factions/cmd/CmdFactionsSeeChunk.java | 4 ++-- .../factions/cmd/CmdFactionsSetAll.java | 3 ++- .../factions/cmd/CmdFactionsSetAuto.java | 3 ++- .../factions/cmd/CmdFactionsSetCircle.java | 3 ++- .../factions/cmd/CmdFactionsSetSquare.java | 3 ++- .../factions/cmd/CmdFactionsSetX.java | 10 ++++---- .../factions/cmd/CmdFactionsSetXAll.java | 3 ++- .../factions/cmd/CmdFactionsSetXRadius.java | 5 ++-- .../factions/cmd/CmdFactionsSethome.java | 4 ++-- .../factions/cmd/CmdFactionsSetpower.java | 5 ++-- .../factions/cmd/CmdFactionsTitle.java | 6 ++--- .../factions/cmd/CmdFactionsUnsethome.java | 4 ++-- .../factions/cmd/arg/ARFaction.java | 24 ++++++++----------- 44 files changed, 103 insertions(+), 133 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java index 31c29308..d24182f8 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSFormatHumanSpace; @@ -39,7 +40,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { chunk = PS.valueOf(me.getLocation()).getChunk(true); ta = BoardColl.get().getTerritoryAccessAt(chunk); @@ -48,7 +49,7 @@ public abstract class CmdFactionsAccessAbstract extends FactionsCommand this.innerPerform(); } - public abstract void innerPerform(); + public abstract void innerPerform() throws MassiveCommandException; public void sendAccessInfo() { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java index 411d9b4c..e7642d47 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -32,14 +33,11 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract // -------------------------------------------- // @Override - public void innerPerform() + public void innerPerform() throws MassiveCommandException { // Args Faction faction = this.arg(0, ARFaction.get()); - if (faction == null) return; - Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId())); - if (newValue == null) return; // MPerm if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java index 20422c23..b9ff1352 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -32,14 +33,11 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract // -------------------------------------------- // @Override - public void innerPerform() + public void innerPerform() throws MassiveCommandException { // Args MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); - if (mplayer == null) return; - Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId())); - if (newValue == null) return; // MPerm if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java index c62d6e1d..38fd131a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; @@ -30,11 +31,10 @@ public class CmdFactionsAdmin extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode()); - if (target == null) return; // Apply msender.setUsingAdminMode(target); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java index e1187149..d70c6c49 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -12,6 +12,7 @@ import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.Txt; @@ -39,11 +40,10 @@ public class CmdFactionsDisband extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; // MPerm if ( ! MPerm.getPermDisband().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java index ac0b35f8..e7aa6025 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -11,6 +11,7 @@ import com.massivecraft.factions.event.EventFactionsFactionShowAsync; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.PriorityLines; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.util.Txt; @@ -38,11 +39,10 @@ public class CmdFactionsFaction extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args final Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; final CommandSender sender = this.sender; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java index f67d580f..c3287f4e 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java @@ -5,6 +5,7 @@ import java.util.List; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.MFlag; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -32,11 +33,10 @@ public class CmdFactionsFlagList extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; //Create messages List messages = new ArrayList(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java index 33b35b71..b09d344f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagSet.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsFlagChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -35,15 +36,12 @@ public class CmdFactionsFlagSet extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args MFlag flag = this.arg(0, ARMFlag.get()); - if (flag == null) return; Boolean value = this.arg(1, ARBoolean.get()); - if (value == null) return; Faction faction = this.arg(2, ARFaction.get(), msenderFaction); - if (faction == null) return; // Do the sender have the right to change flags for this faction? if ( ! MPerm.getPermFlags().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java index 13456023..d5203666 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagShow.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARMFlag; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MFlag; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARList; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -37,11 +38,10 @@ public class CmdFactionsFlagShow extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Arg: Faction Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; List flags = new ArrayList(); @@ -58,7 +58,6 @@ public class CmdFactionsFlagShow extends FactionsCommand { // Arg: MFlag. Maybe we should use ARSet but that is currently buggy. List mflags = this.arg(this.argConcatFrom(1), ARList.get(ARMFlag.get())); - if (mflags == null) return; flags.addAll(mflags); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index 7eabc79f..d0e0a0c0 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -15,6 +15,7 @@ import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsHomeTeleport; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.mixin.Mixin; @@ -46,7 +47,7 @@ public class CmdFactionsHome extends FactionsCommandHome // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { if ( ! MConf.get().homesTeleportCommandEnabled) { @@ -56,7 +57,6 @@ public class CmdFactionsHome extends FactionsCommandHome // Args Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; PS home = faction.getHome(); String homeDesc = "home for " + faction.describeTo(msender, false); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java index f9e9c26c..58920628 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsInvitedChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARSet; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -34,11 +35,10 @@ public class CmdFactionsInviteAdd extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Set mplayers = this.argConcatFrom(0, ARSet.get(ARMPlayer.getAny(), true)); - if (mplayers == null) return; // MPerm if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java index 1021f2df..f8b51e08 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.pager.PagerSimple; @@ -38,14 +39,12 @@ public class CmdFactionsInviteList extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; Faction faction = this.arg(1, ARFaction.get(), msenderFaction); - if (faction == null) return; if ( faction != msenderFaction && ! Perm.INVITE_LIST_OTHER.has(sender, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java index a27450f7..4dd1a237 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java @@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsInvitedChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARSet; import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -37,7 +38,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Set mplayers = new HashSet(); boolean all = false; @@ -58,7 +59,6 @@ public class CmdFactionsInviteRemove extends FactionsCommand else { Set senderInput = this.argConcatFrom(0, ARSet.get(ARMPlayer.getAny(), true)); - if (senderInput == null) return; mplayers.addAll(senderInput); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java index 53bfb19b..938985fb 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -10,6 +10,7 @@ import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -37,14 +38,12 @@ public class CmdFactionsJoin extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args - Faction faction = this.arg(0, ARFaction.get()); - if (faction == null) return; + Faction faction = this.arg(0, ARFaction.get()); MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), msender); - if (mplayer == null) return; Faction mplayerFaction = mplayer.getFaction(); boolean samePlayer = mplayer == msender; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java index 737b4ba8..c69a4bf9 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -11,6 +11,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; @@ -37,11 +38,10 @@ public class CmdFactionsKick extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Arg MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); - if (mplayer == null) return; // Validate if (msender == mplayer) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/com/massivecraft/factions/cmd/CmdFactionsList.java index f9ae5e78..738dd728 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -10,6 +10,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; @@ -40,11 +41,10 @@ public class CmdFactionsList extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args final Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; // NOTE: The faction list is quite slow and mostly thread safe. // We run it asynchronously to spare the primary server thread. diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java index 4a001590..a93c74d3 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -7,6 +7,7 @@ import org.bukkit.Location; import com.massivecraft.factions.Const; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -36,7 +37,7 @@ public class CmdFactionsMap extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { if ( ! this.argIsSet(0)) { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java index c55c2d7b..d4f057c5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsMoneyBalance extends FactionsCommand @@ -31,11 +32,10 @@ public class CmdFactionsMoneyBalance extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; - + if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; Econ.sendBalanceInfo(msender, faction); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java index f31f43e6..8488d744 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.money.Money; @@ -39,13 +40,11 @@ public class CmdFactionsMoneyDeposit extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Double amount = this.arg(0, ARDouble.get()); - if (amount == null) return; Faction faction = this.arg(1, ARFaction.get(), msenderFaction); - if (faction == null) return; boolean success = Econ.transferMoney(msender, msender, faction, amount); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java index 38bdc9be..60e0d234 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.money.Money; @@ -41,16 +42,11 @@ public class CmdFactionsMoneyTransferFf extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Double amount = this.arg(0, ARDouble.get()); - if (amount == null) return; - Faction from = this.arg(1, ARFaction.get()); - if (from == null) return; - Faction to = this.arg(2, ARFaction.get()); - if (to == null) return; boolean success = Econ.transferMoney(msender, from, to, amount); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java index 3ae1d76a..6bd8f4d1 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.money.Money; @@ -43,16 +44,11 @@ public class CmdFactionsMoneyTransferFp extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Double amount = this.arg(0, ARDouble.get()); - if (amount == null) return; - Faction from = this.arg(1, ARFaction.get()); - if (from == null) return; - MPlayer to = this.arg(2, ARMPlayer.getAny()); - if (to == null) return; boolean success = Econ.transferMoney(msender, from, to, amount); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java index 08686da8..08c1ee26 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.money.Money; @@ -43,16 +44,11 @@ public class CmdFactionsMoneyTransferPf extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Double amount = this.arg(0, ARDouble.get()); - if (amount == null) return; - MPlayer from = this.arg(1, ARMPlayer.getAny()); - if (from == null) return; - Faction to = this.arg(2, ARFaction.get()); - if (to == null) return; boolean success = Econ.transferMoney(msender, from, to, amount); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java index 61f2b404..083f0764 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.money.Money; @@ -41,13 +42,10 @@ public class CmdFactionsMoneyWithdraw extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Double amount = this.arg(0, ARDouble.get()); - if (amount == null) return; - Faction from = this.arg(1, ARFaction.get(), msenderFaction); - if (from == null) return; MPlayer to = msender; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsName.java b/src/com/massivecraft/factions/cmd/CmdFactionsName.java index 22589759..9d8f804f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsName.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsName.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.util.MiscUtil; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsName extends FactionsCommand @@ -35,13 +36,12 @@ public class CmdFactionsName extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args String newName = this.arg(0); Faction faction = this.arg(1, ARFaction.get(), msenderFaction); - if (faction == null) return; // MPerm if ( ! MPerm.getPermName().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java index 8e467378..16067b90 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java @@ -5,6 +5,7 @@ import java.util.List; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.MPerm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -32,11 +33,10 @@ public class CmdFactionsPermList extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; // Create messages List messages = new ArrayList(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java index 08ce3bec..44c2ea8f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java @@ -11,6 +11,7 @@ import com.massivecraft.factions.cmd.arg.ARRel; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -41,17 +42,13 @@ public class CmdFactionsPermSet extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args MPerm perm = this.arg(0, ARMPerm.get()); - if (perm == null) return; Rel rel = this.arg(1, ARRel.get()); - if (rel == null) return; Boolean value = this.arg(2, ARBoolean.get()); - if (value == null) return; Faction faction = this.arg(3, ARFaction.get(), msenderFaction); - if (faction == null) return; // Do the sender have the right to change perms for this faction? if ( ! MPerm.getPermPerms().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java index daa59634..c7dd8361 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARMPerm; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARList; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -37,11 +38,10 @@ public class CmdFactionsPermShow extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Arg: Faction Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; List perms = new ArrayList(); @@ -59,7 +59,6 @@ public class CmdFactionsPermShow extends FactionsCommand { // Arg perm. Maybe we should use ARSet but that is currently buggy. List mperms = this.arg(this.argConcatFrom(1), ARList.get(ARMPerm.get())); - if (mperms == null) return; perms.addAll(mperms); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java b/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java index d8778baf..a03e5d0c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPlayer.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis; import com.massivecraft.massivecore.Progressbar; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; @@ -37,11 +38,10 @@ public class CmdFactionsPlayer extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), msender); - if (mplayer == null) return; // INFO: Title msg(Txt.titleize("Player " + mplayer.describeTo(msender))); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index 7cc11453..b473295d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -34,7 +35,7 @@ public class CmdFactionsPowerBoost extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { String type = this.arg(0).toLowerCase(); boolean doPlayer = true; @@ -50,14 +51,12 @@ public class CmdFactionsPowerBoost extends FactionsCommand } Double targetPower = this.arg(2, ARDouble.get()); - if (targetPower == null) return; String target; if (doPlayer) { MPlayer targetPlayer = this.arg(1, ARMPlayer.getAny()); - if (targetPlayer == null) return; targetPlayer.setPowerBoost(targetPower); target = "Player \""+targetPlayer.getName()+"\""; @@ -65,7 +64,6 @@ public class CmdFactionsPowerBoost extends FactionsCommand else { Faction targetFaction = this.arg(1, ARFaction.get()); - if (targetFaction == null) return; targetFaction.setPowerBoost(targetPower); target = "Faction \""+targetFaction.getName()+"\""; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRank.java b/src/com/massivecraft/factions/cmd/CmdFactionsRank.java index e39eb123..88da0060 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRank.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRank.java @@ -13,6 +13,7 @@ import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.event.EventFactionsRankChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; @@ -63,7 +64,7 @@ public class CmdFactionsRank extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // This sets target and much other. Returns false if not succeeded. if ( ! this.registerFields()) @@ -121,7 +122,7 @@ public class CmdFactionsRank extends FactionsCommand // PRIVATE // -------------------------------------------- // - private boolean registerFields() + private boolean registerFields() throws MassiveCommandException { // Getting the target and faction. target = this.arg(0, ARMPlayer.getAny(), msender); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index ca2a74f5..2ff3a7cd 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsRelationChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public abstract class CmdFactionsRelationAbstract extends FactionsCommand @@ -34,11 +35,10 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Faction otherFaction = this.arg(0, ARFaction.get()); - if (otherFaction == null) return; Rel newRelation = targetRelation; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java index 7bb82f78..f0b333b5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -30,13 +31,12 @@ public class CmdFactionsSeeChunk extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args boolean old = msender.isSeeingChunk(); boolean targetDefault = !old; Boolean target = this.arg(0, ARBoolean.get(), targetDefault); - if (target == null) return; String targetDesc = Txt.parse(target ? "ON": "OFF"); // NoChange diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java index 22dbf62b..04c9d4e5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARWorldId; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -39,7 +40,7 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll // -------------------------------------------- // @Override - public Set getChunks() + public Set getChunks() throws MassiveCommandException { // World String word = (this.isClaim() ? "claim" : "unclaim"); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java index 437a922d..64099fb5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java @@ -8,6 +8,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPerm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -52,7 +53,7 @@ public class CmdFactionsSetAuto extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args final Faction newFaction; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java index cd7507c6..3bf1c887 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java @@ -4,6 +4,7 @@ import java.util.LinkedHashSet; import java.util.Set; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -38,7 +39,7 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius // -------------------------------------------- // @Override - public Set getChunks() + public Set getChunks() throws MassiveCommandException { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java index d1852429..45b8624e 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java @@ -4,6 +4,7 @@ import java.util.LinkedHashSet; import java.util.Set; import com.massivecraft.factions.Perm; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -38,7 +39,7 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius // -------------------------------------------- // @Override - public Set getChunks() + public Set getChunks() throws MassiveCommandException { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java index 91886e22..440ef9b2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java @@ -5,6 +5,7 @@ import java.util.Set; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.ps.PS; @@ -44,14 +45,11 @@ public abstract class CmdFactionsSetX extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args final Faction newFaction = this.getNewFaction(); - if (newFaction == null) return; - final Set chunks = this.getChunks(); - if (chunks == null) return; // Apply / Inform msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany()); @@ -61,13 +59,13 @@ public abstract class CmdFactionsSetX extends FactionsCommand // ABSTRACT // -------------------------------------------- // - public abstract Set getChunks(); + public abstract Set getChunks() throws MassiveCommandException; // -------------------------------------------- // // EXTRAS // -------------------------------------------- // - public Faction getNewFaction() + public Faction getNewFaction() throws MassiveCommandException { if (this.isClaim()) { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java index 4b0fedf5..00e4428c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java @@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.massivecore.cmd.MassiveCommandException; public abstract class CmdFactionsSetXAll extends CmdFactionsSetX { @@ -28,7 +29,7 @@ public abstract class CmdFactionsSetXAll extends CmdFactionsSetX // EXTRAS // -------------------------------------------- // - public Faction getOldFaction() + public Faction getOldFaction() throws MassiveCommandException { return this.arg(1, ARFaction.get()); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java index 836f1a49..704fda8c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARInteger; @@ -28,7 +29,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX // EXTRAS // -------------------------------------------- // - public Integer getRadius() + public Integer getRadius() throws MassiveCommandException { Integer radius = this.arg(0, ARInteger.get(), 1); if (radius == null) return radius; @@ -50,7 +51,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX return radius; } - public Integer getRadiusZero() + public Integer getRadiusZero() throws MassiveCommandException { Integer ret = this.getRadius(); if (ret == null) return ret; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index 06a3e569..84aa9489 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -6,6 +6,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsHomeChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -34,11 +35,10 @@ public class CmdFactionsSethome extends FactionsCommandHome // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; PS newHome = PS.valueOf(me.getLocation()); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java index b5991754..d29e404b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -32,13 +33,11 @@ public class CmdFactionsSetpower extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args MPlayer mplayer = this.arg(0, ARMPlayer.getAny()); - if (mplayer == null) return; Double power = this.arg(1, ARDouble.get()); - if (power == null) return; // Power double oldPower = mplayer.getPower(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java index e0c2a3b4..d7450dbb 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsTitleChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -35,14 +36,11 @@ public class CmdFactionsTitle extends FactionsCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args MPlayer you = this.arg(0, ARMPlayer.getAny()); - if (you == null) return; - String newTitle = this.argConcatFrom(1, ARString.get(), ""); - if (newTitle == null) return; newTitle = Txt.parse(newTitle); if (!Perm.TITLE_COLOR.has(sender, false)) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java index a6971d4c..e673a816 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnsethome.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.event.EventFactionsHomeChange; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsUnsethome extends FactionsCommandHome @@ -30,11 +31,10 @@ public class CmdFactionsUnsethome extends FactionsCommandHome // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Faction faction = this.arg(0, ARFaction.get(), msenderFaction); - if (faction == null) return; // Any and MPerm if ( ! MPerm.getPermSethome().has(msender, faction, true)) return; diff --git a/src/com/massivecraft/factions/cmd/arg/ARFaction.java b/src/com/massivecraft/factions/cmd/arg/ARFaction.java index 24155758..2437a72a 100644 --- a/src/com/massivecraft/factions/cmd/arg/ARFaction.java +++ b/src/com/massivecraft/factions/cmd/arg/ARFaction.java @@ -6,10 +6,9 @@ import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.massivecore.MassiveCore; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract; -import com.massivecraft.massivecore.cmd.arg.ArgResult; import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.Txt; public class ARFaction extends ArgReaderAbstract { @@ -25,39 +24,36 @@ public class ARFaction extends ArgReaderAbstract // -------------------------------------------- // @Override - public ArgResult read(String str, CommandSender sender) + public Faction read(String str, CommandSender sender) throws MassiveCommandException { - ArgResult result = new ArgResult(); + Faction ret; // Nothing/Remove targets Wilderness if (MassiveCore.NOTHING_REMOVE.contains(str)) { - result.setResult(FactionColl.get().getNone()); - return result; + return FactionColl.get().getNone(); } // Faction Id Exact if (FactionColl.get().containsId(str)) { - result.setResult(FactionColl.get().get(str)); - if (result.hasResult()) return result; + ret = FactionColl.get().get(str); + if (ret != null) return ret; } // Faction Name Exact - result.setResult(FactionColl.get().getByName(str)); - if (result.hasResult()) return result; + ret = FactionColl.get().getByName(str); + if (ret != null) return ret; // MPlayer Name Exact String id = IdUtil.getId(str); MPlayer mplayer = MPlayer.get(id); if (mplayer != null) { - result.setResult(mplayer.getFaction()); - return result; + return mplayer.getFaction(); } - result.setErrors(Txt.parse("No faction or player matching \"

%s\".", str)); - return result; + throw new MassiveCommandException().addMsg("No faction or player matching \"

%s\".", str); } }