From abc27821f49b343bc36bd27121309bfa762b77f6 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Wed, 6 Mar 2019 17:10:35 +0100 Subject: [PATCH] Fix NPE --- src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java | 3 +-- src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java | 3 +-- src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java | 7 +++---- src/com/massivecraft/factions/cmd/CmdFactionsSetX.java | 3 ++- src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java index aea872fb..90062c3d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetAll.java @@ -74,8 +74,7 @@ public class CmdFactionsSetAll extends CmdFactionsSetXAll } else { - msg("You must specify which map from console."); - return null; + throw new MassiveException().addMsg("You must specify which map from console."); } } else diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java index 43661998..286f5d48 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java @@ -71,8 +71,7 @@ public class CmdFactionsSetAuto extends FactionsCommand if (newFaction == null || newFaction == msender.getAutoClaimFaction()) { msender.setAutoClaimFaction(null); - msg("Disabled auto-setting as you walk around."); - return; + throw new MassiveException().addMsg("Disabled auto-setting as you walk around."); } // MPerm Preemptive Check diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java index fea669ea..e25b75eb 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetFill.java @@ -4,13 +4,13 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.command.requirement.RequirementHasPerm; import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; -import java.util.LinkedHashSet; import java.util.Set; @@ -43,7 +43,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple // -------------------------------------------- // @Override - public Set getChunks() + public Set getChunks() throws MassiveException { // Common Startup final PS chunk = PS.valueOf(me.getLocation()).getChunk(true); @@ -63,8 +63,7 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple // Limit Reached? if (chunks.size() >= max) { - msg("Fill limit of %d reached.", max); - return null; + throw new MassiveException().addMsg("Fill limit of %d reached.", max); } // OK! diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java index 6b235bd7..4c0162a9 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetX.java @@ -49,7 +49,8 @@ public abstract class CmdFactionsSetX extends FactionsCommand // Args final Faction newFaction = this.getNewFaction(); final Set chunks = this.getChunks(); - + if (chunks == null) throw new NullPointerException("chunks"); + // Apply / Inform msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany()); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java index d31981b8..b7fb3e78 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetpower.java @@ -48,8 +48,7 @@ public class CmdFactionsSetpower extends FactionsCommand double maxDifference = 0.1d; if (difference < maxDifference) { - msg("%s's power is already %.2f.", mplayer.getDisplayName(msender), newPower); - return; + throw new MassiveException().addMsg("%s's power is already %.2f.", mplayer.getDisplayName(msender), newPower); } // Event