ArgReaders use exceptions - Part 2

This commit is contained in:
Olof Larsson 2015-02-04 01:27:33 +01:00
parent 47b2eeccb4
commit 49444c6fbf
33 changed files with 140 additions and 107 deletions

View File

@ -12,13 +12,18 @@ public class HelpCommand extends MassiveCommand
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
private static HelpCommand i = new HelpCommand(); protected static HelpCommand i = new HelpCommand();
public static HelpCommand get() { return i; } public static HelpCommand get() { return i; }
private HelpCommand() private HelpCommand()
{ {
// Aliases
this.addAliases("?", "h", "help"); this.addAliases("?", "h", "help");
// Args
this.addOptionalArg("page", "1");
// Other
this.setDesc(""); this.setDesc("");
this.addOptionalArg("page","1");
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -26,13 +31,17 @@ public class HelpCommand extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @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; if (this.getCommandChain().size() == 0) return;
MassiveCommand parentCommand = this.getCommandChain().get(this.getCommandChain().size()-1); MassiveCommand parentCommand = this.getCommandChain().get(this.getCommandChain().size()-1);
// Create Lines
ArrayList<String> lines = new ArrayList<String>(); ArrayList<String> lines = new ArrayList<String>();
for (String helpline : parentCommand.getHelp()) for (String helpline : parentCommand.getHelp())
{ {
lines.add(Txt.parse("<a>#<i> "+helpline)); lines.add(Txt.parse("<a>#<i> "+helpline));
@ -46,8 +55,7 @@ public class HelpCommand extends MassiveCommand
} }
} }
Integer pagenumber = this.arg(0, ARInteger.get(), 1); // Send Lines
if (pagenumber == null) return;
sendMessage(Txt.getPage(lines, pagenumber, "Help for command \""+parentCommand.getAliases().get(0)+"\"", sender)); sendMessage(Txt.getPage(lines, pagenumber, "Help for command \""+parentCommand.getAliases().get(0)+"\"", sender));
} }

View File

@ -339,14 +339,15 @@ public class MassiveCommand
} }
this.fixSenderVars(); this.fixSenderVars();
if ( ! isValidCall(this.sender, this.getArgs())) return; if (isValidCall(this.sender, this.getArgs()))
perform(); {
perform();
}
} }
catch (MassiveCommandException ex) catch (MassiveCommandException ex)
{ {
// Sometimes arg readers (or commands themself) // Sometimes ArgReaders (or commands themself) throw exceptions, to stop executing and notify the user.
// throw exceptions, to stop executing and notify the user. Mixin.messageOne(sender, ex.getMessages());
Mixin.msgOne(sender, ex.getErrorMsgs());
} }
finally finally
{ {

View File

@ -1,10 +1,13 @@
package com.massivecraft.massivecore.cmd; package com.massivecraft.massivecore.cmd;
import java.util.ArrayList; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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 // CONSTANTS
@ -12,32 +15,55 @@ public class MassiveCommandException extends RuntimeException
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private List<String> errorMsgs = new ArrayList<String>();
public List<String> getErrorMsgs() { return this.errorMsgs; }
public void setErrorMsgs(List<String> msgs) { this.errorMsgs = msgs; }
public void addErrorMsg(String msg) { this.errorMsgs.add(msg); }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCTORS // CONSTRUCTORS
// -------------------------------------------- // // -------------------------------------------- //
/*
public MassiveCommandException() public MassiveCommandException()
{ {
} }
public MassiveCommandException(String msg) public MassiveCommandException(String msg)
{ {
this.errorMsgs.add(msg); this.messages.add(msg);
} }
public MassiveCommandException(Collection<String> msgs) public MassiveCommandException(Collection<String> msgs)
{ {
this.errorMsgs.addAll(msgs); this.messages.addAll(msgs);
}
*/
// -------------------------------------------- //
// MESSAGES
// -------------------------------------------- //
private List<String> messages = new MassiveList<String>();
public List<String> getMessages() { return this.messages; }
@Override
public String getMessage()
{
return Txt.implode(this.getMessages(), "\n");
} }
public MassiveCommandException setMessage(String message) { this.messages = new MassiveList<String>(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<String> messages) { this.messages = new MassiveList<String>(messages); return this; }
public MassiveCommandException setMessages(String... messages) { return this.setMessages(Arrays.asList(messages)); }
public MassiveCommandException setMsgs(Collection<String> msgs) { return this.setMessages(Txt.parse(msgs)); }
public MassiveCommandException setMsgs(String... msgs) { return this.setMsgs(Arrays.asList(msgs)); }
public MassiveCommandException addMessages(Collection<String> messages) { this.getMessages().addAll(messages); return this; }
public MassiveCommandException addMessages(String... messages) { return this.addMessages(Arrays.asList(messages)); }
public MassiveCommandException addMsgs(Collection<String> messages) { this.getMessages().addAll(messages); return this; }
public MassiveCommandException addMsgs(String... msgs) { return this.addMsgs(Arrays.asList(msgs)); }
} }

