From 49444c6fbff8b71ab081d178f178c7d7b19c73bc Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 4 Feb 2015 01:27:33 +0100 Subject: [PATCH] ArgReaders use exceptions - Part 2 --- .../massivecore/cmd/HelpCommand.java | 22 +++++--- .../massivecore/cmd/MassiveCommand.java | 11 ++-- .../cmd/MassiveCommandException.java | 56 ++++++++++++++----- .../cmd/arg/ARAbstractPrimitive.java | 4 +- .../massivecore/cmd/arg/ARAbstractSelect.java | 16 ++++-- .../massivecore/cmd/arg/ARList.java | 4 +- .../massivecore/cmd/arg/ARMaterial.java | 10 ++-- .../massivecore/cmd/arg/ARMillisDiff.java | 5 +- .../massivecore/cmd/arg/ARPermission.java | 4 +- .../cmd/arg/ARSenderIdAbstract.java | 4 +- .../massivecore/cmd/arg/ARSet.java | 3 +- .../massivecore/cmd/arg/ARSound.java | 6 +- .../massivecore/cmd/arg/ARSoundEffect.java | 5 +- .../massivecore/cmd/arg/ARSoundEffects.java | 5 +- .../massivecore/cmd/arg/ARUniverse.java | 16 ++++-- .../massivecore/cmd/arg/ARWorld.java | 4 +- .../massivecore/CmdMassiveCoreBufferAdd.java | 1 - .../massivecore/CmdMassiveCoreBufferSet.java | 1 - .../CmdMassiveCoreBufferWhitespace.java | 4 +- .../massivecore/CmdMassiveCoreHearsound.java | 4 +- .../CmdMassiveCoreStoreListcolls.java | 3 +- .../massivecore/CmdMassiveCoreStoreStats.java | 4 +- .../cmd/massivecore/CmdMassiveCoreTest.java | 13 +---- .../CmdMassiveCoreUsysAspectList.java | 4 +- .../CmdMassiveCoreUsysAspectShow.java | 4 +- .../CmdMassiveCoreUsysAspectUse.java | 6 +- .../CmdMassiveCoreUsysMultiverseDel.java | 4 +- .../CmdMassiveCoreUsysMultiverseList.java | 4 +- .../CmdMassiveCoreUsysMultiverseShow.java | 4 +- .../CmdMassiveCoreUsysUniverseClear.java | 4 +- .../CmdMassiveCoreUsysUniverseDel.java | 4 +- .../CmdMassiveCoreUsysUniverseNew.java | 4 +- .../massivecore/CmdMassiveCoreUsysWorld.java | 4 +- 33 files changed, 140 insertions(+), 107 deletions(-) diff --git a/src/com/massivecraft/massivecore/cmd/HelpCommand.java b/src/com/massivecraft/massivecore/cmd/HelpCommand.java index fbaa3554..864d11c4 100644 --- a/src/com/massivecraft/massivecore/cmd/HelpCommand.java +++ b/src/com/massivecraft/massivecore/cmd/HelpCommand.java @@ -12,13 +12,18 @@ public class HelpCommand extends MassiveCommand // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static HelpCommand i = new HelpCommand(); + protected static HelpCommand i = new HelpCommand(); public static HelpCommand get() { return i; } private HelpCommand() { + // Aliases this.addAliases("?", "h", "help"); + + // Args + this.addOptionalArg("page", "1"); + + // Other this.setDesc(""); - this.addOptionalArg("page","1"); } // -------------------------------------------- // @@ -26,13 +31,17 @@ public class HelpCommand extends MassiveCommand // -------------------------------------------- // @Override - public void perform() - { + public void perform() throws MassiveCommandException + { + // Args + Integer pagenumber = this.arg(0, ARInteger.get(), 1); + + // Get parent command if (this.getCommandChain().size() == 0) return; MassiveCommand parentCommand = this.getCommandChain().get(this.getCommandChain().size()-1); + // Create Lines ArrayList lines = new ArrayList(); - for (String helpline : parentCommand.getHelp()) { lines.add(Txt.parse("# "+helpline)); @@ -46,8 +55,7 @@ public class HelpCommand extends MassiveCommand } } - Integer pagenumber = this.arg(0, ARInteger.get(), 1); - if (pagenumber == null) return; + // Send Lines sendMessage(Txt.getPage(lines, pagenumber, "Help for command \""+parentCommand.getAliases().get(0)+"\"", sender)); } diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java index 01d8306f..e6f66f67 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -339,14 +339,15 @@ public class MassiveCommand } this.fixSenderVars(); - if ( ! isValidCall(this.sender, this.getArgs())) return; - perform(); + if (isValidCall(this.sender, this.getArgs())) + { + perform(); + } } catch (MassiveCommandException ex) { - // Sometimes arg readers (or commands themself) - // throw exceptions, to stop executing and notify the user. - Mixin.msgOne(sender, ex.getErrorMsgs()); + // Sometimes ArgReaders (or commands themself) throw exceptions, to stop executing and notify the user. + Mixin.messageOne(sender, ex.getMessages()); } finally { diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommandException.java b/src/com/massivecraft/massivecore/cmd/MassiveCommandException.java index 094448f5..befde354 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommandException.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommandException.java @@ -1,10 +1,13 @@ package com.massivecraft.massivecore.cmd; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; -public class MassiveCommandException extends RuntimeException +import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.util.Txt; + +public class MassiveCommandException extends Exception { // -------------------------------------------- // // CONSTANTS @@ -12,32 +15,55 @@ public class MassiveCommandException extends RuntimeException private static final long serialVersionUID = 1L; - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private List errorMsgs = new ArrayList(); - public List getErrorMsgs() { return this.errorMsgs; } - public void setErrorMsgs(List msgs) { this.errorMsgs = msgs; } - public void addErrorMsg(String msg) { this.errorMsgs.add(msg); } - // -------------------------------------------- // // CONSTRUCTORS // -------------------------------------------- // - + /* public MassiveCommandException() { - + } public MassiveCommandException(String msg) { - this.errorMsgs.add(msg); + this.messages.add(msg); } public MassiveCommandException(Collection msgs) { - this.errorMsgs.addAll(msgs); + this.messages.addAll(msgs); + } + */ + + // -------------------------------------------- // + // MESSAGES + // -------------------------------------------- // + + private List messages = new MassiveList(); + public List getMessages() { return this.messages; } + + @Override + public String getMessage() + { + return Txt.implode(this.getMessages(), "\n"); } + public MassiveCommandException setMessage(String message) { this.messages = new MassiveList(message); return this; } + public MassiveCommandException setMsg(String msg) { return this.setMessage(Txt.parse(msg)); } + public MassiveCommandException setMsg(String msg, Object... args) { return this.setMessage(Txt.parse(msg, args)); } + + public MassiveCommandException addMessage(String message) { this.getMessages().add(message); return this; } + public MassiveCommandException addMsg(String msg) { return this.addMessage(Txt.parse(msg)); } + public MassiveCommandException addMsg(String msg, Object... args) { return this.addMessage(Txt.parse(msg, args)); } + + public MassiveCommandException setMessages(Collection messages) { this.messages = new MassiveList(messages); return this; } + public MassiveCommandException setMessages(String... messages) { return this.setMessages(Arrays.asList(messages)); } + public MassiveCommandException setMsgs(Collection msgs) { return this.setMessages(Txt.parse(msgs)); } + public MassiveCommandException setMsgs(String... msgs) { return this.setMsgs(Arrays.asList(msgs)); } + + public MassiveCommandException addMessages(Collection messages) { this.getMessages().addAll(messages); return this; } + public MassiveCommandException addMessages(String... messages) { return this.addMessages(Arrays.asList(messages)); } + public MassiveCommandException addMsgs(Collection messages) { this.getMessages().addAll(messages); return this; } + public MassiveCommandException addMsgs(String... msgs) { return this.addMsgs(Arrays.asList(msgs)); } + } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java b/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java index 3a09600b..10a3a64e 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java @@ -18,7 +18,7 @@ public abstract class ARAbstractPrimitive extends ArgReaderAbstract // -------------------------------------------- // @Override - public T read(String arg, CommandSender sender) + public T read(String arg, CommandSender sender) throws MassiveCommandException { T result; @@ -28,7 +28,7 @@ public abstract class ARAbstractPrimitive extends ArgReaderAbstract } catch (Exception e) { - throw new MassiveCommandException("Invalid " + this.typename() + " \"" + arg + "\"."); + throw new MassiveCommandException().addMsg("Invalid %s \"%s\".", this.typename(), arg); } return result; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java b/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java index b374e5d8..53dff771 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java @@ -23,28 +23,32 @@ public abstract class ARAbstractSelect extends ArgReaderAbstract // -------------------------------------------- // @Override - public T read(String arg, CommandSender sender) + public T read(String arg, CommandSender sender) throws MassiveCommandException { T result = this.select(arg, sender); if (result == null) { - MassiveCommandException errors = new MassiveCommandException(); - errors.addErrorMsg("No " + this.typename() + " matches \""+arg+"\"."); + MassiveCommandException exception = new MassiveCommandException(); + exception.addMsg("No %s matches \"%s\".", this.typename(), arg); if (this.canList(sender)) { Collection names = this.altNames(sender); if (names.size() == 0) { - errors.addErrorMsg("Note: There is no "+this.typename()+" available."); + exception.addMsg("Note: There is no %s available.", this.typename()); } else { - errors.addErrorMsg("Use "+Txt.implodeCommaAndDot(names, "%s", ", ", " or ", ".")); + String format = Txt.parse("%s"); + String comma = Txt.parse(", "); + String and = Txt.parse(" or "); + String dot = Txt.parse("."); + exception.addMsg("Use %s", Txt.implodeCommaAndDot(names, format, comma, and, dot)); } } - throw errors; + throw exception; } return result; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARList.java b/src/com/massivecraft/massivecore/cmd/arg/ARList.java index 11a87169..d4e034e8 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARList.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARList.java @@ -5,6 +5,8 @@ import java.util.List; import org.bukkit.command.CommandSender; +import com.massivecraft.massivecore.cmd.MassiveCommandException; + public class ARList extends ArgReaderAbstract> { // -------------------------------------------- // @@ -34,7 +36,7 @@ public class ARList extends ArgReaderAbstract> // NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false). @Override - public List read(String arg, CommandSender sender) + public List read(String arg, CommandSender sender) throws MassiveCommandException { // Split into inner args String[] innerArgs = arg.split("\\s+"); diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java b/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java index bb6c01c0..f84c1be2 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java @@ -19,15 +19,15 @@ public class ARMaterial extends ArgReaderAbstract // -------------------------------------------- // @Override - public Material read(String arg, CommandSender sender) + public Material read(String arg, CommandSender sender) throws MassiveCommandException { Material ret = Material.matchMaterial(arg); if (ret == null) { - MassiveCommandException errors = new MassiveCommandException(); - errors.addErrorMsg("No material matches "+arg+"."); - errors.addErrorMsg("Suggestion: http://www.minecraftwiki.net/wiki/Data_values"); - throw errors; + MassiveCommandException exception = new MassiveCommandException(); + exception.addMsg("No material matches %s.", arg); + exception.addMsg("Suggestion: http://www.minecraftwiki.net/wiki/Data_values"); + throw exception; } return ret; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java b/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java index d9d094e7..76e7fcd0 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.util.TimeDiffUtil; -import com.massivecraft.massivecore.util.Txt; public class ARMillisDiff extends ArgReaderAbstract { @@ -20,7 +19,7 @@ public class ARMillisDiff extends ArgReaderAbstract // -------------------------------------------- // @Override - public Long read(String arg, CommandSender sender) + public Long read(String arg, CommandSender sender) throws MassiveCommandException { Long ret; try @@ -29,7 +28,7 @@ public class ARMillisDiff extends ArgReaderAbstract } catch (Exception e) { - throw new MassiveCommandException(Txt.parse("") + e.getMessage()); + throw new MassiveCommandException().addMsg("%s", e.getMessage()); } return ret; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java b/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java index 060f1c1d..2ccd25e3 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java @@ -20,7 +20,7 @@ public class ARPermission extends ArgReaderAbstract // -------------------------------------------- // @Override - public Permission read(String arg, CommandSender sender) + public Permission read(String arg, CommandSender sender) throws MassiveCommandException { Permission ret = null; @@ -33,7 +33,7 @@ public class ARPermission extends ArgReaderAbstract if (ret == null) { - throw new MassiveCommandException("No permission with the name \"" + arg + "\" was found."); + throw new MassiveCommandException().addMsg("No permission with the name \"%s\" was found.", arg); } return ret; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java b/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java index 96c0e608..20f42298 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java @@ -44,7 +44,7 @@ public abstract class ARSenderIdAbstract extends ArgReaderAbstract // -------------------------------------------- // @Override - public T read(String arg, CommandSender sender) + public T read(String arg, CommandSender sender) throws MassiveCommandException { // Create Ret T ret; @@ -60,7 +60,7 @@ public abstract class ARSenderIdAbstract extends ArgReaderAbstract if (ret == null) { // No alternatives found - throw new MassiveCommandException("No player matches \""+arg+"\"."); + throw new MassiveCommandException().addMsg("No player matches \"%s\".", arg); } // Return Ret diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSet.java b/src/com/massivecraft/massivecore/cmd/arg/ARSet.java index 64cdddd8..e0a1ebd8 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSet.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARSet.java @@ -5,6 +5,7 @@ import java.util.Set; import org.bukkit.command.CommandSender; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.util.Txt; public class ARSet extends ArgReaderAbstract> @@ -40,7 +41,7 @@ public class ARSet extends ArgReaderAbstract> // NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false). @Override - public Set read(String arg, CommandSender sender) + public Set read(String arg, CommandSender sender) throws MassiveCommandException { // Split into inner args String[] innerArgs = arg.split("\\s+"); diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSound.java b/src/com/massivecraft/massivecore/cmd/arg/ARSound.java index a54c7a57..640cf20f 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSound.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARSound.java @@ -19,14 +19,14 @@ public class ARSound extends ArgReaderAbstract // -------------------------------------------- // @Override - public Sound read(String arg, CommandSender sender) + public Sound read(String arg, CommandSender sender) throws MassiveCommandException { Sound result = getSoundFromString(arg); if (result == null) { MassiveCommandException errors = new MassiveCommandException(); - errors.addErrorMsg("No sound matches \""+arg+"\"."); - errors.addErrorMsg("https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java"); + errors.addMsg("No sound matches \"%s\".", arg); + errors.addMsg("https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java"); throw errors; } return result; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java b/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java index ec93df70..c28e85d0 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java @@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.cmd.MassiveCommandException; -import com.massivecraft.massivecore.util.Txt; public class ARSoundEffect extends ArgReaderAbstract { @@ -20,7 +19,7 @@ public class ARSoundEffect extends ArgReaderAbstract // -------------------------------------------- // @Override - public SoundEffect read(String arg, CommandSender sender) + public SoundEffect read(String arg, CommandSender sender) throws MassiveCommandException { SoundEffect ret; @@ -30,7 +29,7 @@ public class ARSoundEffect extends ArgReaderAbstract } catch (Exception e) { - throw new MassiveCommandException(Txt.parse("") + e.getMessage()); + throw new MassiveCommandException().addMsg("%s", e.getMessage()); } return ret; } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffects.java b/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffects.java index 05b6a598..c376e637 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffects.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffects.java @@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.cmd.MassiveCommandException; -import com.massivecraft.massivecore.util.Txt; /** * @deprecated use ARList @@ -28,7 +27,7 @@ public class ARSoundEffects extends ArgReaderAbstract> // -------------------------------------------- // @Override - public List read(String arg, CommandSender sender) + public List read(String arg, CommandSender sender) throws MassiveCommandException { List ret = new ArrayList(); List result = new ArrayList(); @@ -46,7 +45,7 @@ public class ARSoundEffects extends ArgReaderAbstract> } catch (Exception e) { - throw new MassiveCommandException(Txt.parse("") + e.getMessage()); + throw new MassiveCommandException().addMsg("%s", e.getMessage()); } return ret; } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java b/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java index fbbb37f7..e76a6157 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java @@ -32,7 +32,7 @@ public class ARUniverse extends ArgReaderAbstract // -------------------------------------------- // @Override - public String read(String arg, CommandSender sender) + public String read(String arg, CommandSender sender) throws MassiveCommandException { String result = new String(); @@ -42,11 +42,17 @@ public class ARUniverse extends ArgReaderAbstract } else { - MassiveCommandException errors = new MassiveCommandException(); - errors.addErrorMsg("No universe \"" + arg + "\" exists in multiverse " + this.multiverse.getId() + "."); + MassiveCommandException exception = new MassiveCommandException(); + exception.addMsg("No universe \"%s\" exists in multiverse %s.", arg, this.multiverse.getId()); + Collection names = new ArrayList(multiverse.getUniverses()); - errors.addErrorMsg("Use " + Txt.implodeCommaAndDot(names, "%s", ", ", " or ", ".")); - throw errors; + String format = Txt.parse("%s"); + String comma = Txt.parse(", "); + String and = Txt.parse(" or "); + String dot = Txt.parse("."); + exception.addMsg("Use %s", Txt.implodeCommaAndDot(names, format, comma, and, dot)); + + throw exception; } return result; diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java b/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java index 4fc65d0c..9af12f7c 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java +++ b/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java @@ -20,7 +20,7 @@ public class ARWorld extends ArgReaderAbstract // -------------------------------------------- // @Override - public World read(String arg, CommandSender sender) + public World read(String arg, CommandSender sender) throws MassiveCommandException { World ret; @@ -32,7 +32,7 @@ public class ARWorld extends ArgReaderAbstract if (ret == null) { - throw new MassiveCommandException("The world could not be found."); + throw new MassiveCommandException().addMsg("The world \"%s\" could not be found.", arg); } return ret; diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java index 1e75d06f..bb3cd25e 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java @@ -32,7 +32,6 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand public void perform() { String string = this.argConcatFrom(0); - if (string == null) return; String buffer = MassiveCoreEngineVariable.getBuffer(sender); buffer += string; diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java index 4059d9c6..bb3007e9 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java @@ -32,7 +32,6 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand public void perform() { String string = this.argConcatFrom(0); - if (string == null) return; MassiveCoreEngineVariable.setBuffer(sender, string); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java index 68aefc5e..3f52d851 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java @@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore; import com.massivecraft.massivecore.MassiveCoreEngineVariable; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.cmd.MassiveCommand; +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; @@ -30,10 +31,9 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Integer times = this.arg(0, ARInteger.get(), 1); - if (times == null) return; String string = Txt.repeat(" ", times); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java index a4f4e3d9..28cd137e 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java @@ -5,6 +5,7 @@ import java.util.List; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARList; import com.massivecraft.massivecore.cmd.arg.ARSoundEffect; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -35,11 +36,10 @@ public class CmdMassiveCoreHearsound extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args List soundEffects = this.argConcatFrom(0, ARList.get(ARSoundEffect.get())); - if (soundEffects == null) return; // Apply SoundEffect.runAll(soundEffects, me); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java index 294e78e9..60c4e656 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java @@ -7,6 +7,7 @@ import com.massivecraft.massivecore.ConfServer; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.NaturalOrderComparator; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.store.Coll; @@ -37,7 +38,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args final String dbAlias = this.arg(0, ARString.get(), ConfServer.dburi); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java index 7d7b6c26..87d8448e 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java @@ -4,6 +4,7 @@ import java.util.Map.Entry; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARColl; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.store.Coll; @@ -34,7 +35,7 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { if (!this.argIsSet(0) || this.arg(0).equalsIgnoreCase(Coll.TOTAL)) { @@ -43,7 +44,6 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand else { Coll coll = this.arg(0, ARColl.get()); - if (coll == null) return; this.performColl(coll); } } diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreTest.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreTest.java index 1a1690e9..2450221d 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreTest.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreTest.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.VisibilityMode; import com.massivecraft.massivecore.cmd.arg.AREnum; import com.massivecraft.massivecore.cmd.arg.ARFloat; @@ -45,28 +46,18 @@ public class CmdMassiveCoreTest extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args ParticleEffect particleEffect = this.arg(0, AREnum.get(ParticleEffect.class)); - if (particleEffect == null) return; Location center = me.getEyeLocation().add(0, 0, 0); Float offsetX = this.arg(1, ARFloat.get()); - if (offsetX == null) return; - Float offsetY = this.arg(2, ARFloat.get()); - if (offsetY == null) return; - Float offsetZ = this.arg(3, ARFloat.get()); - if (offsetZ == null) return; - Float speed = this.arg(4, ARFloat.get()); - if (speed == null) return; - Integer amount = this.arg(5, ARInteger.get()); - if (amount == null) return; Player player = me; diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java index 66ff5f01..b3c1ebdd 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java @@ -7,6 +7,7 @@ import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.AspectColl; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.cmd.MassiveCommand; +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; @@ -34,11 +35,10 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; // Create Lines List lines = new ArrayList(); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java index c584cceb..1a7a2aca 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java @@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore; import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARAspect; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Aspect aspect = this.arg(0, ARAspect.get()); - if (aspect == null) return; msg(Txt.titleize("Aspect: "+aspect.getId())); msg("using multiverse: %s",aspect.getMultiverse().getId()); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java index e943246d..228583a7 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java @@ -4,6 +4,7 @@ import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARAspect; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -32,13 +33,10 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Aspect aspect = this.arg(0, ARAspect.get()); - if (aspect == null) return; - Multiverse multiverse = this.arg(1, ARMultiverse.get()); - if (multiverse == null) return; aspect.setMultiverse(multiverse); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java index 79ec4938..349b82e2 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java @@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(0, ARMultiverse.get()); - if (multiverse == null) return; String id = multiverse.getId(); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java index 204d5a2b..da6a5164 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java @@ -7,6 +7,7 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.MultiverseColl; import com.massivecraft.massivecore.cmd.MassiveCommand; +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; @@ -34,11 +35,10 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { // Args Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); - if (pageHumanBased == null) return; // Create Lines List lines = new ArrayList(); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java index e4695f85..76c2e216 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java @@ -8,6 +8,7 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -35,10 +36,9 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(0, ARMultiverse.get()); - if (multiverse == null) return; msg(Txt.titleize("Multiverse: "+multiverse.getId())); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java index 9a9dd89a..c35483b0 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java @@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(1, ARMultiverse.get()); - if (multiverse == null) return; String universe = this.arg(0); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java index e5928a2b..25af5d2c 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java @@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(1, ARMultiverse.get()); - if (multiverse == null) return; String universe = this.arg(0); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java index a8ee769b..9c1d0991 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java @@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(1, ARMultiverse.get()); - if (multiverse == null) return; String universe = this.arg(0); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java index cf026e9d..3fe6e126 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java @@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; +import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand // -------------------------------------------- // @Override - public void perform() + public void perform() throws MassiveCommandException { Multiverse multiverse = this.arg(2, ARMultiverse.get()); - if (multiverse == null) return; String universe = this.arg(1); String worldName = this.arg(0);