Default values for ArgSettings

This commit is contained in:
Magnus Ulf 2015-05-13 21:28:39 +02:00 committed by Olof Larsson
parent 419f0c608d
commit 13a97293cd
22 changed files with 226 additions and 104 deletions

View File

@ -6,33 +6,63 @@ import org.bukkit.entity.Player;
import com.massivecraft.massivecore.cmd.arg.AR; import com.massivecraft.massivecore.cmd.arg.AR;
import com.massivecraft.massivecore.cmd.arg.ARInteger; 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 // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
protected AR<?> reader; protected AR<T> reader;
public AR<?> getReader() { return reader; } public AR<T> getReader() { return reader; }
public ArgSetting setReader(AR<?> reader) { this.reader = reader; return this; } public ArgSetting<T> setReader(AR<T> reader) { this.reader = reader; return this; }
protected String name; protected String name;
public String getName() { return 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 // Convenience
public boolean isRequired() { return this.getDefault() == null; } public boolean isRequired() { return this.getDefaultDesc() == null; }
public boolean isOptional() { return ! this.isRequired(); } public boolean isOptional() { return ! this.isRequired(); }
// Is this arg ALWAYS required from the console? // Is this arg ALWAYS required from the console?
// That might the case if the arg is a player. and default is oneself. // That might the case if the arg is a player. and default is oneself.
protected boolean requiredFromConsole = false; protected boolean requiredFromConsole = false;
public boolean isRequiredFromConsole() { return requiredFromConsole; } 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. // An optional description of this argument.
// Examples: // Examples:
@ -41,7 +71,7 @@ public class ArgSetting
// 3. "the amount of money to pay" // 3. "the amount of money to pay"
protected String desc = null; protected String desc = null;
public String getDesc() { return desc; } 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; } public boolean hasDesc() { return this.getDesc() != null; }
@ -53,7 +83,7 @@ public class ArgSetting
// description must not be set in the constructor. // description must not be set in the constructor.
// All // 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 // Null checks
if (reader == null) throw new IllegalArgumentException("reader mustn't be null"); if (reader == null) throw new IllegalArgumentException("reader mustn't be null");
@ -62,31 +92,61 @@ public class ArgSetting
this.setReader(reader); this.setReader(reader);
this.setRequiredFromConsole(requiredFromConsole); this.setRequiredFromConsole(requiredFromConsole);
this.setName(name); 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. // 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. // Without defaultDesc.
public ArgSetting(AR<?> reader, boolean requiredFromConsole, String name) 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. // Without defaultValue & defaultDesc.
public ArgSetting (AR<?> reader, String name) 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 @Deprecated
public static ArgSetting of(AR<?> reader, boolean requiredFromConsole, String name, String def) 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() + ">"; if (this.isRequiredFor(sender)) return "<" + this.getName() + ">";
String def = this.getDefault(); String def = this.getDefaultDesc();
def = (def != null ? "=" + def : ""); def = (def != null ? "=" + def : "");
return "[" + this.getName() + def + "]"; return "[" + this.getName() + def + "]";
} }
@ -129,11 +189,11 @@ public class ArgSetting
// COMMONLY USED ARG SETTINGS // COMMONLY USED ARG SETTINGS
// -------------------------------------------- // // -------------------------------------------- //
public static ArgSetting getPager() public static ArgSetting<Integer> getPager()
{ {
// We can't use a singletone, because people might // We can't use a singletone, because people might
// want to set a description. // want to set a description.
return new ArgSetting(ARInteger.get(), "page", "1"); return new ArgSetting<Integer>(1, ARInteger.get(), "page", "1");
} }
} }

View File