View File

@ -18,7 +18,7 @@ public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public T read(String arg, CommandSender sender) public T read(String arg, CommandSender sender) throws MassiveCommandException
{ {
T result; T result;
@ -28,7 +28,7 @@ public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
} }
catch (Exception e) catch (Exception e)
{ {
throw new MassiveCommandException("<b>Invalid " + this.typename() + " \"<h>" + arg + "\"<b>."); throw new MassiveCommandException().addMsg("<b>Invalid %s \"<h>%s\"<b>.", this.typename(), arg);
} }
return result; return result;

View File

@ -23,28 +23,32 @@ public abstract class ARAbstractSelect<T> extends ArgReaderAbstract<T>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public T read(String arg, CommandSender sender) public T read(String arg, CommandSender sender) throws MassiveCommandException
{ {
T result = this.select(arg, sender); T result = this.select(arg, sender);
if (result == null) if (result == null)
{ {
MassiveCommandException errors = new MassiveCommandException(); MassiveCommandException exception = new MassiveCommandException();
errors.addErrorMsg("<b>No " + this.typename() + " matches \"<h>"+arg+"<b>\"."); exception.addMsg("<b>No %s matches \"<h>%s<b>\".", this.typename(), arg);
if (this.canList(sender)) if (this.canList(sender))
{ {
Collection<String> names = this.altNames(sender); Collection<String> names = this.altNames(sender);
if (names.size() == 0) if (names.size() == 0)
{ {
errors.addErrorMsg("<i>Note: There is no "+this.typename()+" available."); exception.addMsg("<i>Note: There is no %s available.", this.typename());
} }
else else
{ {
errors.addErrorMsg("<i>Use "+Txt.implodeCommaAndDot(names, "<h>%s", "<i>, ", " <i>or ", "<i>.")); String format = Txt.parse("<h>%s");
String comma = Txt.parse("<i>, ");
String and = Txt.parse(" <i>or ");
String dot = Txt.parse("<i>.");
exception.addMsg("<i>Use %s", Txt.implodeCommaAndDot(names, format, comma, and, dot));
} }
} }
throw errors; throw exception;
} }
return result; return result;

View File

@ -5,6 +5,8 @@ import java.util.List;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
public class ARList<T> extends ArgReaderAbstract<List<T>> public class ARList<T> extends ArgReaderAbstract<List<T>>
{ {
// -------------------------------------------- // // -------------------------------------------- //
@ -34,7 +36,7 @@ public class ARList<T> extends ArgReaderAbstract<List<T>>
// NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false). // NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false).
@Override @Override
public List<T> read(String arg, CommandSender sender) public List<T> read(String arg, CommandSender sender) throws MassiveCommandException
{ {
// Split into inner args // Split into inner args
String[] innerArgs = arg.split("\\s+"); String[] innerArgs = arg.split("\\s+");

View File

@ -19,15 +19,15 @@ public class ARMaterial extends ArgReaderAbstract<Material>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public Material read(String arg, CommandSender sender) public Material read(String arg, CommandSender sender) throws MassiveCommandException
{ {
Material ret = Material.matchMaterial(arg); Material ret = Material.matchMaterial(arg);
if (ret == null) if (ret == null)
{ {
MassiveCommandException errors = new MassiveCommandException(); MassiveCommandException exception = new MassiveCommandException();
errors.addErrorMsg("<b>No material matches <h>"+arg+"<b>."); exception.addMsg("<b>No material matches <h>%s<b>.", arg);
errors.addErrorMsg("<i>Suggestion: <aqua>http://www.minecraftwiki.net/wiki/Data_values"); exception.addMsg("<i>Suggestion: <aqua>http://www.minecraftwiki.net/wiki/Data_values");
throw errors; throw exception;
} }
return ret; return ret;

View File

@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeDiffUtil;
import com.massivecraft.massivecore.util.Txt;
public class ARMillisDiff extends ArgReaderAbstract<Long> public class ARMillisDiff extends ArgReaderAbstract<Long>
{ {
@ -20,7 +19,7 @@ public class ARMillisDiff extends ArgReaderAbstract<Long>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public Long read(String arg, CommandSender sender) public Long read(String arg, CommandSender sender) throws MassiveCommandException
{ {
Long ret; Long ret;
try try
@ -29,7 +28,7 @@ public class ARMillisDiff extends ArgReaderAbstract<Long>
} }
catch (Exception e) catch (Exception e)
{ {
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage()); throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
} }
return ret; return ret;

View File

@ -20,7 +20,7 @@ public class ARPermission extends ArgReaderAbstract<Permission>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public Permission read(String arg, CommandSender sender) public Permission read(String arg, CommandSender sender) throws MassiveCommandException
{ {
Permission ret = null; Permission ret = null;
@ -33,7 +33,7 @@ public class ARPermission extends ArgReaderAbstract<Permission>
if (ret == null) if (ret == null)
{ {
throw new MassiveCommandException("<b>No permission with the name \"<h>" + arg + "<b>\" was found."); throw new MassiveCommandException().addMsg("<b>No permission with the name \"<h>%s<b>\" was found.", arg);
} }
return ret; return ret;

View File

@ -44,7 +44,7 @@ public abstract class ARSenderIdAbstract<T> extends ArgReaderAbstract<T>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public T read(String arg, CommandSender sender) public T read(String arg, CommandSender sender) throws MassiveCommandException
{ {
// Create Ret // Create Ret
T ret; T ret;
@ -60,7 +60,7 @@ public abstract class ARSenderIdAbstract<T> extends ArgReaderAbstract<T>
if (ret == null) if (ret == null)
{ {
// No alternatives found // No alternatives found
throw new MassiveCommandException("<b>No player matches \"<h>"+arg+"<b>\"."); throw new MassiveCommandException().addMsg("<b>No player matches \"<h>%s<b>\".", arg);
} }
// Return Ret // Return Ret

View File

@ -5,6 +5,7 @@ import java.util.Set;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
public class ARSet<T> extends ArgReaderAbstract<Set<T>> public class ARSet<T> extends ArgReaderAbstract<Set<T>>
@ -40,7 +41,7 @@ public class ARSet<T> extends ArgReaderAbstract<Set<T>>
// NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false). // NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false).
@Override @Override
public Set<T> read(String arg, CommandSender sender) public Set<T> read(String arg, CommandSender sender) throws MassiveCommandException
{ {
// Split into inner args // Split into inner args
String[] innerArgs = arg.split("\\s+"); String[] innerArgs = arg.split("\\s+");

View File

@ -19,14 +19,14 @@ public class ARSound extends ArgReaderAbstract<Sound>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public Sound read(String arg, CommandSender sender) public Sound read(String arg, CommandSender sender) throws MassiveCommandException
{ {
Sound result = getSoundFromString(arg); Sound result = getSoundFromString(arg);
if (result == null) if (result == null)
{ {
MassiveCommandException errors = new MassiveCommandException(); MassiveCommandException errors = new MassiveCommandException();
errors.addErrorMsg("<b>No sound matches \"<h>"+arg+"<b>\"."); errors.addMsg("<b>No sound matches \"<h>%s<b>\".", arg);
errors.addErrorMsg("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java"); errors.addMsg("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java");
throw errors; throw errors;
} }
return result; return result;

View File

@ -4,7 +4,6 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.util.Txt;
public class ARSoundEffect extends ArgReaderAbstract<SoundEffect> public class ARSoundEffect extends ArgReaderAbstract<SoundEffect>
{ {
@ -20,7 +19,7 @@ public class ARSoundEffect extends ArgReaderAbstract<SoundEffect>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public SoundEffect read(String arg, CommandSender sender) public SoundEffect read(String arg, CommandSender sender) throws MassiveCommandException
{ {
SoundEffect ret; SoundEffect ret;
@ -30,7 +29,7 @@ public class ARSoundEffect extends ArgReaderAbstract<SoundEffect>
} }
catch (Exception e) catch (Exception e)
{ {
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage()); throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
} }
return ret; return ret;
} }

View File

@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.cmd.MassiveCommandException; import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.util.Txt;
/** /**
* @deprecated use ARList * @deprecated use ARList
@ -28,7 +27,7 @@ public class ARSoundEffects extends ArgReaderAbstract<List<SoundEffect>>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public List<SoundEffect> read(String arg, CommandSender sender) public List<SoundEffect> read(String arg, CommandSender sender) throws MassiveCommandException
{ {
List<SoundEffect> ret = new ArrayList<SoundEffect>(); List<SoundEffect> ret = new ArrayList<SoundEffect>();
List<SoundEffect> result = new ArrayList<SoundEffect>(); List<SoundEffect> result = new ArrayList<SoundEffect>();
@ -46,7 +45,7 @@ public class ARSoundEffects extends ArgReaderAbstract<List<SoundEffect>>
} }
catch (Exception e) catch (Exception e)
{ {
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage()); throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
} }
return ret; return ret;
} }

View File

@ -32,7 +32,7 @@ public class ARUniverse extends ArgReaderAbstract<String>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public String read(String arg, CommandSender sender) public String read(String arg, CommandSender sender) throws MassiveCommandException
{ {
String result = new String(); String result = new String();
@ -42,11 +42,17 @@ public class ARUniverse extends ArgReaderAbstract<String>
} }
else else
{ {
MassiveCommandException errors = new MassiveCommandException(); MassiveCommandException exception = new MassiveCommandException();
errors.addErrorMsg("<b>No universe \"<h>" + arg + "<b>\" exists in multiverse <h>" + this.multiverse.getId() + "<b>."); exception.addMsg("<b>No universe \"<h>%s<b>\" exists in multiverse <h>%s<b>.", arg, this.multiverse.getId());
Collection<String> names = new ArrayList<String>(multiverse.getUniverses()); Collection<String> names = new ArrayList<String>(multiverse.getUniverses());
errors.addErrorMsg("<i>Use " + Txt.implodeCommaAndDot(names, "<h>%s", "<i>, ", " <i>or ", "<i>.")); String format = Txt.parse("<h>%s");
throw errors; String comma = Txt.parse("<i>, ");
String and = Txt.parse(" <i>or ");
String dot = Txt.parse("<i>.");
exception.addMsg("<i>Use %s", Txt.implodeCommaAndDot(names, format, comma, and, dot));
throw exception;
} }
return result; return result;

View File

@ -20,7 +20,7 @@ public class ARWorld extends ArgReaderAbstract<World>
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public World read(String arg, CommandSender sender) public World read(String arg, CommandSender sender) throws MassiveCommandException
{ {
World ret; World ret;
@ -32,7 +32,7 @@ public class ARWorld extends ArgReaderAbstract<World>
if (ret == null) if (ret == null)
{ {
throw new MassiveCommandException("<b>The world could not be found."); throw new MassiveCommandException().addMsg("<b>The world \"<h>%s<b>\" could not be found.", arg);
} }
return ret; return ret;

View File

@ -32,7 +32,6 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand
public void perform() public void perform()
{ {
String string = this.argConcatFrom(0); String string = this.argConcatFrom(0);
if (string == null) return;
String buffer = MassiveCoreEngineVariable.getBuffer(sender); String buffer = MassiveCoreEngineVariable.getBuffer(sender);
buffer += string; buffer += string;

View File

@ -32,7 +32,6 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand
public void perform() public void perform()
{ {
String string = this.argConcatFrom(0); String string = this.argConcatFrom(0);
if (string == null) return;
MassiveCoreEngineVariable.setBuffer(sender, string); MassiveCoreEngineVariable.setBuffer(sender, string);

View File

@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore;
import com.massivecraft.massivecore.MassiveCoreEngineVariable; import com.massivecraft.massivecore.MassiveCoreEngineVariable;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -30,10 +31,9 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Integer times = this.arg(0, ARInteger.get(), 1); Integer times = this.arg(0, ARInteger.get(), 1);
if (times == null) return;
String string = Txt.repeat(" ", times); String string = Txt.repeat(" ", times);

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.SoundEffect;
import com.massivecraft.massivecore.cmd.MassiveCommand; 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.ARList;
import com.massivecraft.massivecore.cmd.arg.ARSoundEffect; import com.massivecraft.massivecore.cmd.arg.ARSoundEffect;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -35,11 +36,10 @@ public class CmdMassiveCoreHearsound extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
// Args // Args
List<SoundEffect> soundEffects = this.argConcatFrom(0, ARList.get(ARSoundEffect.get())); List<SoundEffect> soundEffects = this.argConcatFrom(0, ARList.get(ARSoundEffect.get()));
if (soundEffects == null) return;
// Apply // Apply
SoundEffect.runAll(soundEffects, me); SoundEffect.runAll(soundEffects, me);

View File

@ -7,6 +7,7 @@ import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.NaturalOrderComparator; import com.massivecraft.massivecore.NaturalOrderComparator;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Coll;
@ -37,7 +38,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
// Args // Args
final String dbAlias = this.arg(0, ARString.get(), ConfServer.dburi); final String dbAlias = this.arg(0, ARString.get(), ConfServer.dburi);

View File

@ -4,6 +4,7 @@ import java.util.Map.Entry;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARColl; import com.massivecraft.massivecore.cmd.arg.ARColl;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Coll;
@ -34,7 +35,7 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
if (!this.argIsSet(0) || this.arg(0).equalsIgnoreCase(Coll.TOTAL)) if (!this.argIsSet(0) || this.arg(0).equalsIgnoreCase(Coll.TOTAL))
{ {
@ -43,7 +44,6 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
else else
{ {
Coll<?> coll = this.arg(0, ARColl.get()); Coll<?> coll = this.arg(0, ARColl.get());
if (coll == null) return;
this.performColl(coll); this.performColl(coll);
} }
} }

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.VisibilityMode; import com.massivecraft.massivecore.cmd.VisibilityMode;
import com.massivecraft.massivecore.cmd.arg.AREnum; import com.massivecraft.massivecore.cmd.arg.AREnum;
import com.massivecraft.massivecore.cmd.arg.ARFloat; import com.massivecraft.massivecore.cmd.arg.ARFloat;
@ -45,28 +46,18 @@ public class CmdMassiveCoreTest extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
// Args // Args
ParticleEffect particleEffect = this.arg(0, AREnum.get(ParticleEffect.class)); ParticleEffect particleEffect = this.arg(0, AREnum.get(ParticleEffect.class));
if (particleEffect == null) return;
Location center = me.getEyeLocation().add(0, 0, 0); Location center = me.getEyeLocation().add(0, 0, 0);
Float offsetX = this.arg(1, ARFloat.get()); Float offsetX = this.arg(1, ARFloat.get());
if (offsetX == null) return;
Float offsetY = this.arg(2, ARFloat.get()); Float offsetY = this.arg(2, ARFloat.get());
if (offsetY == null) return;
Float offsetZ = this.arg(3, ARFloat.get()); Float offsetZ = this.arg(3, ARFloat.get());
if (offsetZ == null) return;
Float speed = this.arg(4, ARFloat.get()); Float speed = this.arg(4, ARFloat.get());
if (speed == null) return;
Integer amount = this.arg(5, ARInteger.get()); Integer amount = this.arg(5, ARInteger.get());
if (amount == null) return;
Player player = me; Player player = me;

View File

@ -7,6 +7,7 @@ import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.AspectColl; import com.massivecraft.massivecore.AspectColl;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -34,11 +35,10 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
if (pageHumanBased == null) return;
// Create Lines // Create Lines
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();

View File

@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore;
import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.cmd.MassiveCommand; 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.ARAspect;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Aspect aspect = this.arg(0, ARAspect.get()); Aspect aspect = this.arg(0, ARAspect.get());
if (aspect == null) return;
msg(Txt.titleize("Aspect: "+aspect.getId())); msg(Txt.titleize("Aspect: "+aspect.getId()));
msg("<k>using multiverse: <v>%s",aspect.getMultiverse().getId()); msg("<k>using multiverse: <v>%s",aspect.getMultiverse().getId());

View File

@ -4,6 +4,7 @@ import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; 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.ARAspect;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -32,13 +33,10 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Aspect aspect = this.arg(0, ARAspect.get()); Aspect aspect = this.arg(0, ARAspect.get());
if (aspect == null) return;
Multiverse multiverse = this.arg(1, ARMultiverse.get()); Multiverse multiverse = this.arg(1, ARMultiverse.get());
if (multiverse == null) return;
aspect.setMultiverse(multiverse); aspect.setMultiverse(multiverse);

View File

@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(0, ARMultiverse.get()); Multiverse multiverse = this.arg(0, ARMultiverse.get());
if (multiverse == null) return;
String id = multiverse.getId(); String id = multiverse.getId();

View File

@ -7,6 +7,7 @@ import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.MultiverseColl; import com.massivecraft.massivecore.MultiverseColl;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -34,11 +35,10 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
// Args // Args
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1); Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
if (pageHumanBased == null) return;
// Create Lines // Create Lines
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();

View File

@ -8,6 +8,7 @@ import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
@ -35,10 +36,9 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(0, ARMultiverse.get()); Multiverse multiverse = this.arg(0, ARMultiverse.get());
if (multiverse == null) return;
msg(Txt.titleize("Multiverse: "+multiverse.getId())); msg(Txt.titleize("Multiverse: "+multiverse.getId()));

View File

@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(1, ARMultiverse.get()); Multiverse multiverse = this.arg(1, ARMultiverse.get());
if (multiverse == null) return;
String universe = this.arg(0); String universe = this.arg(0);

View File

@ -4,6 +4,7 @@ import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(1, ARMultiverse.get()); Multiverse multiverse = this.arg(1, ARMultiverse.get());
if (multiverse == null) return;
String universe = this.arg(0); String universe = this.arg(0);

View File

@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -30,10 +31,9 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(1, ARMultiverse.get()); Multiverse multiverse = this.arg(1, ARMultiverse.get());
if (multiverse == null) return;
String universe = this.arg(0); String universe = this.arg(0);

View File

@ -3,6 +3,7 @@ package com.massivecraft.massivecore.cmd.massivecore;
import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.MassiveCommandException;
import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.arg.ARMultiverse;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
@ -31,10 +32,9 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
@Override @Override
public void perform() public void perform() throws MassiveCommandException
{ {
Multiverse multiverse = this.arg(2, ARMultiverse.get()); Multiverse multiverse = this.arg(2, ARMultiverse.get());
if (multiverse == null) return;
String universe = this.arg(1); String universe = this.arg(1);
String worldName = this.arg(0); String worldName = this.arg(0);