Default values for ArgSettings
This commit is contained in:
parent
419f0c608d
commit
13a97293cd
@ -6,33 +6,63 @@ import org.bukkit.entity.Player;
|
||||
import com.massivecraft.massivecore.cmd.arg.AR;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
|
||||
public class ArgSetting
|
||||
public class ArgSetting<T>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static final String DEFAULT_DESC_DEFAULT = null;
|
||||
public static final Object DEFAULT_VALUE_DEFAULT = null;
|
||||
public static final boolean REQUIRED_FROM_CONSOLE_DEFAULT = false;
|
||||
public static final String DESCRIPTION_DEFAULT = null;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected AR<?> reader;
|
||||
public AR<?> getReader() { return reader; }
|
||||
public ArgSetting setReader(AR<?> reader) { this.reader = reader; return this; }
|
||||
protected AR<T> reader;
|
||||
public AR<T> getReader() { return reader; }
|
||||
public ArgSetting<T> setReader(AR<T> reader) { this.reader = reader; return this; }
|
||||
|
||||
protected String name;
|
||||
public String getName() { return name; }
|
||||
public ArgSetting setName(String name) { this.name = name; return this; }
|
||||
public ArgSetting<T> setName(String name) { this.name = name; return this; }
|
||||
|
||||
protected String defaultDesc = null;
|
||||
public ArgSetting<T> setDefaultDesc(String defaultDesc) { this.defaultDesc = defaultDesc; return this; }
|
||||
public String getDefaultDesc()
|
||||
{
|
||||
if (this.defaultDesc != null) return defaultDesc;
|
||||
if (this.isDefaultValueSet()) return String.valueOf(this.getDefaultValue());
|
||||
return null;
|
||||
}
|
||||
|
||||
protected T defaultValue = null;
|
||||
public T getDefaultValue() { return defaultValue; }
|
||||
public ArgSetting<T> setDefaultValue(T defaultValue)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
this.defaultValueSet = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
// A default value can be null.
|
||||
// So we must keep track of this field too.
|
||||
protected boolean defaultValueSet = false;
|
||||
public boolean isDefaultValueSet() { return this.defaultValueSet; }
|
||||
public void setDefaultValueSet(boolean defaultValueSet) { this.defaultValueSet = defaultValueSet; }
|
||||
|
||||
protected String def = null; // "default" is a reserved keyword in Java.
|
||||
public String getDefault() { return def; }
|
||||
public ArgSetting setDefault(String def) { this.def = def; return this; }
|
||||
|
||||
// Convenience
|
||||
public boolean isRequired() { return this.getDefault() == null; }
|
||||
public boolean isRequired() { return this.getDefaultDesc() == null; }
|
||||
public boolean isOptional() { return ! this.isRequired(); }
|
||||
|
||||
// Is this arg ALWAYS required from the console?
|
||||
// That might the case if the arg is a player. and default is oneself.
|
||||
protected boolean requiredFromConsole = false;
|
||||
public boolean isRequiredFromConsole() { return requiredFromConsole; }
|
||||
public ArgSetting setRequiredFromConsole(boolean requiredFromConsole) { this.requiredFromConsole = requiredFromConsole; return this; }
|
||||
public ArgSetting<T> setRequiredFromConsole(boolean requiredFromConsole) { this.requiredFromConsole = requiredFromConsole; return this; }
|
||||
|
||||
// An optional description of this argument.
|
||||
// Examples:
|
||||
@ -41,7 +71,7 @@ public class ArgSetting
|
||||
// 3. "the amount of money to pay"
|
||||
protected String desc = null;
|
||||
public String getDesc() { return desc; }
|
||||
public ArgSetting setDesc(String desc) { this.desc = desc; return this; }
|
||||
public ArgSetting<T> setDesc(String desc) { this.desc = desc; return this; }
|
||||
|
||||
public boolean hasDesc() { return this.getDesc() != null; }
|
||||
|
||||
@ -53,7 +83,7 @@ public class ArgSetting
|
||||
// description must not be set in the constructor.
|
||||
|
||||
// All
|
||||
public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name, String def)
|
||||
public ArgSetting(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc)
|
||||
{
|
||||
// Null checks
|
||||
if (reader == null) throw new IllegalArgumentException("reader mustn't be null");
|
||||
@ -62,31 +92,61 @@ public class ArgSetting
|
||||
this.setReader(reader);
|
||||
this.setRequiredFromConsole(requiredFromConsole);
|
||||
this.setName(name);
|
||||
this.setDefault(def);
|
||||
this.setDefaultDesc(defaultDesc);
|
||||
this.setDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
// Without defaultValue
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArgSetting(AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc)
|
||||
{
|
||||
this((T) DEFAULT_VALUE_DEFAULT, reader, requiredFromConsole, name, defaultDesc);
|
||||
|
||||
// In fact the default value is not set.
|
||||
this.defaultValueSet = false;
|
||||
}
|
||||
|
||||
// Without reqFromConsole.
|
||||
public ArgSetting(AR<?> reader, String name, String def)
|
||||
public ArgSetting(T defaultValue, AR<T> reader, String name, String defaultDesc)
|
||||
{
|
||||
this(reader, false, name, def);
|
||||
this(defaultValue, reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc);
|
||||
}
|
||||
|
||||
// Without default.
|
||||
public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name)
|
||||
// Without defaultDesc.
|
||||
public ArgSetting(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name)
|
||||
{
|
||||
this(reader, requiredFromConsole, name, null);
|
||||
this(defaultValue, reader, requiredFromConsole, name, DEFAULT_DESC_DEFAULT);
|
||||
}
|
||||
|
||||
// Without defaultValue & reqFromConsole.
|
||||
public ArgSetting(AR<T> reader, String name, String defaultDesc)
|
||||
{
|
||||
this(reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc);
|
||||
}
|
||||
|
||||
// Without reqFromConsole and default.
|
||||
public ArgSetting (AR<?> reader, String name)
|
||||
// Without defaultValue & defaultDesc.
|
||||
public ArgSetting(AR<T> reader, boolean requiredFromConsole, String name)
|
||||
{
|
||||
this(reader, false, name, null);
|
||||
this(reader, requiredFromConsole, name, DEFAULT_DESC_DEFAULT);
|
||||
}
|
||||
|
||||
// Without reqFromConsole and defaultDesc.
|
||||
public ArgSetting(T defaultValue, AR<T> reader, String name)
|
||||
{
|
||||
this(defaultValue, reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT);
|
||||
}
|
||||
|
||||
// Without defaultValue, reqFromConsole and defaultDesc.
|
||||
public ArgSetting(AR<T> reader, String name)
|
||||
{
|
||||
this(reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// STATIC FACTORY
|
||||
// STATIC FACTORY (DEPRECATED)
|
||||
// -------------------------------------------- //
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Deprecated
|
||||
public static ArgSetting of(AR<?> reader, boolean requiredFromConsole, String name, String def)
|
||||
{
|
||||
@ -120,7 +180,7 @@ public class ArgSetting
|
||||
{
|
||||
if (this.isRequiredFor(sender)) return "<" + this.getName() + ">";
|
||||
|
||||
String def = this.getDefault();
|
||||
String def = this.getDefaultDesc();
|
||||
def = (def != null ? "=" + def : "");
|
||||
return "[" + this.getName() + def + "]";
|
||||
}
|
||||
@ -129,11 +189,11 @@ public class ArgSetting
|
||||
// COMMONLY USED ARG SETTINGS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static ArgSetting getPager()
|
||||
public static ArgSetting<Integer> getPager()
|
||||
{
|
||||
// We can't use a singletone, because people might
|
||||
// want to set a description.
|
||||
return new ArgSetting(ARInteger.get(), "page", "1");
|
||||
return new ArgSetting<Integer>(1, ARInteger.get(), "page", "1");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,14 +177,14 @@ public class MassiveCommand
|
||||
|
||||
// FIELD argSettings
|
||||
// Settings for all args.
|
||||
protected List<ArgSetting> argSettings;
|
||||
public List<ArgSetting> getArgSettings() { return this.argSettings; }
|
||||
public void setArgSettings(List<ArgSetting> argSettings) { this.argSettings = argSettings; }
|
||||
protected List<ArgSetting<?>> argSettings;
|
||||
public List<ArgSetting<?>> getArgSettings() { return this.argSettings; }
|
||||
public void setArgSettings(List<ArgSetting<?>> argSettings) { this.argSettings = argSettings; }
|
||||
|
||||
// The index is the same as the argument index.
|
||||
// So argAt(x) should be read by getArgReader(x)
|
||||
|
||||
public ArgSetting getArgSetting(int index)
|
||||
public ArgSetting<?> getArgSetting(int index)
|
||||
{
|
||||
if (this.isUsingConcatFrom() && this.getConcatFromIndex() < index) index = this.getConcatFromIndex();
|
||||
return this.getArgSettings().get(index);
|
||||
@ -192,7 +192,7 @@ public class MassiveCommand
|
||||
|
||||
public AR<?> getArgReader(int index)
|
||||
{
|
||||
ArgSetting setting = this.getArgSetting(index);
|
||||
ArgSetting<?> setting = this.getArgSetting(index);
|
||||
return setting.getReader();
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ public class MassiveCommand
|
||||
}
|
||||
|
||||
// The actual setting.
|
||||
public ArgSetting addArg(ArgSetting setting, boolean concatFromHere)
|
||||
public <T> ArgSetting<T> addArg(ArgSetting<T> setting, boolean concatFromHere)
|
||||
{
|
||||
// Concat safety.
|
||||
if (this.isUsingConcatFrom())
|
||||
@ -229,57 +229,113 @@ public class MassiveCommand
|
||||
}
|
||||
|
||||
// The actual setting without concat.
|
||||
public ArgSetting addArg(ArgSetting setting)
|
||||
public <T> ArgSetting<T> addArg(ArgSetting<T> setting)
|
||||
{
|
||||
return this.addArg(setting, false);
|
||||
}
|
||||
|
||||
// All
|
||||
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def, boolean concatFromHere)
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, requiredFromConsole, name, def), concatFromHere);
|
||||
return this.addArg(new ArgSetting<T>(defaultValue, reader, requiredFromConsole, name, defaultDesc), concatFromHere);
|
||||
}
|
||||
|
||||
// Without concat.
|
||||
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def)
|
||||
// WITHOUT 1
|
||||
|
||||
// Without defaultValue
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, requiredFromConsole, name, def), false);
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name, defaultDesc), concatFromHere);
|
||||
}
|
||||
|
||||
// Without reqFromConsole.
|
||||
public ArgSetting addArg(AR<?> reader, String name, String def, boolean concatFromHere)
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, String name, String defaultDesc, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, name, def), concatFromHere);
|
||||
}
|
||||
|
||||
// Without default.
|
||||
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, requiredFromConsole, name), concatFromHere);
|
||||
}
|
||||
|
||||
// Without concat & reqFromConsole.
|
||||
public ArgSetting addArg(AR<?> reader, String name, String def)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, name, def), false);
|
||||
}
|
||||
|
||||
// Without concat and default.
|
||||
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, requiredFromConsole, name), false);
|
||||
return this.addArg(new ArgSetting<T>(reader, name, defaultDesc), concatFromHere);
|
||||
}
|
||||
|
||||
// Without reqFromConsole and default.
|
||||
public ArgSetting addArg(AR<?> reader, String name, boolean concatFromHere)
|
||||
// Without defaultDesc.
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, name), concatFromHere);
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name), concatFromHere);
|
||||
}
|
||||
|
||||
// Without concat.
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name, defaultDesc), false);
|
||||
}
|
||||
|
||||
// WITHOUT 2
|
||||
|
||||
// Without defaultValue & reqFromConsole
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, String name, String defaultDesc, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, name, defaultDesc), concatFromHere);
|
||||
}
|
||||
|
||||
// Without defaultValue & defaultDesc
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, boolean requiredFromConsole, String name, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name), concatFromHere);
|
||||
}
|
||||
|
||||
// Without defaultValue & concat.
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, boolean requiredFromConsole, String name, String defaultDesc)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name, defaultDesc));
|
||||
}
|
||||
|
||||
// Without concat, reqFromConsole and default.
|
||||
public ArgSetting addArg(AR<?> reader, String name)
|
||||
// Without reqFromConsole & defaultDesc.
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, String name, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting(reader, name), false);
|
||||
return this.addArg(new ArgSetting<T>(defaultValue, reader, name), concatFromHere);
|
||||
}
|
||||
|
||||
// Without reqFromConsole & concat.
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, String name, String defaultDesc)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(defaultValue, reader, name, defaultDesc));
|
||||
}
|
||||
|
||||
// Without defaultDesc & concat.
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, boolean requiredFromConsole, String name)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(defaultValue, reader, requiredFromConsole, name));
|
||||
}
|
||||
|
||||
// WITHOUT 3
|
||||
|
||||
// Without defaultValue, reqFromConsole & defaultDesc.
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, String name, boolean concatFromHere)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, name), concatFromHere);
|
||||
}
|
||||
|
||||
// Without defaultValue, reqFromConsole & concat .
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, String name, String defaultDesc)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, name, defaultDesc));
|
||||
}
|
||||
|
||||
// Without defaultValue, defaultDesc & concat .
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, boolean requiredFromConsole, String name)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, requiredFromConsole, name));
|
||||
}
|
||||
|
||||
// Without reqFromConsole, defaultDesc & concat .
|
||||
public <T> ArgSetting<T> addArg(T defaultValue, AR<T> reader, String name)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(defaultValue, reader, name));
|
||||
}
|
||||
|
||||
// WITHOUT 4
|
||||
|
||||
// Without defaultValue, reqFromConsole, defaultDesc & concat .
|
||||
public <T> ArgSetting<T> addArg(AR<T> reader, String name)
|
||||
{
|
||||
return this.addArg(new ArgSetting<T>(reader, name));
|
||||
}
|
||||
|
||||
// FIELD: requiredArgs
|
||||
@ -441,7 +497,7 @@ public class MassiveCommand
|
||||
if ( ! this.isUsingNewArgSystem()) return this.getRequiredArgs().size();
|
||||
|
||||
int ret = 0;
|
||||
for (ArgSetting setting : this.getArgSettings())
|
||||
for (ArgSetting<?> setting : this.getArgSettings())
|
||||
{
|
||||
if (setting.isRequiredFor(sender)) ret++;
|
||||
}
|
||||
@ -454,7 +510,7 @@ public class MassiveCommand
|
||||
if ( ! this.isUsingNewArgSystem()) return this.getOptionalArgs().size();
|
||||
|
||||
int ret = 0;
|
||||
for (ArgSetting setting : this.getArgSettings())
|
||||
for (ArgSetting<?> setting : this.getArgSettings())
|
||||
{
|
||||
if (setting.isOptionalFor(sender)) ret++;
|
||||
}
|
||||
@ -477,7 +533,7 @@ public class MassiveCommand
|
||||
|
||||
this.aliases = new ArrayList<String>();
|
||||
|
||||
this.argSettings = new ArrayList<ArgSetting>();
|
||||
this.argSettings = new ArrayList<ArgSetting<?>>();
|
||||
|
||||
this.requiredArgs = new ArrayList<String>();
|
||||
this.optionalArgs = new LinkedHashMap<String, String>();
|
||||
@ -863,7 +919,7 @@ public class MassiveCommand
|
||||
List<String> ret = new MassiveList<String>();
|
||||
if (this.isUsingNewArgSystem())
|
||||
{
|
||||
for (ArgSetting setting : this.getArgSettings())
|
||||
for (ArgSetting<?> setting : this.getArgSettings())
|
||||
{
|
||||
ret.add(setting.getUseageTemplateDisplayFor(sender));
|
||||
}
|
||||
@ -1085,24 +1141,31 @@ public class MassiveCommand
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readArgAt(int idx) throws MassiveException
|
||||
{
|
||||
// Make sure that an ArgSetting is present.
|
||||
if ( ! this.hasArgSettingForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. ArgSettings size: " + this.getArgSettings().size());
|
||||
|
||||
// Get the setting
|
||||
ArgSetting<T> setting = (ArgSetting<T>) this.getArgSetting(idx);
|
||||
// Return the default in the setting.
|
||||
if ( ! this.argIsSet(idx) && setting.isDefaultValueSet()) return setting.getDefaultValue();
|
||||
|
||||
// The was no arg, or default value in the setting.
|
||||
if ( ! this.argIsSet(idx)) throw new IllegalArgumentException("Trying to access arg: " + idx + " but that is not set.");
|
||||
|
||||
String str = this.argAt(idx);
|
||||
return this.readArgFrom(str, (AR<T>) this.getArgReader(idx));
|
||||
// Just read the arg normally.
|
||||
String arg = this.argAt(idx);
|
||||
return setting.getReader().read(arg, sender);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readArgAt(int idx, T defaultNotSet) throws MassiveException
|
||||
{
|
||||
if ( ! this.hasArgSettingForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. ArgSettings size: " + this.getArgSettings().size());
|
||||
// Return the default passed.
|
||||
if ( ! this.argIsSet(idx)) return defaultNotSet;
|
||||
|
||||
String str = this.argAt(idx);
|
||||
return this.readArgFrom(str, (AR<T>)this.getArgReader(idx), defaultNotSet);
|
||||
return readArgAt(idx);
|
||||
}
|
||||
|
||||
// Core Logic
|
||||
// Basic Logic
|
||||
|
||||
public <T> T readArgFrom(AR<T> argReader) throws MassiveException
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String string = (String) this.readArg();
|
||||
String string = this.readArg();
|
||||
|
||||
String buffer = MassiveCoreEngineVariable.getBuffer(sender);
|
||||
buffer += string;
|
||||
|
@ -32,7 +32,7 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String string = (String) this.readArg();
|
||||
String string = this.readArg();
|
||||
|
||||
MassiveCoreEngineVariable.setBuffer(sender, string);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
int times = (Integer) this.readArg(1);
|
||||
int times = this.readArg(1);
|
||||
|
||||
String string = Txt.repeat(" ", times);
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class CmdMassiveCoreCmdurl extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
String urlString = (String) this.readArg();
|
||||
String urlString = this.readArg();
|
||||
|
||||
final URL url;
|
||||
try
|
||||
|
@ -33,13 +33,12 @@ public class CmdMassiveCoreHearsound extends MassiveCommand
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
List<SoundEffect> soundEffects = (List<SoundEffect>) this.readArg();
|
||||
List<SoundEffect> soundEffects = this.readArg();
|
||||
|
||||
// Apply
|
||||
SoundEffect.runAll(soundEffects, me);
|
||||
|
@ -42,7 +42,7 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
final String fromAlias = (String) this.readArg();
|
||||
final String fromAlias = this.readArg();
|
||||
final Db fromDb = MStore.getDb(fromAlias);
|
||||
if (fromDb == null)
|
||||
{
|
||||
@ -50,7 +50,7 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
|
||||
return;
|
||||
}
|
||||
|
||||
final String toAlias = (String) this.readArg();
|
||||
final String toAlias = this.readArg();
|
||||
final Db toDb = MStore.getDb(toAlias);
|
||||
if (toDb == null)
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
final String dbAlias = (String) this.readArg(ConfServer.dburi);
|
||||
final String dbAlias = this.readArg(ConfServer.dburi);
|
||||
final Db db = MStore.getDb(dbAlias);
|
||||
if (db == null)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
Coll<?> coll = (Coll<?>) this.readArg();
|
||||
Coll<?> coll = this.readArg();
|
||||
this.performColl(coll);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class CmdMassiveCoreTest extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
ParticleEffect particleEffect = (ParticleEffect) this.readArg();
|
||||
ParticleEffect particleEffect = this.readArg();
|
||||
|
||||
Location center = me.getEyeLocation().add(0, 0, 0);
|
||||
|
||||
|
@ -7,8 +7,8 @@ import com.massivecraft.massivecore.Aspect;
|
||||
import com.massivecraft.massivecore.AspectColl;
|
||||
import com.massivecraft.massivecore.MassiveCorePerm;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.cmd.ArgSetting;
|
||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
@ -24,7 +24,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
|
||||
this.addAliases("l", "list");
|
||||
|
||||
// Args
|
||||
this.addArg(ARInteger.get(), "page", "1").setDesc("the page in the aspect list");
|
||||
this.addArg(ArgSetting.getPager()).setDesc("the page in the aspect list");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node));
|
||||
@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
int pageHumanBased = (Integer) this.readArg(1);
|
||||
int pageHumanBased = this.readArg();
|
||||
|
||||
// Create Lines
|
||||
List<String> lines = new ArrayList<String>();
|
||||
|
@ -33,7 +33,7 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
Aspect aspect = (Aspect) this.readArg();
|
||||
Aspect aspect = this.readArg();
|
||||
|
||||
msg(Txt.titleize("Aspect: "+aspect.getId()));
|
||||
msg("<k>using multiverse: <v>%s",aspect.getMultiverse().getId());
|
||||
|
@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
Aspect aspect = (Aspect) this.readArg();
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
Aspect aspect = this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
aspect.setMultiverse(multiverse);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
String id = multiverse.getId();
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
// Args
|
||||
int pageHumanBased = (Integer) this.readArg(1);
|
||||
int pageHumanBased = this.readArg(1);
|
||||
|
||||
// Create Lines
|
||||
List<String> lines = new ArrayList<String>();
|
||||
|
@ -32,7 +32,7 @@ public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String id = (String) this.readArg();
|
||||
String id = this.readArg();
|
||||
|
||||
if (MultiverseColl.get().containsId(id))
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
msg(Txt.titleize("Multiverse: "+multiverse.getId()));
|
||||
|
||||
|
@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String universe = (String) this.readArg();
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
String universe = this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
if (universe.equals(MassiveCore.DEFAULT))
|
||||
{
|
||||
|
@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String universe = (String) this.readArg();
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
String universe = this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
if (universe.equals(MassiveCore.DEFAULT))
|
||||
{
|
||||
|
@ -34,8 +34,8 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String universe = (String) this.readArg();
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
String universe = this.readArg();
|
||||
Multiverse multiverse = this.readArg();
|
||||
|
||||
if (multiverse.containsUniverse(universe))
|
||||
{
|
||||
|
@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
String worldName = (String) this.readArg();
|
||||
String universe = (String) this.readArg();
|
||||
String worldName = this.readArg();
|
||||
String universe = this.readArg();
|
||||
Multiverse multiverse = (Multiverse) this.readArg();
|
||||
|
||||
if (!multiverse.containsUniverse(universe))
|
||||
|
Loading…
Reference in New Issue
Block a user