ArgReaders use exceptions - Part 2
This commit is contained in:
parent
47b2eeccb4
commit
49444c6fbf
@ -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");
|
||||
this.setDesc("");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("page", "1");
|
||||
|
||||
// Other
|
||||
this.setDesc("");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -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<String> lines = new ArrayList<String>();
|
||||
|
||||
for (String helpline : parentCommand.getHelp())
|
||||
{
|
||||
lines.add(Txt.parse("<a>#<i> "+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));
|
||||
}
|
||||
|
||||
|
@ -339,14 +339,15 @@ public class MassiveCommand
|
||||
}
|
||||
this.fixSenderVars();
|
||||
|
||||
if ( ! isValidCall(this.sender, this.getArgs())) return;
|
||||
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
|
||||
{
|
||||
|
@ -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,19 +15,10 @@ public class MassiveCommandException extends RuntimeException
|
||||
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
|
||||
/*
|
||||
public MassiveCommandException()
|
||||
{
|
||||
|
||||
@ -32,12 +26,44 @@ public class MassiveCommandException extends RuntimeException
|
||||
|
||||
public MassiveCommandException(String msg)
|
||||
{
|
||||
this.errorMsgs.add(msg);
|
||||
this.messages.add(msg);
|
||||
}
|
||||
|
||||
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)); }
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<T> extends ArgReaderAbstract<T>
|
||||
}
|
||||
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;
|
||||
|
@ -23,28 +23,32 @@ public abstract class ARAbstractSelect<T> extends ArgReaderAbstract<T>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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("<b>No " + this.typename() + " matches \"<h>"+arg+"<b>\".");
|
||||
MassiveCommandException exception = new MassiveCommandException();
|
||||
exception.addMsg("<b>No %s matches \"<h>%s<b>\".", this.typename(), arg);
|
||||
if (this.canList(sender))
|
||||
{
|
||||
Collection<String> names = this.altNames(sender);
|
||||
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
|
||||
{
|
||||
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;
|
||||
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.massivecore.cmd.MassiveCommandException;
|
||||
|
||||
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).
|
||||
@Override
|
||||
public List<T> read(String arg, CommandSender sender)
|
||||
public List<T> read(String arg, CommandSender sender) throws MassiveCommandException
|
||||
{
|
||||
// Split into inner args
|
||||
String[] innerArgs = arg.split("\\s+");
|
||||
|
@ -19,15 +19,15 @@ public class ARMaterial extends ArgReaderAbstract<Material>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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("<b>No material matches <h>"+arg+"<b>.");
|
||||
errors.addErrorMsg("<i>Suggestion: <aqua>http://www.minecraftwiki.net/wiki/Data_values");
|
||||
throw errors;
|
||||
MassiveCommandException exception = new MassiveCommandException();
|
||||
exception.addMsg("<b>No material matches <h>%s<b>.", arg);
|
||||
exception.addMsg("<i>Suggestion: <aqua>http://www.minecraftwiki.net/wiki/Data_values");
|
||||
throw exception;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -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<Long>
|
||||
{
|
||||
@ -20,7 +19,7 @@ public class ARMillisDiff extends ArgReaderAbstract<Long>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<Long>
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage());
|
||||
throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -20,7 +20,7 @@ public class ARPermission extends ArgReaderAbstract<Permission>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<Permission>
|
||||
|
||||
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;
|
||||
|
@ -44,7 +44,7 @@ public abstract class ARSenderIdAbstract<T> extends ArgReaderAbstract<T>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<T> extends ArgReaderAbstract<T>
|
||||
if (ret == null)
|
||||
{
|
||||
// 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
|
||||
|
@ -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<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).
|
||||
@Override
|
||||
public Set<T> read(String arg, CommandSender sender)
|
||||
public Set<T> read(String arg, CommandSender sender) throws MassiveCommandException
|
||||
{
|
||||
// Split into inner args
|
||||
String[] innerArgs = arg.split("\\s+");
|
||||
|
@ -19,14 +19,14 @@ public class ARSound extends ArgReaderAbstract<Sound>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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("<b>No sound matches \"<h>"+arg+"<b>\".");
|
||||
errors.addErrorMsg("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java");
|
||||
errors.addMsg("<b>No sound matches \"<h>%s<b>\".", arg);
|
||||
errors.addMsg("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java");
|
||||
throw errors;
|
||||
}
|
||||
return result;
|
||||
|
@ -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<SoundEffect>
|
||||
{
|
||||
@ -20,7 +19,7 @@ public class ARSoundEffect extends ArgReaderAbstract<SoundEffect>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<SoundEffect>
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage());
|
||||
throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -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<List<SoundEffect>>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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> result = new ArrayList<SoundEffect>();
|
||||
@ -46,7 +45,7 @@ public class ARSoundEffects extends ArgReaderAbstract<List<SoundEffect>>
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new MassiveCommandException(Txt.parse("<b>") + e.getMessage());
|
||||
throw new MassiveCommandException().addMsg("<b>%s", e.getMessage());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class ARUniverse extends ArgReaderAbstract<String>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<String>
|
||||
}
|
||||
else
|
||||
{
|
||||
MassiveCommandException errors = new MassiveCommandException();
|
||||
errors.addErrorMsg("<b>No universe \"<h>" + arg + "<b>\" exists in multiverse <h>" + this.multiverse.getId() + "<b>.");
|
||||
MassiveCommandException exception = new MassiveCommandException();
|
||||
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());
|
||||
errors.addErrorMsg("<i>Use " + Txt.implodeCommaAndDot(names, "<h>%s", "<i>, ", " <i>or ", "<i>."));
|
||||
throw errors;
|
||||
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 exception;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -20,7 +20,7 @@ public class ARWorld extends ArgReaderAbstract<World>
|
||||
// -------------------------------------------- //
|
||||
|
||||
@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<World>
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<SoundEffect> soundEffects = this.argConcatFrom(0, ARList.get(ARSoundEffect.get()));
|
||||
if (soundEffects == null) return;
|
||||
|
||||
// Apply
|
||||
SoundEffect.runAll(soundEffects, me);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<String> lines = new ArrayList<String>();
|
||||
|
@ -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("<k>using multiverse: <v>%s",aspect.getMultiverse().getId());
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<String> lines = new ArrayList<String>();
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user