@ -177,14 +177,14 @@ public class MassiveCommand
// FIELD argSettings // FIELD argSettings
// Settings for all args. // Settings for all args.
protected List<ArgSetting> argSettings; protected List<ArgSetting<?>> argSettings;
public List<ArgSetting> getArgSettings() { return this.argSettings; } public List<ArgSetting<?>> getArgSettings() { return this.argSettings; }
public void setArgSettings(List<ArgSetting> argSettings) { this.argSettings = argSettings; } public void setArgSettings(List<ArgSetting<?>> argSettings) { this.argSettings = argSettings; }
// The index is the same as the argument index. // The index is the same as the argument index.
// So argAt(x) should be read by getArgReader(x) // 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(); if (this.isUsingConcatFrom() && this.getConcatFromIndex() < index) index = this.getConcatFromIndex();
return this.getArgSettings().get(index); return this.getArgSettings().get(index);
@ -192,7 +192,7 @@ public class MassiveCommand
public AR<?> getArgReader(int index) public AR<?> getArgReader(int index)
{ {
ArgSetting setting = this.getArgSetting(index); ArgSetting<?> setting = this.getArgSetting(index);
return setting.getReader(); return setting.getReader();
} }
@ -205,7 +205,7 @@ public class MassiveCommand
} }
// The actual setting. // The actual setting.
public ArgSetting addArg(ArgSetting setting, boolean concatFromHere) public <T> ArgSetting<T> addArg(ArgSetting<T> setting, boolean concatFromHere)
{ {
// Concat safety. // Concat safety.
if (this.isUsingConcatFrom()) if (this.isUsingConcatFrom())
@ -229,57 +229,113 @@ public class MassiveCommand
} }
// The actual setting without concat. // The actual setting without concat.
public ArgSetting addArg(ArgSetting setting) public <T> ArgSetting<T> addArg(ArgSetting<T> setting)
{ {
return this.addArg(setting, false); return this.addArg(setting, false);
} }
// All // 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. // WITHOUT 1
public ArgSetting addArg(AR<?> reader, boolean requiredFromConsole, String name, String def)
// 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. // 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); return this.addArg(new ArgSetting<T>(reader, name, defaultDesc), 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);
} }
// Without reqFromConsole and default. // Without defaultDesc.
public ArgSetting addArg(AR<?> reader, String name, boolean concatFromHere) 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. // Without reqFromConsole & defaultDesc.
public ArgSetting addArg(AR<?> reader, String name) 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 // FIELD: requiredArgs
@ -441,7 +497,7 @@ public class MassiveCommand
if ( ! this.isUsingNewArgSystem()) return this.getRequiredArgs().size(); if ( ! this.isUsingNewArgSystem()) return this.getRequiredArgs().size();
int ret = 0; int ret = 0;
for (ArgSetting setting : this.getArgSettings()) for (ArgSetting<?> setting : this.getArgSettings())
{ {
if (setting.isRequiredFor(sender)) ret++; if (setting.isRequiredFor(sender)) ret++;
} }
@ -454,7 +510,7 @@ public class MassiveCommand
if ( ! this.isUsingNewArgSystem()) return this.getOptionalArgs().size(); if ( ! this.isUsingNewArgSystem()) return this.getOptionalArgs().size();
int ret = 0; int ret = 0;
for (ArgSetting setting : this.getArgSettings()) for (ArgSetting<?> setting : this.getArgSettings())
{ {
if (setting.isOptionalFor(sender)) ret++; if (setting.isOptionalFor(sender)) ret++;
} }
@ -477,7 +533,7 @@ public class MassiveCommand
this.aliases = new ArrayList<String>(); this.aliases = new ArrayList<String>();
this.argSettings = new ArrayList<ArgSetting>(); this.argSettings = new ArrayList<ArgSetting<?>>();
this.requiredArgs = new ArrayList<String>(); this.requiredArgs = new ArrayList<String>();
this.optionalArgs = new LinkedHashMap<String, String>(); this.optionalArgs = new LinkedHashMap<String, String>();
@ -863,7 +919,7 @@ public class MassiveCommand
List<String> ret = new MassiveList<String>(); List<String> ret = new MassiveList<String>();
if (this.isUsingNewArgSystem()) if (this.isUsingNewArgSystem())
{ {
for (ArgSetting setting : this.getArgSettings()) for (ArgSetting<?> setting : this.getArgSettings())
{ {
ret.add(setting.getUseageTemplateDisplayFor(sender)); ret.add(setting.getUseageTemplateDisplayFor(sender));
} }
@ -1085,24 +1141,31 @@ public class MassiveCommand
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T readArgAt(int idx) throws MassiveException 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()); 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."); if ( ! this.argIsSet(idx)) throw new IllegalArgumentException("Trying to access arg: " + idx + " but that is not set.");
String str = this.argAt(idx); // Just read the arg normally.
return this.readArgFrom(str, (AR<T>) this.getArgReader(idx)); String arg = this.argAt(idx);
return setting.getReader().read(arg, sender);
} }
@SuppressWarnings("unchecked")
public <T> T readArgAt(int idx, T defaultNotSet) throws MassiveException 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; if ( ! this.argIsSet(idx)) return defaultNotSet;
String str = this.argAt(idx); return readArgAt(idx);
return this.readArgFrom(str, (AR<T>)this.getArgReader(idx), defaultNotSet);
} }
// Core Logic // Basic Logic
public <T> T readArgFrom(AR<T> argReader) throws MassiveException public <T> T readArgFrom(AR<T> argReader) throws MassiveException
{ {

View File

@ -32,7 +32,7 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String string = (String) this.readArg(); String string = this.readArg();
String buffer = MassiveCoreEngineVariable.getBuffer(sender); String buffer = MassiveCoreEngineVariable.getBuffer(sender);
buffer += string; buffer += string;

View File

@ -32,7 +32,7 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String string = (String) this.readArg(); String string = this.readArg();
MassiveCoreEngineVariable.setBuffer(sender, string); MassiveCoreEngineVariable.setBuffer(sender, string);

View File

@ -33,7 +33,7 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
int times = (Integer) this.readArg(1); int times = this.readArg(1);
String string = Txt.repeat(" ", times); String string = Txt.repeat(" ", times);

View File

@ -44,7 +44,7 @@ public class CmdMassiveCoreCmdurl extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
String urlString = (String) this.readArg(); String urlString = this.readArg();
final URL url; final URL url;
try try

View File

@ -33,13 +33,12 @@ public class CmdMassiveCoreHearsound extends MassiveCommand
// -------------------------------------------- // // -------------------------------------------- //
// OVERRIDE // OVERRIDE
// -------------------------------------------- // // -------------------------------------------- //
@SuppressWarnings("unchecked")
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
List<SoundEffect> soundEffects = (List<SoundEffect>) this.readArg(); List<SoundEffect> soundEffects = this.readArg();
// Apply // Apply
SoundEffect.runAll(soundEffects, me); SoundEffect.runAll(soundEffects, me);

View File

@ -42,7 +42,7 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
final String fromAlias = (String) this.readArg(); final String fromAlias = this.readArg();
final Db fromDb = MStore.getDb(fromAlias); final Db fromDb = MStore.getDb(fromAlias);
if (fromDb == null) if (fromDb == null)
{ {
@ -50,7 +50,7 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand
return; return;
} }
final String toAlias = (String) this.readArg(); final String toAlias = this.readArg();
final Db toDb = MStore.getDb(toAlias); final Db toDb = MStore.getDb(toAlias);
if (toDb == null) if (toDb == null)
{ {

View File

@ -41,7 +41,7 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
final String dbAlias = (String) this.readArg(ConfServer.dburi); final String dbAlias = this.readArg(ConfServer.dburi);
final Db db = MStore.getDb(dbAlias); final Db db = MStore.getDb(dbAlias);
if (db == null) if (db == null)
{ {

View File

@ -43,7 +43,7 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand
} }
else else
{ {
Coll<?> coll = (Coll<?>) this.readArg(); Coll<?> coll = this.readArg();
this.performColl(coll); this.performColl(coll);
} }
} }

View File

@ -49,7 +49,7 @@ public class CmdMassiveCoreTest extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
ParticleEffect particleEffect = (ParticleEffect) this.readArg(); ParticleEffect particleEffect = this.readArg();
Location center = me.getEyeLocation().add(0, 0, 0); Location center = me.getEyeLocation().add(0, 0, 0);

View File

@ -7,8 +7,8 @@ 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.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.cmd.ArgSetting;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
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;
@ -24,7 +24,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
this.addAliases("l", "list"); this.addAliases("l", "list");
// Args // 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 // Requirements
this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node)); this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node));
@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
int pageHumanBased = (Integer) this.readArg(1); int pageHumanBased = this.readArg();
// Create Lines // Create Lines
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();

