Making argument index optional and heavy OCD
This commit is contained in:
parent
92ac999c2e
commit
ad06dd854c
@ -491,9 +491,9 @@ public abstract class MCommand
|
||||
return this.args.get(idx);
|
||||
}
|
||||
|
||||
public <T> T arg(int idx, ArgReader<T> ar)
|
||||
public <T> T arg(int idx, ArgReader<T> argReader)
|
||||
{
|
||||
return this.arg(idx, ar, null);
|
||||
return this.arg(idx, argReader, null);
|
||||
}
|
||||
|
||||
public <T> T arg(int idx, ArgReader<T> argReader, T defaultNotSet)
|
||||
@ -504,4 +504,11 @@ public abstract class MCommand
|
||||
if (result.hasErrors()) this.msg(result.getErrors());
|
||||
return result.getResult();
|
||||
}
|
||||
|
||||
public <T> T arg(ArgReader<T> argReader)
|
||||
{
|
||||
ArgResult<T> result = argReader.read(this.sender);
|
||||
if (result.hasErrors()) this.msg(result.getErrors());
|
||||
return result.getResult();
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,19 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public abstract class ARAbstractPrimitive<T> implements ArgReader<T>
|
||||
public abstract class ARAbstractPrimitive<T> extends ArgReaderAbstract<T>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public abstract String typename();
|
||||
public abstract T convert(String arg) throws Exception;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<T> read(String arg, CommandSender sender)
|
||||
{
|
||||
|
@ -6,13 +6,21 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public abstract class ARAbstractSelect<T> implements ArgReader<T>
|
||||
public abstract class ARAbstractSelect<T> extends ArgReaderAbstract<T>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public abstract String typename();
|
||||
public abstract T select(String str, CommandSender sender);
|
||||
public abstract Collection<String> altNames(CommandSender sender);
|
||||
public boolean canList(CommandSender sender) { return true; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<T> read(String arg, CommandSender sender)
|
||||
{
|
||||
|
@ -10,6 +10,17 @@ import com.massivecraft.mcore.usys.AspectColl;
|
||||
|
||||
public class ARAspect extends ARAbstractSelect<Aspect>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARAspect i = new ARAspect();
|
||||
public static ARAspect get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -34,11 +45,4 @@ public class ARAspect extends ARAbstractSelect<Aspect>
|
||||
return AspectColl.i.getIds();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARAspect i = new ARAspect();
|
||||
public static ARAspect get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARBoolean extends ARAbstractPrimitive<Boolean>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARBoolean i = new ARBoolean();
|
||||
public static ARBoolean get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -19,11 +30,4 @@ public class ARBoolean extends ARAbstractPrimitive<Boolean>
|
||||
return false;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARBoolean i = new ARBoolean();
|
||||
public static ARBoolean get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARByte extends ARAbstractPrimitive<Byte>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARByte i = new ARByte();
|
||||
public static ARByte get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARByte extends ARAbstractPrimitive<Byte>
|
||||
return Byte.parseByte(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARByte i = new ARByte();
|
||||
public static ARByte get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ARChatColor extends ARAbstractSelect<ChatColor>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARChatColor i = new ARChatColor();
|
||||
public static ARChatColor get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -62,11 +73,4 @@ public class ARChatColor extends ARAbstractSelect<ChatColor>
|
||||
return str;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARChatColor i = new ARChatColor();
|
||||
public static ARChatColor get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,18 @@ import java.util.Date;
|
||||
|
||||
public class ARDate extends ARAbstractPrimitive<Date>
|
||||
{
|
||||
protected static DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
protected final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDate i = new ARDate();
|
||||
public static ARDate get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
@ -20,11 +31,4 @@ public class ARDate extends ARAbstractPrimitive<Date>
|
||||
return df.parse(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDate i = new ARDate();
|
||||
public static ARDate get() { return i; }
|
||||
|
||||
}
|
@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
|
||||
|
||||
public class ARDifficulty extends ARAbstractSelect<Difficulty>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDifficulty i = new ARDifficulty();
|
||||
public static ARDifficulty get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -48,11 +59,4 @@ public class ARDifficulty extends ARAbstractSelect<Difficulty>
|
||||
return MUtil.list("peaceful", "easy", "normal", "hard");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDifficulty i = new ARDifficulty();
|
||||
public static ARDifficulty get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARDouble extends ARAbstractPrimitive<Double>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDouble i = new ARDouble();
|
||||
public static ARDouble get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARDouble extends ARAbstractPrimitive<Double>
|
||||
return Double.parseDouble(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARDouble i = new ARDouble();
|
||||
public static ARDouble get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
|
||||
|
||||
public class AREnvironment extends ARAbstractSelect<Environment>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static AREnvironment i = new AREnvironment();
|
||||
public static AREnvironment get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -50,11 +61,4 @@ public class AREnvironment extends ARAbstractSelect<Environment>
|
||||
return MUtil.list("normal", "end", "nether");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static AREnvironment i = new AREnvironment();
|
||||
public static AREnvironment get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARFloat extends ARAbstractPrimitive<Float>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARFloat i = new ARFloat();
|
||||
public static ARFloat get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARFloat extends ARAbstractPrimitive<Float>
|
||||
return Float.parseFloat(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARFloat i = new ARFloat();
|
||||
public static ARFloat get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
|
||||
|
||||
public class ARGameMode extends ARAbstractSelect<GameMode>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARGameMode i = new ARGameMode();
|
||||
public static ARGameMode get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -44,11 +55,4 @@ public class ARGameMode extends ARAbstractSelect<GameMode>
|
||||
return MUtil.list("survival", "creative", "adventure");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARGameMode i = new ARGameMode();
|
||||
public static ARGameMode get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARInteger extends ARAbstractPrimitive<Integer>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARInteger i = new ARInteger();
|
||||
public static ARInteger get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARInteger extends ARAbstractPrimitive<Integer>
|
||||
return Integer.parseInt(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARInteger i = new ARInteger();
|
||||
public static ARInteger get() { return i; }
|
||||
|
||||
}
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARLong extends ARAbstractPrimitive<Long>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARLong i = new ARLong();
|
||||
public static ARLong get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARLong extends ARAbstractPrimitive<Long>
|
||||
return Long.parseLong(arg);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARLong i = new ARLong();
|
||||
public static ARLong get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,19 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ARMaterial implements ArgReader<Material>
|
||||
public class ARMaterial extends ArgReaderAbstract<Material>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMaterial i = new ARMaterial();
|
||||
public static ARMaterial get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<Material> read(String arg, CommandSender sender)
|
||||
{
|
||||
@ -17,11 +28,4 @@ public class ARMaterial implements ArgReader<Material>
|
||||
return result;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMaterial i = new ARMaterial();
|
||||
public static ARMaterial get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -5,8 +5,15 @@ import org.bukkit.command.CommandSender;
|
||||
import com.massivecraft.mcore.util.TimeDiffUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ARMillisDiff implements ArgReader<Long>
|
||||
public class ARMillisDiff extends ArgReaderAbstract<Long>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMillisDiff i = new ARMillisDiff();
|
||||
public static ARMillisDiff get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
@ -26,11 +33,4 @@ public class ARMillisDiff implements ArgReader<Long>
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMillisDiff i = new ARMillisDiff();
|
||||
public static ARMillisDiff get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,17 @@ import com.massivecraft.mcore.usys.MultiverseColl;
|
||||
|
||||
public class ARMultiverse extends ARAbstractSelect<Multiverse>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMultiverse i = new ARMultiverse();
|
||||
public static ARMultiverse get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -34,11 +45,4 @@ public class ARMultiverse extends ARAbstractSelect<Multiverse>
|
||||
return MultiverseColl.i.getIds();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMultiverse i = new ARMultiverse();
|
||||
public static ARMultiverse get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ import org.bukkit.command.CommandSender;
|
||||
import com.massivecraft.mcore.mixin.Mixin;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public abstract class ARSenderIdAbstract<T> implements ArgReader<T>
|
||||
public abstract class ARSenderIdAbstract<T> extends ArgReaderAbstract<T>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public final static int MAX_COUNT = 10;
|
||||
|
@ -2,6 +2,17 @@ package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
public class ARString extends ARAbstractPrimitive<String>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARString i = new ARString();
|
||||
public static ARString get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -14,11 +25,4 @@ public class ARString extends ARAbstractPrimitive<String>
|
||||
return arg;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARString i = new ARString();
|
||||
public static ARString get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,26 @@ import org.bukkit.command.CommandSender;
|
||||
import com.massivecraft.mcore.usys.Multiverse;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class ARUniverse implements ArgReader<String>
|
||||
public class ARUniverse extends ArgReaderAbstract<String>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// IMPLEMENTATION
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public ARUniverse(Multiverse multiverse)
|
||||
{
|
||||
this.multiverse = multiverse;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected Multiverse multiverse;
|
||||
public Multiverse multiverse() { return this.multiverse; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
@ -34,19 +50,4 @@ public class ARUniverse implements ArgReader<String>
|
||||
return result;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
protected Multiverse multiverse;
|
||||
public Multiverse multiverse() { return this.multiverse; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public ARUniverse(Multiverse multiverse)
|
||||
{
|
||||
this.multiverse = multiverse;
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,19 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ARWorld implements ArgReader<World>
|
||||
public class ARWorld extends ArgReaderAbstract<World>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorld i = new ARWorld();
|
||||
public static ARWorld get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<World> read(String arg, CommandSender sender)
|
||||
{
|
||||
@ -33,12 +44,4 @@ public class ARWorld implements ArgReader<World>
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorld i = new ARWorld();
|
||||
public static ARWorld get() { return i; }
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ import com.massivecraft.mcore.mixin.Mixin;
|
||||
|
||||
public class ARWorldId extends ARAbstractSelect<String>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorldId i = new ARWorldId();
|
||||
public static ARWorldId get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -50,11 +61,4 @@ public class ARWorldId extends ARAbstractSelect<String>
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorldId i = new ARWorldId();
|
||||
public static ARWorldId get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ import com.massivecraft.mcore.util.MUtil;
|
||||
|
||||
public class ARWorldType extends ARAbstractSelect<WorldType>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorldType i = new ARWorldType();
|
||||
public static ARWorldType get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
@ -60,11 +71,4 @@ public class ARWorldType extends ARAbstractSelect<WorldType>
|
||||
return MUtil.list("normal", "flat", "1.1", "largebiomes");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARWorldType i = new ARWorldType();
|
||||
public static ARWorldType get() { return i; }
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ public class ArgPredictateAnd<T> implements ArgPredictate<T>
|
||||
this.two = two;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean apply(T type, String arg, CommandSender sender)
|
||||
{
|
||||
|
@ -5,4 +5,7 @@ import org.bukkit.command.CommandSender;
|
||||
public interface ArgReader<T>
|
||||
{
|
||||
public ArgResult<T> read(String arg, CommandSender sender);
|
||||
public ArgResult<T> read(CommandSender sender);
|
||||
public ArgResult<T> read(String arg);
|
||||
public ArgResult<T> read();
|
||||
}
|
29
src/com/massivecraft/mcore/cmd/arg/ArgReaderAbstract.java
Normal file
29
src/com/massivecraft/mcore/cmd/arg/ArgReaderAbstract.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.massivecraft.mcore.cmd.arg;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public abstract class ArgReaderAbstract<T> implements ArgReader<T>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<T> read(CommandSender sender)
|
||||
{
|
||||
return this.read(null, sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgResult<T> read(String arg)
|
||||
{
|
||||
return this.read(arg, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgResult<T> read()
|
||||
{
|
||||
return this.read(null, null);
|
||||
}
|
||||
|
||||
}
|
@ -13,10 +13,7 @@ public class ArgResult<T>
|
||||
protected T result = null;
|
||||
public T getResult() { return this.result; }
|
||||
public void setResult(T result) { this.result = result; }
|
||||
public boolean hasResult()
|
||||
{
|
||||
return this.getResult() != null;
|
||||
}
|
||||
public boolean hasResult() { return this.getResult() != null; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELD: ERRORS
|
||||
|
@ -314,6 +314,7 @@ public class MUtil
|
||||
// SIMPLE CONSTRUCTORS
|
||||
// -------------------------------------------- //
|
||||
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> List<T> list(T... items)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ public final class Streams {
|
||||
TypeAdapters.JSON_ELEMENT.write(writer, element);
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static Writer writerForAppendable(Appendable appendable) {
|
||||
return appendable instanceof Writer ? (Writer) appendable : new AppendableWriter(appendable);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ public final class ObjectTypeAdapter extends TypeAdapter<Object> {
|
||||
this.gson = gson;
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override public Object read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
switch (token) {
|
||||
|
Loading…
Reference in New Issue
Block a user