View File

@ -33,7 +33,7 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Aspect aspect = (Aspect) this.readArg(); Aspect aspect = this.readArg();
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

@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Aspect aspect = (Aspect) this.readArg(); Aspect aspect = this.readArg();
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
aspect.setMultiverse(multiverse); aspect.setMultiverse(multiverse);

View File

@ -33,7 +33,7 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
String id = multiverse.getId(); String id = multiverse.getId();

View File

@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
// Args // Args
int pageHumanBased = (Integer) this.readArg(1); int pageHumanBased = this.readArg(1);
// Create Lines // Create Lines
List<String> lines = new ArrayList<String>(); List<String> lines = new ArrayList<String>();

View File

@ -32,7 +32,7 @@ public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String id = (String) this.readArg(); String id = this.readArg();
if (MultiverseColl.get().containsId(id)) if (MultiverseColl.get().containsId(id))
{ {

View File

@ -38,7 +38,7 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
msg(Txt.titleize("Multiverse: "+multiverse.getId())); msg(Txt.titleize("Multiverse: "+multiverse.getId()));

View File

@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String universe = (String) this.readArg(); String universe = this.readArg();
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
if (universe.equals(MassiveCore.DEFAULT)) if (universe.equals(MassiveCore.DEFAULT))
{ {

View File

@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String universe = (String) this.readArg(); String universe = this.readArg();
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
if (universe.equals(MassiveCore.DEFAULT)) if (universe.equals(MassiveCore.DEFAULT))
{ {

View File

@ -34,8 +34,8 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String universe = (String) this.readArg(); String universe = this.readArg();
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = this.readArg();
if (multiverse.containsUniverse(universe)) if (multiverse.containsUniverse(universe))
{ {

View File

@ -35,8 +35,8 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
String worldName = (String) this.readArg(); String worldName = this.readArg();
String universe = (String) this.readArg(); String universe = this.readArg();
Multiverse multiverse = (Multiverse) this.readArg(); Multiverse multiverse = (Multiverse) this.readArg();
if (!multiverse.containsUniverse(universe)) if (!multiverse.containsUniverse(universe))