From 9667e27fcbc3d80de9a49543f9b37efd98aa040c Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 21 Oct 2015 19:36:10 +0200 Subject: [PATCH] MassiveCore - Heavy Refactoring and Command improvements --- src/com/massivecraft/massivecore/Lang.java | 15 +- .../MassiveCoreEngineDestination.java | 16 +- .../massivecore/MassiveCoreEngineMain.java | 4 +- .../massivecraft/massivecore/Multiverse.java | 6 +- .../{Predictate.java => Predicate.java} | 2 +- .../massivecore/PredicateAnd.java | 49 + ...stered.java => PredicateIsRegistered.java} | 6 +- ...y.java => PredicateIsntDefaultEntity.java} | 6 +- ...ava => PredicateStartsWithIgnoreCase.java} | 6 +- .../massivecore/PredictateAnd.java | 49 - .../massivecraft/massivecore/SoundEffect.java | 10 +- .../massivecore/cmd/DeprecatedCommand.java | 10 +- .../massivecore/cmd/HelpCommand.java | 22 +- .../massivecore/cmd/MassiveCommand.java | 1160 +++++++++-------- .../cmd/MassiveCoreBukkitCommand.java | 6 +- .../cmd/{ArgSetting.java => Parameter.java} | 80 +- .../{VisibilityMode.java => Visibility.java} | 2 +- .../cmd/massivecore/CmdMassiveCore.java | 18 +- .../cmd/massivecore/CmdMassiveCoreBuffer.java | 12 +- .../massivecore/CmdMassiveCoreBufferAdd.java | 6 +- .../massivecore/CmdMassiveCoreBufferSet.java | 6 +- .../CmdMassiveCoreBufferWhitespace.java | 6 +- .../cmd/massivecore/CmdMassiveCoreCmdurl.java | 6 +- .../massivecore/CmdMassiveCoreHearsound.java | 8 +- .../cmd/massivecore/CmdMassiveCoreStore.java | 10 +- .../CmdMassiveCoreStoreCopydb.java | 8 +- .../CmdMassiveCoreStoreListcolls.java | 6 +- .../massivecore/CmdMassiveCoreStoreStats.java | 6 +- .../cmd/massivecore/CmdMassiveCoreUsys.java | 10 +- .../massivecore/CmdMassiveCoreUsysAspect.java | 8 +- .../CmdMassiveCoreUsysAspectList.java | 6 +- .../CmdMassiveCoreUsysAspectShow.java | 6 +- .../CmdMassiveCoreUsysAspectUse.java | 10 +- .../CmdMassiveCoreUsysMultiverse.java | 10 +- .../CmdMassiveCoreUsysMultiverseDel.java | 6 +- .../CmdMassiveCoreUsysMultiverseList.java | 6 +- .../CmdMassiveCoreUsysMultiverseNew.java | 6 +- .../CmdMassiveCoreUsysMultiverseShow.java | 6 +- .../CmdMassiveCoreUsysUniverse.java | 8 +- .../CmdMassiveCoreUsysUniverseClear.java | 10 +- .../CmdMassiveCoreUsysUniverseDel.java | 10 +- .../CmdMassiveCoreUsysUniverseNew.java | 10 +- .../massivecore/CmdMassiveCoreUsysWorld.java | 12 +- .../massivecraft/massivecore/cmd/req/Req.java | 4 +- .../cmd/{arg/AR.java => type/Type.java} | 6 +- .../TypeAbstract.java} | 8 +- .../TypeAbstractException.java} | 4 +- .../TypeAbstractNumber.java} | 4 +- .../TypeAbstractPrimitive.java} | 4 +- .../TypeAbstractSelect.java} | 4 +- .../cmd/{arg/ARAll.java => type/TypeAll.java} | 50 +- .../ARAllAble.java => type/TypeAllAble.java} | 4 +- .../ARAspect.java => type/TypeAspect.java} | 8 +- .../{arg/ARBiome.java => type/TypeBiome.java} | 8 +- .../ARBoolean.java => type/TypeBoolean.java} | 8 +- .../{arg/ARByte.java => type/TypeByte.java} | 8 +- .../TypeChatColor.java} | 8 +- .../{arg/ARColl.java => type/TypeColl.java} | 8 +- .../TypeCollection.java} | 8 +- .../TypeCombined.java} | 22 +- .../{arg/ARDate.java => type/TypeDate.java} | 8 +- .../TypeDestination.java} | 8 +- .../TypeDifficulty.java} | 8 +- .../ARDouble.java => type/TypeDouble.java} | 8 +- .../TypeEntityType.java} | 8 +- .../{arg/AREnum.java => type/TypeEnum.java} | 10 +- .../TypeEnvironment.java} | 8 +- .../{arg/ARFloat.java => type/TypeFloat.java} | 8 +- .../TypeGameMode.java} | 8 +- .../ARInteger.java => type/TypeInteger.java} | 8 +- .../{arg/ARList.java => type/TypeList.java} | 20 +- .../{arg/ARLong.java => type/TypeLong.java} | 8 +- .../TypeMaterial.java} | 8 +- .../TypeMillisDiff.java} | 8 +- .../TypeMultiverse.java} | 8 +- .../TypeNullable.java} | 36 +- .../cmd/{arg/ARPS.java => type/TypePS.java} | 58 +- .../TypePermission.java} | 8 +- .../ARPlayer.java => type/TypePlayer.java} | 10 +- .../TypePotionEffectType.java} | 8 +- .../TypePotionEffectWrap.java} | 22 +- .../ARSender.java => type/TypeSender.java} | 10 +- .../TypeSenderEntity.java} | 16 +- .../TypeSenderId.java} | 20 +- .../TypeSenderIdAbstract.java} | 10 +- .../cmd/{arg/ARSet.java => type/TypeSet.java} | 24 +- .../{arg/ARSound.java => type/TypeSound.java} | 8 +- .../TypeSoundEffect.java} | 10 +- .../ARString.java => type/TypeString.java} | 8 +- .../TypeStringCommand.java} | 8 +- .../TypeUniverse.java} | 12 +- .../{arg/ARWorld.java => type/TypeWorld.java} | 12 +- .../ARWorldId.java => type/TypeWorldId.java} | 8 +- .../TypeWorldType.java} | 8 +- .../ARWrapper.java => type/TypeWrapper.java} | 14 +- .../massivecore/mixin/MessageMixin.java | 14 +- .../mixin/MessageMixinAbstract.java | 24 +- .../mixin/MessageMixinDefault.java | 8 +- .../massivecraft/massivecore/mixin/Mixin.java | 26 +- .../massivecraft/massivecore/mson/Mson.java | 8 +- .../massivecore/store/CollAbstract.java | 26 +- .../massivecore/store/CollInterface.java | 26 +- .../massivecore/store/SenderColl.java | 30 +- .../massivecraft/massivecore/util/MUtil.java | 14 +- .../massivecraft/massivecore/util/Txt.java | 14 +- 105 files changed, 1269 insertions(+), 1196 deletions(-) rename src/com/massivecraft/massivecore/{Predictate.java => Predicate.java} (66%) create mode 100644 src/com/massivecraft/massivecore/PredicateAnd.java rename src/com/massivecraft/massivecore/{PredictateIsRegistered.java => PredicateIsRegistered.java} (64%) rename src/com/massivecraft/massivecore/{PredictateIsntDefaultEntity.java => PredicateIsntDefaultEntity.java} (64%) rename src/com/massivecraft/massivecore/{PredictateStartsWithIgnoreCase.java => PredicateStartsWithIgnoreCase.java} (80%) delete mode 100644 src/com/massivecraft/massivecore/PredictateAnd.java rename src/com/massivecraft/massivecore/cmd/{ArgSetting.java => Parameter.java} (60%) rename src/com/massivecraft/massivecore/cmd/{VisibilityMode.java => Visibility.java} (91%) rename src/com/massivecraft/massivecore/cmd/{arg/AR.java => type/Type.java} (88%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAbstract.java => type/TypeAbstract.java} (97%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAbstractException.java => type/TypeAbstractException.java} (89%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAbstractNumber.java => type/TypeAbstractNumber.java} (80%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAbstractPrimitive.java => type/TypeAbstractPrimitive.java} (72%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAbstractSelect.java => type/TypeAbstractSelect.java} (93%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAll.java => type/TypeAll.java} (51%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAllAble.java => type/TypeAllAble.java} (57%) rename src/com/massivecraft/massivecore/cmd/{arg/ARAspect.java => type/TypeAspect.java} (79%) rename src/com/massivecraft/massivecore/cmd/{arg/ARBiome.java => type/TypeBiome.java} (85%) rename src/com/massivecraft/massivecore/cmd/{arg/ARBoolean.java => type/TypeBoolean.java} (85%) rename src/com/massivecraft/massivecore/cmd/{arg/ARByte.java => type/TypeByte.java} (69%) rename src/com/massivecraft/massivecore/cmd/{arg/ARChatColor.java => type/TypeChatColor.java} (83%) rename src/com/massivecraft/massivecore/cmd/{arg/ARColl.java => type/TypeColl.java} (75%) rename src/com/massivecraft/massivecore/cmd/{arg/ARCollection.java => type/TypeCollection.java} (75%) rename src/com/massivecraft/massivecore/cmd/{arg/ARCombined.java => type/TypeCombined.java} (69%) rename src/com/massivecraft/massivecore/cmd/{arg/ARDate.java => type/TypeDate.java} (80%) rename src/com/massivecraft/massivecore/cmd/{arg/ARDestination.java => type/TypeDestination.java} (86%) rename src/com/massivecraft/massivecore/cmd/{arg/ARDifficulty.java => type/TypeDifficulty.java} (81%) rename src/com/massivecraft/massivecore/cmd/{arg/ARDouble.java => type/TypeDouble.java} (68%) rename src/com/massivecraft/massivecore/cmd/{arg/AREntityType.java => type/TypeEntityType.java} (84%) rename src/com/massivecraft/massivecore/cmd/{arg/AREnum.java => type/TypeEnum.java} (87%) rename src/com/massivecraft/massivecore/cmd/{arg/AREnvironment.java => type/TypeEnvironment.java} (84%) rename src/com/massivecraft/massivecore/cmd/{arg/ARFloat.java => type/TypeFloat.java} (68%) rename src/com/massivecraft/massivecore/cmd/{arg/ARGameMode.java => type/TypeGameMode.java} (84%) rename src/com/massivecraft/massivecore/cmd/{arg/ARInteger.java => type/TypeInteger.java} (67%) rename src/com/massivecraft/massivecore/cmd/{arg/ARList.java => type/TypeList.java} (63%) rename src/com/massivecraft/massivecore/cmd/{arg/ARLong.java => type/TypeLong.java} (68%) rename src/com/massivecraft/massivecore/cmd/{arg/ARMaterial.java => type/TypeMaterial.java} (81%) rename src/com/massivecraft/massivecore/cmd/{arg/ARMillisDiff.java => type/TypeMillisDiff.java} (73%) rename src/com/massivecraft/massivecore/cmd/{arg/ARMultiverse.java => type/TypeMultiverse.java} (78%) rename src/com/massivecraft/massivecore/cmd/{arg/ARNullable.java => type/TypeNullable.java} (64%) rename src/com/massivecraft/massivecore/cmd/{arg/ARPS.java => type/TypePS.java} (73%) rename src/com/massivecraft/massivecore/cmd/{arg/ARPermission.java => type/TypePermission.java} (80%) rename src/com/massivecraft/massivecore/cmd/{arg/ARPlayer.java => type/TypePlayer.java} (73%) rename src/com/massivecraft/massivecore/cmd/{arg/ARPotionEffectType.java => type/TypePotionEffectType.java} (87%) rename src/com/massivecraft/massivecore/cmd/{arg/ARPotionEffectWrap.java => type/TypePotionEffectWrap.java} (77%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSender.java => type/TypeSender.java} (73%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSenderEntity.java => type/TypeSenderEntity.java} (56%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSenderId.java => type/TypeSenderId.java} (50%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSenderIdAbstract.java => type/TypeSenderIdAbstract.java} (90%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSet.java => type/TypeSet.java} (66%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSound.java => type/TypeSound.java} (86%) rename src/com/massivecraft/massivecore/cmd/{arg/ARSoundEffect.java => type/TypeSoundEffect.java} (71%) rename src/com/massivecraft/massivecore/cmd/{arg/ARString.java => type/TypeString.java} (73%) rename src/com/massivecraft/massivecore/cmd/{arg/ARStringCommand.java => type/TypeStringCommand.java} (94%) rename src/com/massivecraft/massivecore/cmd/{arg/ARUniverse.java => type/TypeUniverse.java} (78%) rename src/com/massivecraft/massivecore/cmd/{arg/ARWorld.java => type/TypeWorld.java} (70%) rename src/com/massivecraft/massivecore/cmd/{arg/ARWorldId.java => type/TypeWorldId.java} (84%) rename src/com/massivecraft/massivecore/cmd/{arg/ARWorldType.java => type/TypeWorldType.java} (86%) rename src/com/massivecraft/massivecore/cmd/{arg/ARWrapper.java => type/TypeWrapper.java} (61%) diff --git a/src/com/massivecraft/massivecore/Lang.java b/src/com/massivecraft/massivecore/Lang.java index fd824bf7..69bc511d 100644 --- a/src/com/massivecraft/massivecore/Lang.java +++ b/src/com/massivecraft/massivecore/Lang.java @@ -13,12 +13,15 @@ public class Lang public static final String COMMAND_SENDER_MUST_BE_PLAYER = "This command can only be used by ingame players."; public static final String COMMAND_SENDER_MUSNT_BE_PLAYER = "This command can not be used by ingame players."; public static final String COMMAND_TITLES_MUST_BE_AVAILABLE = "This command requires the Minecraft 1.8 titles."; - public static final String COMMAND_TOO_FEW_ARGS = "Not enough command input. You should use it like this:"; - public static final String COMMAND_TOO_MANY_ARGS = "Too much command input %s."; - public static final String COMMAND_TOO_MANY_ARGS2 = "You should use the command like this:"; + public static final String COMMAND_TOO_FEW_ARGUMENTS = "Not enough command input. You should use it like this:"; + public static final String COMMAND_TOO_MANY_ARGUMENTS = "Too much command input %s."; + public static final String COMMAND_TOO_MANY_ARGUMENTS2 = "You should use the command like this:"; + public static final Mson COMMAND_REPLACEMENT = mson("REPLACEMENT"); - public static final Mson COMMAND_NO_SUCH_SUB = mson("Couldn't find the command ", COMMAND_REPLACEMENT).color(ChatColor.YELLOW); - public static final Mson COMMAND_SUGGEST_SUB = mson("Maybe you could try ", COMMAND_REPLACEMENT).color(ChatColor.YELLOW); - public static final Mson COMMAND_GET_HELP = mson("Use ", COMMAND_REPLACEMENT, " to see commands.").color(ChatColor.YELLOW); + + public static final Mson COMMAND_CHILD_AMBIGUOUS = mson("The sub command ", COMMAND_REPLACEMENT, " is ambiguous.").color(ChatColor.YELLOW); + public static final Mson COMMAND_CHILD_NONE = mson("The sub command ", COMMAND_REPLACEMENT, " couldn't be found.").color(ChatColor.YELLOW); + public static final Mson COMMAND_CHILD_HELP = mson("Use ", COMMAND_REPLACEMENT, " to see all commands.").color(ChatColor.YELLOW); + public static final String COMMAND_TOO_MANY_TAB_SUGGESTIONS = "%d tab completions available. Be more specific and try again."; } diff --git a/src/com/massivecraft/massivecore/MassiveCoreEngineDestination.java b/src/com/massivecraft/massivecore/MassiveCoreEngineDestination.java index ab024b85..543c1fb0 100644 --- a/src/com/massivecraft/massivecore/MassiveCoreEngineDestination.java +++ b/src/com/massivecraft/massivecore/MassiveCoreEngineDestination.java @@ -11,9 +11,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.plugin.Plugin; -import com.massivecraft.massivecore.cmd.arg.ARPS; -import com.massivecraft.massivecore.cmd.arg.ARSenderId; -import com.massivecraft.massivecore.cmd.arg.ARWorldId; +import com.massivecraft.massivecore.cmd.type.TypePS; +import com.massivecraft.massivecore.cmd.type.TypeSenderId; +import com.massivecraft.massivecore.cmd.type.TypeWorldId; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.event.EventMassiveCoreDestination; import com.massivecraft.massivecore.ps.PS; @@ -56,7 +56,7 @@ public class MassiveCoreEngineDestination extends EngineAbstract { try { - PS ps = ARPS.get().read(event.getArg(), event.getSender()); + PS ps = TypePS.get().read(event.getArg(), event.getSender()); Destination destination = new DestinationSimple(ps); event.setDestination(destination); } @@ -144,7 +144,7 @@ public class MassiveCoreEngineDestination extends EngineAbstract String worldId; if (rest != null) { - worldId = ARWorldId.get().read(rest, sender); + worldId = TypeWorldId.get().read(rest, sender); } else { @@ -158,7 +158,7 @@ public class MassiveCoreEngineDestination extends EngineAbstract // World Implicit try { - String worldId = ARWorldId.get().read(arg, sender); + String worldId = TypeWorldId.get().read(arg, sender); return new DestinationWorld(worldId); } catch (Exception e) @@ -172,7 +172,7 @@ public class MassiveCoreEngineDestination extends EngineAbstract String playerId; if (rest != null) { - playerId = ARSenderId.get().read(rest, sender); + playerId = TypeSenderId.get().read(rest, sender); } else { @@ -185,7 +185,7 @@ public class MassiveCoreEngineDestination extends EngineAbstract // Player Implicit try { - String playerId = ARSenderId.get().read(arg, sender); + String playerId = TypeSenderId.get().read(arg, sender); return new DestinationPlayer(playerId); } catch (Exception e) diff --git a/src/com/massivecraft/massivecore/MassiveCoreEngineMain.java b/src/com/massivecraft/massivecore/MassiveCoreEngineMain.java index 965a2f0d..8a9c379e 100644 --- a/src/com/massivecraft/massivecore/MassiveCoreEngineMain.java +++ b/src/com/massivecraft/massivecore/MassiveCoreEngineMain.java @@ -143,7 +143,7 @@ public class MassiveCoreEngineMain extends EngineAbstract if (MUtil.isntPlayer(watcher)) return; // Get the lowercased token predicate - Predictate predictate = PredictateStartsWithIgnoreCase.get(event.getLastToken()); + Predicate predicate = PredicateStartsWithIgnoreCase.get(event.getLastToken()); // Create a case insensitive set to check for already added stuff Set current = new TreeSet(String.CASE_INSENSITIVE_ORDER); @@ -153,7 +153,7 @@ public class MassiveCoreEngineMain extends EngineAbstract // TODO: Should this only be players? Would a player actually want to tab-complete @console? for (String senderName : IdUtil.getNames(SenderPresence.ONLINE, SenderType.ANY)) { - if (!predictate.apply(senderName)) continue; + if (!predicate.apply(senderName)) continue; if (current.contains(senderName)) continue; if (!Mixin.canSee(watcher, senderName)) continue; diff --git a/src/com/massivecraft/massivecore/Multiverse.java b/src/com/massivecraft/massivecore/Multiverse.java index b0a9c268..1fcd6c61 100644 --- a/src/com/massivecraft/massivecore/Multiverse.java +++ b/src/com/massivecraft/massivecore/Multiverse.java @@ -8,7 +8,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; -import com.massivecraft.massivecore.cmd.arg.ARUniverse; +import com.massivecraft.massivecore.cmd.type.TypeUniverse; import com.massivecraft.massivecore.store.Entity; import com.massivecraft.massivecore.util.MUtil; @@ -170,9 +170,9 @@ public class Multiverse extends Entity // ARG READERS // -------------------------------------------- // - public ARUniverse argReaderUniverse() + public TypeUniverse typeUniverse() { - return new ARUniverse(this); + return new TypeUniverse(this); } } diff --git a/src/com/massivecraft/massivecore/Predictate.java b/src/com/massivecraft/massivecore/Predicate.java similarity index 66% rename from src/com/massivecraft/massivecore/Predictate.java rename to src/com/massivecraft/massivecore/Predicate.java index c8378f60..b3909f3f 100644 --- a/src/com/massivecraft/massivecore/Predictate.java +++ b/src/com/massivecraft/massivecore/Predicate.java @@ -1,6 +1,6 @@ package com.massivecraft.massivecore; -public interface Predictate +public interface Predicate { public boolean apply(T type); } diff --git a/src/com/massivecraft/massivecore/PredicateAnd.java b/src/com/massivecraft/massivecore/PredicateAnd.java new file mode 100644 index 00000000..8e2f70a8 --- /dev/null +++ b/src/com/massivecraft/massivecore/PredicateAnd.java @@ -0,0 +1,49 @@ +package com.massivecraft.massivecore; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class PredicateAnd implements Predicate +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + @SafeVarargs + public static PredicateAnd get(Predicate... predicates) { return new PredicateAnd(predicates); } + @SafeVarargs + public PredicateAnd(Predicate... predicates) + { + this(Arrays.asList(predicates)); + } + + public static PredicateAnd get(Collection> predicates) { return new PredicateAnd(predicates); } + public PredicateAnd(Collection> predicates) + { + this.predicates = Collections.unmodifiableList(new ArrayList>(predicates)); + } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + private final List> predicates; + public List> getPredicates() { return this.predicates; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public boolean apply(T type) + { + for (Predicate predicate : this.getPredicates()) + { + if (!predicate.apply(type)) return false; + } + return true; + } + +} diff --git a/src/com/massivecraft/massivecore/PredictateIsRegistered.java b/src/com/massivecraft/massivecore/PredicateIsRegistered.java similarity index 64% rename from src/com/massivecraft/massivecore/PredictateIsRegistered.java rename to src/com/massivecraft/massivecore/PredicateIsRegistered.java index 3a1bf168..200346a6 100644 --- a/src/com/massivecraft/massivecore/PredictateIsRegistered.java +++ b/src/com/massivecraft/massivecore/PredicateIsRegistered.java @@ -1,13 +1,13 @@ package com.massivecraft.massivecore; -public class PredictateIsRegistered implements Predictate +public class PredicateIsRegistered implements Predicate { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static PredictateIsRegistered i = new PredictateIsRegistered(); - public static PredictateIsRegistered get() { return i; } + private static PredicateIsRegistered i = new PredicateIsRegistered(); + public static PredicateIsRegistered get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/PredictateIsntDefaultEntity.java b/src/com/massivecraft/massivecore/PredicateIsntDefaultEntity.java similarity index 64% rename from src/com/massivecraft/massivecore/PredictateIsntDefaultEntity.java rename to src/com/massivecraft/massivecore/PredicateIsntDefaultEntity.java index 05c94ee5..cec446db 100644 --- a/src/com/massivecraft/massivecore/PredictateIsntDefaultEntity.java +++ b/src/com/massivecraft/massivecore/PredicateIsntDefaultEntity.java @@ -2,14 +2,14 @@ package com.massivecraft.massivecore; import com.massivecraft.massivecore.store.Entity; -public class PredictateIsntDefaultEntity implements Predictate> +public class PredicateIsntDefaultEntity implements Predicate> { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static PredictateIsntDefaultEntity i = new PredictateIsntDefaultEntity(); - public static PredictateIsntDefaultEntity get() { return i; } + private static PredicateIsntDefaultEntity i = new PredicateIsntDefaultEntity(); + public static PredicateIsntDefaultEntity get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/PredictateStartsWithIgnoreCase.java b/src/com/massivecraft/massivecore/PredicateStartsWithIgnoreCase.java similarity index 80% rename from src/com/massivecraft/massivecore/PredictateStartsWithIgnoreCase.java rename to src/com/massivecraft/massivecore/PredicateStartsWithIgnoreCase.java index 96d3435d..467b0683 100644 --- a/src/com/massivecraft/massivecore/PredictateStartsWithIgnoreCase.java +++ b/src/com/massivecraft/massivecore/PredicateStartsWithIgnoreCase.java @@ -1,7 +1,7 @@ package com.massivecraft.massivecore; // Inspired by: String#regionMatches(ignoreCase, toffset, other, ooffset, len) -public class PredictateStartsWithIgnoreCase implements Predictate +public class PredicateStartsWithIgnoreCase implements Predicate { // -------------------------------------------- // // FIELDS @@ -14,8 +14,8 @@ public class PredictateStartsWithIgnoreCase implements Predictate // CONSTRUCT // -------------------------------------------- // - public static PredictateStartsWithIgnoreCase get(String prefix) { return new PredictateStartsWithIgnoreCase(prefix); } - public PredictateStartsWithIgnoreCase(String prefix) + public static PredicateStartsWithIgnoreCase get(String prefix) { return new PredicateStartsWithIgnoreCase(prefix); } + public PredicateStartsWithIgnoreCase(String prefix) { if (prefix == null) throw new NullPointerException("prefix"); this.prefixLower = prefix.toLowerCase(); diff --git a/src/com/massivecraft/massivecore/PredictateAnd.java b/src/com/massivecraft/massivecore/PredictateAnd.java deleted file mode 100644 index 2940109a..00000000 --- a/src/com/massivecraft/massivecore/PredictateAnd.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.massivecraft.massivecore; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public class PredictateAnd implements Predictate -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - @SafeVarargs - public static PredictateAnd get(Predictate... predictates) { return new PredictateAnd(predictates); } - @SafeVarargs - public PredictateAnd(Predictate... predictates) - { - this(Arrays.asList(predictates)); - } - - public static PredictateAnd get(Collection> predictates) { return new PredictateAnd(predictates); } - public PredictateAnd(Collection> predictates) - { - this.predictates = Collections.unmodifiableList(new ArrayList>(predictates)); - } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final List> predictates; - public List> getPredictates() { return this.predictates; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public boolean apply(T type) - { - for (Predictate predictate : this.getPredictates()) - { - if (!predictate.apply(type)) return false; - } - return true; - } - -} diff --git a/src/com/massivecraft/massivecore/SoundEffect.java b/src/com/massivecraft/massivecore/SoundEffect.java index 428926d5..833dae6c 100644 --- a/src/com/massivecraft/massivecore/SoundEffect.java +++ b/src/com/massivecraft/massivecore/SoundEffect.java @@ -7,8 +7,8 @@ import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; -import com.massivecraft.massivecore.cmd.arg.ARFloat; -import com.massivecraft.massivecore.cmd.arg.ARSound; +import com.massivecraft.massivecore.cmd.type.TypeFloat; +import com.massivecraft.massivecore.cmd.type.TypeSound; public final class SoundEffect implements Cloneable, Serializable { @@ -67,18 +67,18 @@ public final class SoundEffect implements Cloneable, Serializable soundString = soundString.trim(); String[] parts = soundString.split("[^a-zA-Z0-9_.]+"); - Sound sound = ARSound.get().read(parts[0]); + Sound sound = TypeSound.get().read(parts[0]); float volume = 1.0f; if (parts.length >= 2) { - volume = ARFloat.get().read(parts[1]); + volume = TypeFloat.get().read(parts[1]); } float pitch = 1.0f; if (parts.length >= 3) { - pitch = ARFloat.get().read(parts[2]); + pitch = TypeFloat.get().read(parts[2]); } return SoundEffect.valueOf(sound, volume, pitch); diff --git a/src/com/massivecraft/massivecore/cmd/DeprecatedCommand.java b/src/com/massivecraft/massivecore/cmd/DeprecatedCommand.java index f77b9c28..136c60aa 100644 --- a/src/com/massivecraft/massivecore/cmd/DeprecatedCommand.java +++ b/src/com/massivecraft/massivecore/cmd/DeprecatedCommand.java @@ -1,7 +1,7 @@ package com.massivecraft.massivecore.cmd; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.VisibilityMode; +import com.massivecraft.massivecore.cmd.Visibility; public class DeprecatedCommand extends MassiveCommand @@ -24,11 +24,11 @@ public class DeprecatedCommand extends MassiveCommand // Aliases this.setAliases(aliases); - // Args - this.setGivingErrorOnTooManyArgs(false); + // Parameters + this.setOverflowSensitive(false); // Visibility - this.setVisibilityMode(VisibilityMode.INVISIBLE); + this.setVisibility(Visibility.INVISIBLE); } // -------------------------------------------- // @@ -39,7 +39,7 @@ public class DeprecatedCommand extends MassiveCommand public void perform() { msg("Use this new command instead:"); - message(target.getUseageTemplate(true)); + message(target.getTemplate(true)); } } diff --git a/src/com/massivecraft/massivecore/cmd/HelpCommand.java b/src/com/massivecraft/massivecore/cmd/HelpCommand.java index 0aea8800..d9ebd035 100644 --- a/src/com/massivecraft/massivecore/cmd/HelpCommand.java +++ b/src/com/massivecraft/massivecore/cmd/HelpCommand.java @@ -23,8 +23,8 @@ public class HelpCommand extends MassiveCommand // Aliases this.addAliases("?", "h", "help"); - // Args - this.addArg(ArgSetting.getPage()); + // Parameters + this.addParameter(Parameter.getPage()); // Other this.setDesc(""); @@ -41,34 +41,34 @@ public class HelpCommand extends MassiveCommand int page = this.readArg(); // Get parent command - if ( ! this.hasParentCommand()) return; - MassiveCommand parentCommand = this.getParentCommand(); + if ( ! this.hasParent()) return; + MassiveCommand parent = this.getParent(); // Create Lines List lines = new ArrayList(); - for (String helpline : parentCommand.getHelp()) + for (String helpline : parent.getHelp()) { lines.add(Mson.parse("# " + helpline)); } - for (MassiveCommand subCommand : parentCommand.getSubCommands()) + for (MassiveCommand child : parent.getChildren()) { - if ( ! subCommand.isVisibleTo(sender)) continue; - lines.add(subCommand.getUseageTemplate(this.getCommandChain(), true, true, sender)); + if ( ! child.isVisibleTo(sender)) continue; + lines.add(child.getTemplate(this.getChain(), true, true, sender)); } // Send Lines - message(Txt.getPage(lines, page, "Help for command \"" + parentCommand.getAliases().get(0) + "\"", this)); + message(Txt.getPage(lines, page, "Help for command \"" + parent.getAliases().get(0) + "\"", this)); } @Override public boolean isVisibleTo(CommandSender sender) { boolean visible = super.isVisibleTo(sender); - if ( ! (this.hasParentCommand() && visible)) return visible; + if ( ! (this.hasParent() && visible)) return visible; int pageHeight = (sender instanceof Player) ? Txt.PAGEHEIGHT_PLAYER : Txt.PAGEHEIGHT_CONSOLE; - int size = this.getParentCommand().getSubCommands().size(); + int size = this.getParent().getChildren().size(); if (size <= pageHeight) { diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java index 36e418a5..8d47d13c 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -19,10 +19,12 @@ import org.bukkit.plugin.Plugin; import com.massivecraft.massivecore.Lang; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.AR; +import com.massivecraft.massivecore.PredicateStartsWithIgnoreCase; import com.massivecraft.massivecore.cmd.req.Req; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.Type; import com.massivecraft.massivecore.collections.MassiveList; +import com.massivecraft.massivecore.collections.MassiveMap; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.PermUtil; @@ -46,18 +48,10 @@ public class MassiveCommand // This task unregisters /all/ registered MCommands and then register them all again. // When registering again we use the fresh and current aliases. - private static transient Map registry = new LinkedHashMap(); - - public static Set getRegisteredCommands() - { - return registry.keySet(); - } - - public static Map getRegistry() - { - return registry; - } - + // STATIC + private static final transient Map registry = new LinkedHashMap(); + public static Map getRegistry() { return registry; } + public static Set getRegisteredCommands() { return registry.keySet(); } public static void unregister(Plugin plugin) { Iterator> iter = registry.entrySet().iterator(); @@ -71,101 +65,264 @@ public class MassiveCommand } } - public Plugin register(Plugin plugin) - { - return registry.put(this, plugin); - } + // INSTANCE + public Plugin register(Plugin plugin) { return registry.put(this, plugin); } + public void unregister() { registry.remove(this); } + public boolean isRegistered() { return registry.containsKey(this); } + public Plugin getRegisteredPlugin() { return registry.get(this); } - public void unregister() - { - registry.remove(this); - } + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + // Due to the large amount of methods in this class we place the fields alone here in the beginning. + // Field access and other similar utility methods have their special sections below. - public boolean isRegistered() - { - return registry.containsKey(this); - } + // === CHILDREN === - public Plugin getRegisteredPlugin() + // The children. Previously called subcommands. + protected List children = new ArrayList(); + + // === ALIASES === + + // The different names this commands will react to + protected List aliases = new ArrayList(); + + // === PARAMETERS === + + // The command parameters. + protected List> parameters = new ArrayList>(); + + // === PREPROCESS === + + // Should the arguments be parsed considering quotes and backslashes and such? + protected boolean tokenizing = true; + + // Are "smart" quotes replaced with normal characters? + protected boolean unsmart = true; + + // === PUZZLER === + + // Should an error be thrown if "too many" arguments are provided? + protected boolean overflowSensitive = true; + + // Should the last parameter concatenate all surplus arguments? + protected boolean concatenating = false; + + // Should we try to automatically swap the arguments around if they were typed in invalid order? + protected boolean swapping = true; + + // === REQUIREMENTS === + + // All these requirements must be met for the command to be executable; + protected List requirements = new ArrayList(); + + // === HELP === + + // A short description of what the command does. Such as "eat hamburgers" or "do admin stuff". + protected String desc = null; + + // A specific permission node to use for description if desc is null. + protected String descPermission = null; + + // Free text displayed at the top of the help command. + protected List help = new ArrayList(); + + // The visibility of this command in help command. + protected Visibility visibility = Visibility.VISIBLE; + + // === EXECUTION === + + // The raw string arguments passed upon execution. An empty list if there are none. + protected List args = new ArrayList(); + + // The chain of commands used to reach this command during execution. + protected List chain = new ArrayList(); + + // The index of the next arg to read. + public int nextArg = 0; + + // ... + public CommandSender sender = null; + + // ... + public Player me = null; + + // ... + public boolean senderIsConsole = false; + + // -------------------------------------------- // + // CHILDREN + // -------------------------------------------- // + + public List getChildren() { return this.children; } + public void setChildren(List children) { this.children = children; } + + public boolean isParent() { - return registry.get(this); + return this.getChildren().size() > 0; } // -------------------------------------------- // - // COMMAND BEHAVIOR + // CHILDREN > GET // -------------------------------------------- // - - // FIELD: subCommands - // The sub-commands to this command - protected List subCommands; - public List getSubCommands() { return this.subCommands; } - public void setSubCommands(List subCommands) { this.subCommands = subCommands; } - - public boolean isParentCommand() { return this.getSubCommands().size() > 0; } - - public MassiveCommand getSubCommand(String alias) + + // The full version of the child matcher method. + // Returns a map from alias to command. + // + // token - the full alias or an alias prefix. + // levenshtein - should we use levenshtein instead of starts with? + // prioritizeExact - return single entry map on full match. + // + // An empty map means no child was found. + // A single entry map means we found an unambiguous match. + // A larger map means the token was ambiguous. + public Map getChildMatches(String token, boolean levenshtein, CommandSender onlyRelevantToSender) { - for (MassiveCommand subCommand: this.getSubCommands()) + // Create Ret + Map ret = new MassiveMap(); + + // Prepare + token = token.toLowerCase(); + PredicateStartsWithIgnoreCase predicate = PredicateStartsWithIgnoreCase.get(token); + + // Fill Ret + for (MassiveCommand child : this.getChildren()) { - for (String subAlias : subCommand.getAliases()) + for (String alias : child.getAliases()) { - if (alias.equalsIgnoreCase(subAlias)) + // If this alias has not already been reserved ... + if (ret.containsKey(alias)) continue; + + // ... consider exact priority ... + if (alias.equalsIgnoreCase(token)) { - return subCommand; + return new MassiveMap(alias, child); } + + // ... matches ... + if (levenshtein) + { + // ... is levenshteinish ... + if ( ! this.isLevenshteinClose(token, alias)) continue; + } + else + { + // ... the alias startsWithIgnoreCase the token ... + if ( ! predicate.apply(alias)) continue; + } + + // ... and put in ret. + ret.put(alias, child); } } - return null; - } - - public void addSubCommand(MassiveCommand subCommand) - { - this.addSubCommand(subCommand, this.subCommands.size()); - } - - public void addSubCommand(MassiveCommand subCommand, int index) - { - if (this.subCommands.isEmpty() && ! (subCommand instanceof HelpCommand)) + + // Only Relevant + if (onlyRelevantToSender != null) { - this.subCommands.add(0, HelpCommand.get()); + Iterator> iter = ret.entrySet().iterator(); + while (iter.hasNext()) + { + Entry entry = iter.next(); + if (entry.getValue().isRelevant(onlyRelevantToSender)) continue; + iter.remove(); + } + } + + // Return Ret + return ret; + } + + // A simplified version returning null on ambiguity and nothing found. + public MassiveCommand getChild(String token) + { + Map childMatches = this.getChildMatches(token, false, null); + + if (childMatches.isEmpty()) return null; + if (childMatches.size() > 1) return null; + + return childMatches.entrySet().iterator().next().getValue(); + } + + protected boolean isRelevant(CommandSender sender) + { + if (sender == null) return true; + + if ( ! this.isVisibleTo(sender)) return false; + if ( ! this.isRequirementsMet(sender, false)) return false; + + return true; + } + + public boolean isLevenshteinClose(String argument, String alias) + { + int levenshteinDistanceMax = this.getLevenshteinMax(argument); + int distance = StringUtils.getLevenshteinDistance(argument, alias); + return distance <= levenshteinDistanceMax; + } + + public int getLevenshteinMax(String argument) + { + if (argument == null) return 0; + if (argument.length() <= 1) return 0; // When dealing with 1 character aliases, there is way too many options. So we don't suggest. + if (argument.length() <= 4) return 1; // When dealing with low length aliases, there too many options. So we won't suggest much + if (argument.length() <= 7) return 2; // 2 is default. + + return 3; // If it were 8 characters or more, we end up here. Because many characters allow for more typos. + } + + // -------------------------------------------- // + // CHILDREN > ADD & REMOVE + // -------------------------------------------- // + + public void addChild(MassiveCommand child) + { + this.addChild(child, this.children.size()); + } + + public void addChild(MassiveCommand child, int index) + { + if (this.children.isEmpty() && ! (child instanceof HelpCommand)) + { + this.children.add(0, HelpCommand.get()); index++; } - subCommand.addToCommandChain(this); - this.subCommands.add(index, subCommand); + child.addToChain(this); + this.children.add(index, child); } - public void addSubCommandAfter(MassiveCommand subCommand, MassiveCommand after) + public void addChildAfter(MassiveCommand child, MassiveCommand after) { - int index = this.subCommands.indexOf(after); + int index = this.children.indexOf(after); if (index == -1) { - index = this.subCommands.size(); + index = this.children.size(); } else { index++; } - this.addSubCommand(subCommand, index); + this.addChild(child, index); } - public int removeSubCommand(MassiveCommand subCommand) + public int removeChild(MassiveCommand child) { - int index = this.subCommands.indexOf(subCommand); - this.subCommands.remove(index); + int index = this.children.indexOf(child); + this.children.remove(index); return index; } - public int replaceSubCommand(MassiveCommand subCommand, MassiveCommand replaced) + public int replaceChild(MassiveCommand child, MassiveCommand replaced) { - int index = this.removeSubCommand(replaced); + int index = this.removeChild(replaced); if (index < 0) return index; - this.addSubCommand(subCommand, index); + this.addChild(child, index); return index; } - // FIELD: aliases - // The different names this commands will react to - protected List aliases; + // -------------------------------------------- // + // ALIASES + // -------------------------------------------- // + public List getAliases() { return this.aliases; } public void setAliases(Collection aliases) { this.aliases = new MassiveList(aliases); } @@ -174,215 +331,335 @@ public class MassiveCommand public void addAliases(Collection aliases) { this.aliases.addAll(aliases); } public void addAliases(String... aliases) { this.addAliases(Arrays.asList(aliases)); } - // FIELD argSettings - // Settings for all args. - protected List> argSettings; - public List> getArgSettings() { return this.argSettings; } - public void setArgSettings(List> argSettings) { this.argSettings = argSettings; } + // -------------------------------------------- // + // PARAMETERS + // -------------------------------------------- // - // The index is the same as the argument index. - // So argAt(x) should be read by getArgReader(x) + public List> getParameters() { return this.parameters; } + public void setParameters(List> parameters) { this.parameters = parameters; } - public ArgSetting getArgSetting(int index) + public Parameter getParameter(int index) { - if (this.isUsingConcatFrom() && this.getConcatFromIndex() < index) index = this.getConcatFromIndex(); - return this.getArgSettings().get(index); + if (this.isConcatenating() && this.getConcatenationIndex() < index) index = this.getConcatenationIndex(); + return this.getParameters().get(index); } - public AR getArgReader(int index) + public Type getParameterType(int index) { - ArgSetting setting = this.getArgSetting(index); - return setting.getReader(); + Parameter parameter = this.getParameter(index); + return parameter.getType(); } - public boolean hasArgSettingForIndex(int index) + public boolean hasParameterForIndex(int index) { if (index < 0) return false; - if (this.isUsingConcatFrom() && this.getConcatFromIndex() < index) index = this.getConcatFromIndex(); - if (this.getArgSettings().size() <= index) return false; + if (this.isConcatenating() && this.getConcatenationIndex() < index) index = this.getConcatenationIndex(); + if (this.getParameters().size() <= index) return false; return true; } - // The actual setting. - public ArgSetting addArg(ArgSetting setting, boolean concatFromHere) + // -------------------------------------------- // + // PARAMETERS > COUNT + // -------------------------------------------- // + + public int getParameterCount(CommandSender sender) + { + return this.getParameterCountRequired(sender) + this.getParameterCountOptional(sender); + } + + public int getParameterCountRequired(CommandSender sender) + { + int ret = 0; + + for (Parameter parameter : this.getParameters()) + { + if (parameter.isRequiredFor(sender)) ret++; + } + + return ret; + } + + public int getParameterCountOptional(CommandSender sender) + { + int ret = 0; + + for (Parameter parameter : this.getParameters()) + { + if (parameter.isOptionalFor(sender)) ret++; + } + + return ret; + } + + // -------------------------------------------- // + // PARAMETERS > ADD + // -------------------------------------------- // + + // The actual parameter. + public Parameter addParameter(Parameter parameter, boolean concatFromHere) { // Concat safety. - if (this.isUsingConcatFrom()) + if (this.isConcatenating()) { throw new IllegalStateException("You can't add args if a prior one concatenates."); } // Req/optional safety. - int prior = this.getArgSettings().size()-1; - if (this.hasArgSettingForIndex(prior) && this.getArgSetting(prior).isOptional() && setting.isRequired()) + int prior = this.getParameters().size()-1; + if (this.hasParameterForIndex(prior) && this.getParameter(prior).isOptional() && parameter.isRequired()) { throw new IllegalArgumentException("You can't add required args, if a prior one is optional."); } // If false no change is made. // If true change is made. - this.setUsingConcatFrom(concatFromHere); + this.setConcatenating(concatFromHere); - this.getArgSettings().add(setting); - return setting; + this.getParameters().add(parameter); + return parameter; } - // The actual setting without concat. - public ArgSetting addArg(ArgSetting setting) + // The actual parameter without concat. + public Parameter addParameter(Parameter parameter) { - return this.addArg(setting, false); + return this.addParameter(parameter, false); } // All - public ArgSetting addArg(T defaultValue, AR reader, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere) + public Parameter addParameter(T defaultValue, Type type, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere) { - return this.addArg(new ArgSetting(defaultValue, reader, requiredFromConsole, name, defaultDesc), concatFromHere); + return this.addParameter(new Parameter(defaultValue, type, requiredFromConsole, name, defaultDesc), concatFromHere); } // WITHOUT 1 // Without defaultValue - public ArgSetting addArg(AR reader, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere) + public Parameter addParameter(Type type, boolean requiredFromConsole, String name, String defaultDesc, boolean concatFromHere) { - return this.addArg(new ArgSetting(reader, requiredFromConsole, name, defaultDesc), concatFromHere); + return this.addParameter(new Parameter(type, requiredFromConsole, name, defaultDesc), concatFromHere); } // Without reqFromConsole. - public ArgSetting addArg(T defaultValue, AR reader, String name, String defaultDesc, boolean concatFromHere) + public Parameter addParameter(T defaultValue, Type type, String name, String defaultDesc, boolean concatFromHere) { - return this.addArg(new ArgSetting(defaultValue, reader, name, defaultDesc), concatFromHere); + return this.addParameter(new Parameter(defaultValue, type, name, defaultDesc), concatFromHere); } // Without defaultDesc. - public ArgSetting addArg(T defaultValue, AR reader, boolean requiredFromConsole, String name, boolean concatFromHere) + public Parameter addParameter(T defaultValue, Type type, boolean requiredFromConsole, String name, boolean concatFromHere) { - return this.addArg(new ArgSetting(defaultValue, reader, requiredFromConsole, name), concatFromHere); + return this.addParameter(new Parameter(defaultValue, type, requiredFromConsole, name), concatFromHere); } // Without concat. - public ArgSetting addArg(T defaultValue, AR reader, boolean requiredFromConsole, String name, String defaultDesc) + public Parameter addParameter(T defaultValue, Type type, boolean requiredFromConsole, String name, String defaultDesc) { - return this.addArg(new ArgSetting(defaultValue, reader, requiredFromConsole, name, defaultDesc), false); + return this.addParameter(new Parameter(defaultValue, type, requiredFromConsole, name, defaultDesc), false); } // WITHOUT 2 // Without defaultValue & reqFromConsole - public ArgSetting addArg(AR reader, String name, String defaultDesc, boolean concatFromHere) + public Parameter addParameter(Type type, String name, String defaultDesc, boolean concatFromHere) { - return this.addArg(new ArgSetting(reader, name, defaultDesc), concatFromHere); + return this.addParameter(new Parameter(type, name, defaultDesc), concatFromHere); } // Without defaultValue & defaultDesc - public ArgSetting addArg(AR reader, boolean requiredFromConsole, String name, boolean concatFromHere) + public Parameter addParameter(Type type, boolean requiredFromConsole, String name, boolean concatFromHere) { - return this.addArg(new ArgSetting(reader, requiredFromConsole, name), concatFromHere); + return this.addParameter(new Parameter(type, requiredFromConsole, name), concatFromHere); } // Without defaultValue & concat. - public ArgSetting addArg(AR reader, boolean requiredFromConsole, String name, String defaultDesc) + public Parameter addParameter(Type type, boolean requiredFromConsole, String name, String defaultDesc) { - return this.addArg(new ArgSetting(reader, requiredFromConsole, name, defaultDesc)); + return this.addParameter(new Parameter(type, requiredFromConsole, name, defaultDesc)); } // Without reqFromConsole & defaultDesc. - public ArgSetting addArg(T defaultValue, AR reader, String name, boolean concatFromHere) + public Parameter addParameter(T defaultValue, Type type, String name, boolean concatFromHere) { - return this.addArg(new ArgSetting(defaultValue, reader, name), concatFromHere); + return this.addParameter(new Parameter(defaultValue, type, name), concatFromHere); } // Without reqFromConsole & concat. - public ArgSetting addArg(T defaultValue, AR reader, String name, String defaultDesc) + public Parameter addParameter(T defaultValue, Type type, String name, String defaultDesc) { - return this.addArg(new ArgSetting(defaultValue, reader, name, defaultDesc)); + return this.addParameter(new Parameter(defaultValue, type, name, defaultDesc)); } // Without defaultDesc & concat. - public ArgSetting addArg(T defaultValue, AR reader, boolean requiredFromConsole, String name) + public Parameter addParameter(T defaultValue, Type type, boolean requiredFromConsole, String name) { - return this.addArg(new ArgSetting(defaultValue, reader, requiredFromConsole, name)); + return this.addParameter(new Parameter(defaultValue, type, requiredFromConsole, name)); } // WITHOUT 3 // Without defaultValue, reqFromConsole & defaultDesc. - public ArgSetting addArg(AR reader, String name, boolean concatFromHere) + public Parameter addParameter(Type type, String name, boolean concatFromHere) { - return this.addArg(new ArgSetting(reader, name), concatFromHere); + return this.addParameter(new Parameter(type, name), concatFromHere); } // Without defaultValue, reqFromConsole & concat . - public ArgSetting addArg(AR reader, String name, String defaultDesc) + public Parameter addParameter(Type type, String name, String defaultDesc) { - return this.addArg(new ArgSetting(reader, name, defaultDesc)); + return this.addParameter(new Parameter(type, name, defaultDesc)); } // Without defaultValue, defaultDesc & concat . - public ArgSetting addArg(AR reader, boolean requiredFromConsole, String name) + public Parameter addParameter(Type type, boolean requiredFromConsole, String name) { - return this.addArg(new ArgSetting(reader, requiredFromConsole, name)); + return this.addParameter(new Parameter(type, requiredFromConsole, name)); } // Without reqFromConsole, defaultDesc & concat . - public ArgSetting addArg(T defaultValue, AR reader, String name) + public Parameter addParameter(T defaultValue, Type type, String name) { - return this.addArg(new ArgSetting(defaultValue, reader, name)); + return this.addParameter(new Parameter(defaultValue, type, name)); } // WITHOUT 4 // Without defaultValue, reqFromConsole, defaultDesc & concat . - public ArgSetting addArg(AR reader, String name) + public Parameter addParameter(Type type, String name) { - return this.addArg(new ArgSetting(reader, name)); + return this.addParameter(new Parameter(type, name)); } + + // -------------------------------------------- // + // PREPROCESS + // -------------------------------------------- // + // These options are applied very early. + // The code is located in the MassiveCoreBukkitCommand. - // FIELD: errorOnToManyArgs - // Should an error be thrown if "too many" args are sent. - protected boolean givingErrorOnTooManyArgs; - public boolean isGivingErrorOnTooManyArgs() { return this.givingErrorOnTooManyArgs; } - public void setGivingErrorOnTooManyArgs(boolean val) { this.givingErrorOnTooManyArgs = val; } + public boolean isTokenizing() { return this.tokenizing; } + public void setTokenizing(boolean tokenizing) { this.tokenizing = tokenizing; } - // FIELD concatFrom - // From which arg should the be concatenated. - protected boolean usingConcatFrom; - public boolean isUsingConcatFrom() { return this.usingConcatFrom; } - public void setUsingConcatFrom(boolean usingConcatFrom) { this.usingConcatFrom = usingConcatFrom; } + public boolean isUnsmart() { return this.unsmart; } + public void setUnsmart(boolean unsmart) { this.unsmart = unsmart; } - public int getConcatFromIndex() { return this.getArgSettings().size() -1; } + // -------------------------------------------- // + // PUZZLER + // -------------------------------------------- // + // At the puzzler phase of execution we massage the raw arguments. + // The end result is still raw arguments but their order and composition is better adapted to our parameters. - // FIELD: usingTokenizer - // Should the arguments be parsed considering quotes and backslashes and such? - protected boolean usingTokenizer; - public boolean isUsingTokenizer() { return this.usingTokenizer; } - public void setUsingTokenizer(boolean usingTokenizer) { this.usingTokenizer = usingTokenizer; } + public boolean isOverflowSensitive() { return this.overflowSensitive; } + public void setOverflowSensitive(boolean overflowSensitive) { this.overflowSensitive = overflowSensitive; } - // FIELD: usingSmartQuotesRemoval - // Are "smart" quotes replaced with normal characters? - protected boolean usingSmartQuotesRemoval; - public boolean isUsingSmartQuotesRemoval() { return this.usingSmartQuotesRemoval; } - public void setUsingSmartQuotesRemoval(boolean usingSmartQuotesRemoval) { this.usingSmartQuotesRemoval = usingSmartQuotesRemoval; } + public boolean isConcatenating() { return this.concatenating; } + public void setConcatenating(boolean concatenating) { this.concatenating = concatenating; } + public int getConcatenationIndex() { return this.getParameters().size() - 1; } - // FIELD: usingArbitraryArgumentOrder - // Can the order of the args which the player types, be arbitrary? - protected boolean usingArbitraryArgumentOrder; - public boolean isUsingArbitraryArgumentOrder() { return this.usingArbitraryArgumentOrder; } - public void setUsingArbitraryArgumentOrder(boolean usingArbitraryArgumentOrder) { this.usingArbitraryArgumentOrder = usingArbitraryArgumentOrder; } + public boolean isSwapping() { return this.swapping; } + public void setSwapping(boolean swapping) { this.swapping = swapping; } + + // -------------------------------------------- // + // PUZZLER > APPLY + // -------------------------------------------- // + + public List applyPuzzler(List args, CommandSender sender) + { + args = this.applyConcatenating(args); + args = this.applySwapping(args, sender); + return args; + } + + public List applyConcatenating(List args) + { + // Really? + if ( ! this.isConcatenating()) return args; + + // Create Ret + List ret = new MassiveList(); + + // Fill Ret + final int maxIdx = Math.min(this.getConcatenationIndex(), args.size()); + ret.addAll(args.subList(0, maxIdx)); // The args that should not be concatenated. + if (args.size() > maxIdx) + { + ret.add(Txt.implode(args.subList(maxIdx, args.size()), " ")); + } + + // Return Ret + return ret; + } + + public List applySwapping(List args, CommandSender sender) + { + // Really? + if ( ! this.isSwapping()) return args; + + // So if there is too many, or too few args. We can't do much here. + if ( ! this.isArgsValid(args)) return args; + + String[] ret = new String[this.getParameters().size()]; + + args: + for (String arg : args) + { + parameters: + for (int i = 0; i < this.getParameters().size(); i++) + { + Type type = this.getParameterType(i); + + if (ret[i] != null) continue parameters; // If that index is already filled. + + // We do in fact want to allow null args. + // Those are used by us in some special circumstances. + if (arg != null && ! type.isValid(arg, sender)) continue parameters; // If this arg isn't valid for that index. + + ret[i] = arg; + continue args; // That arg is now set :) + } + // We will only end up here if an arg didn't fit any of the types. + // In that case we failed. + return args; + } + + // Ensure that the required args are filled. + for (int i = 0; i < this.getParameterCountRequired(sender); i++) + { + if (ret[i] != null) continue; + // We end up here if an required arg wasn't filled. In that case we failed. + return args; + } + + return Arrays.asList(ret); + } + + // -------------------------------------------- // + // REQUIREMENTS + // -------------------------------------------- // - // FIELD: requirements - // All these requirements must be met for the command to be executable; - protected List requirements; public List getRequirements() { return this.requirements; } - public void getRequirements(List requirements) { this.requirements = requirements; } + public void setRequirements(List requirements) { this.requirements = requirements; } public void addRequirements(Req... requirements) { this.requirements.addAll(Arrays.asList(requirements)); } - // FIELD: desc - // This field may be left blank and will in such case be loaded from the permissions node instead. - // Thus make sure the permissions node description is an action description like "eat hamburgers" or "do admin stuff". - protected String desc = null; - public void setDesc(String desc) { this.desc = desc; } + public boolean isRequirementsMet(CommandSender sender, boolean informSenderIfNot) + { + for (Req req : this.getRequirements()) + { + if (req.apply(sender, this)) continue; + + if (informSenderIfNot) + { + Mixin.messageOne(sender, req.createErrorMessage(sender, this)); + } + return false; + } + return true; + } + // -------------------------------------------- // + // HELP + // -------------------------------------------- // + + public void setDesc(String desc) { this.desc = desc; } public String getDesc() { if (this.desc != null) return this.desc; @@ -390,7 +667,7 @@ public class MassiveCommand String perm = this.getDescPermission(); if (perm != null) { - String pdesc = PermUtil.getDescription(this.getDescPermission()); + String pdesc = PermUtil.getDescription(perm); if (pdesc != null) { return pdesc; @@ -400,11 +677,7 @@ public class MassiveCommand return "*info unavailable*"; } - // FIELD: descPermission - // This permission node IS NOT TESTED AT ALL. It is rather used in the method above. - protected String descPermission; public void setDescPermission(String descPermission) { this.descPermission = descPermission; } - public String getDescPermission() { if (this.descPermission != null) return this.descPermission; @@ -416,175 +689,136 @@ public class MassiveCommand } return null; } - - // FIELD: help - // This is a multi-line help text for the command. - protected List help = new ArrayList(); + public void setHelp(List val) { this.help = val; } public void setHelp(String... val) { this.help = Arrays.asList(val); } public List getHelp() { return this.help; } - // FIELD: visibilityMode - protected VisibilityMode visibilityMode; - public VisibilityMode getVisibilityMode() { return this.visibilityMode; } - public void setVisibilityMode(VisibilityMode visibilityMode) { this.visibilityMode = visibilityMode; } + public Visibility getVisibility() { return this.visibility; } + public void setVisibility(Visibility visibility) { this.visibility = visibility; } + public boolean isVisibleTo(CommandSender sender) + { + if (this.getVisibility() == Visibility.VISIBLE) return true; + if (this.getVisibility() == Visibility.INVISIBLE) return false; + return this.isRequirementsMet(sender, false); + } // -------------------------------------------- // - // EXECUTION INFO + // EXECUTION // -------------------------------------------- // - // FIELD: args - // Will contain the arguments, or and empty list if there are none. - protected List args; public List getArgs() { return this.args; } public void setArgs(List args) { this.args = args; } - // FIELD: commandChain - // The command chain used to execute this command - protected List commandChain = new ArrayList(); - public List getCommandChain() { return this.commandChain; } - public void setCommandChain(List commandChain) { this.commandChain = commandChain; } + public List getChain() { return this.chain; } + public void setChain(List chain) { this.chain = chain; } // Adds command to tree structure - public void addToCommandChain(MassiveCommand command) + public void addToChain(MassiveCommand command) { - this.commandChain.add(0, command); + this.chain.add(0, command); - List cmds = this.getSubCommands(); + List children = this.getChildren(); - for (MassiveCommand cmd : cmds) + for (MassiveCommand child : children) { - cmd.addToCommandChain(command); + child.addToChain(command); } } - public MassiveCommand getParentCommand() + public MassiveCommand getParent() { - List commandChain = this.getCommandChain(); - if (commandChain == null) return null; - if (commandChain.isEmpty()) return null; - return commandChain.get(commandChain.size()-1); + List chain = this.getChain(); + if (chain == null) return null; + if (chain.isEmpty()) return null; + return chain.get(chain.size()-1); } - public boolean hasParentCommand() { return this.getParentCommand() != null; } - - // FIELD: nextArg - // The index of the next arg to read. - public int nextArg; - - // FIELDS: sender, me, senderIsConsole - public CommandSender sender; - public Player me; - public boolean senderIsConsole; - - // -------------------------------------------- // - // ARG AMOUNTS - // -------------------------------------------- // - - public int getRequiredArgsAmountFor(CommandSender sender) + public boolean hasParent() { - int ret = 0; - - for (ArgSetting setting : this.getArgSettings()) - { - if (setting.isRequiredFor(sender)) ret++; - } - - return ret; - } - - public int getOptionalArgsAmountFor(CommandSender sender) - { - int ret = 0; - - for (ArgSetting setting : this.getArgSettings()) - { - if (setting.isOptionalFor(sender)) ret++; - } - - return ret; - } - - public int getAllArgsAmountFor(CommandSender sender) - { - return this.getOptionalArgsAmountFor(sender) + this.getRequiredArgsAmountFor(sender); + return this.getParent() != null; } // -------------------------------------------- // - // CONSTRUCTORS AND EXECUTOR + // EXECUTOR // -------------------------------------------- // - public MassiveCommand() + public void execute(CommandSender sender, List args, List chain) { - this.subCommands = new ArrayList(); - - this.aliases = new ArrayList(); - - this.argSettings = new ArrayList>(); - - this.requirements = new ArrayList(); - - this.givingErrorOnTooManyArgs = true; - this.usingConcatFrom = false; - - this.usingTokenizer = true; - this.usingSmartQuotesRemoval = true; - this.usingArbitraryArgumentOrder = true; - - this.desc = null; - this.descPermission = null; - - this.visibilityMode = VisibilityMode.VISIBLE; - } - - // The commandChain is a list of the parent command chain used to get to this command. - public void execute(CommandSender sender, List args, List commandChain) - { - args = this.applyConcatFrom(args); - - if (this.isUsingArbitraryArgumentOrder()) - { - args = this.fixArgOrder(args, sender); - } - - this.setArgs(args); - this.setCommandChain(commandChain); - - // Is there a matching sub command? - if (args.size() > 0) - { - MassiveCommand subCommand = this.getSubCommand(args.get(0)); - if (subCommand != null) - { - args.remove(0); - commandChain.add(this); - subCommand.execute(sender, args, commandChain); - return; - } - } - try { - // Set Sender Variables - this.nextArg = 0; - this.sender = sender; - this.senderIsConsole = true; - this.me = null; - if (sender instanceof Player) - { - this.me = (Player) sender; - this.senderIsConsole = false; - } - this.fixSenderVars(); + // Update Chain + this.setChain(chain); + + // Sender Field - Setup + this.senderFieldsOuter(sender); + + // Apply Puzzler + args = this.applyPuzzler(args, sender); + this.setArgs(args); - if (isValidCall(this.sender, this.getArgs())) + // Child Execution + if (this.isParent() && args.size() > 0) { - perform(); + // Get matches + String token = args.get(0); + Map matches = this.getChildMatches(token, false, null); + + // Score! + if (matches.size() == 1) + { + MassiveCommand child = matches.entrySet().iterator().next().getValue(); + args.remove(0); + chain.add(this); + child.execute(sender, args, chain); + } + // Crap! + else + { + Mson base = null; + Collection suggestions = null; + + if (matches.isEmpty()) + { + base = Lang.COMMAND_CHILD_NONE; + suggestions = this.getChildMatches(token, true, sender).values(); + } + else + { + base = Lang.COMMAND_CHILD_AMBIGUOUS; + suggestions = this.getChildMatches(token, false, sender).values(); + } + + // Message: "The sub command X couldn't be found." + // OR + // Message: "The sub command X is ambiguous." + Mson bluetoken = mson(token).color(ChatColor.AQUA); + Mixin.messageOne(sender, base.replaceAll(Lang.COMMAND_REPLACEMENT, bluetoken).command(this)); + + // Message: "/f access ..." + // Message: "/f ally ..." + for (MassiveCommand suggestion : suggestions) + { + Mixin.messageOne(sender, suggestion.getTemplate(suggestion.getChain(), false, false, sender)); + } + + // Message: "Use /Y to see all commands." + Mixin.messageOne(sender, Lang.COMMAND_CHILD_HELP.replaceAll(Lang.COMMAND_REPLACEMENT, this.getTemplate(chain, false, false, sender)).command(this)); + } + + // NOTE: This return statement will jump to the finally block. + return; + } + + // Self Execution (Perform) + if (this.isValidCall(this.sender, this.getArgs())) + { + this.perform(); } } catch (MassiveException ex) { - // Sometimes ArgReaders (or commands themself) throw exceptions, to stop executing and notify the user. + // Sometimes Types (or commands themselves) throw exceptions, to stop executing and notify the user. if (ex.hasMessages()) { Mixin.messageOne(sender, ex.getMessages()); @@ -592,19 +826,28 @@ public class MassiveCommand } finally { - // Unset Sender Variables - this.nextArg = 0; - this.sender = null; - this.me = null; - this.unsetSenderVars(); + // Sender Sender - Cleanup + this.senderFieldsOuter(null); } } - public void fixSenderVars() + public void senderFieldsOuter(CommandSender sender) { + this.nextArg = 0; + this.sender = sender; + this.senderIsConsole = true; + this.me = null; + if (sender instanceof Player) + { + this.me = (Player) sender; + this.senderIsConsole = false; + } + boolean set = (sender != null); + this.senderFields(set); } - public void unsetSenderVars() + + public void senderFields(boolean set) { } @@ -614,74 +857,14 @@ public class MassiveCommand execute(sender, args, new ArrayList()); } - public List applyConcatFrom(List args) - { - if ( ! this.isUsingConcatFrom()) return args; - - List ret = new MassiveList(); - final int maxIdx = Math.min(this.getConcatFromIndex(), args.size()); - ret.addAll(args.subList(0, maxIdx)); // The args that should not be concatenated. - - if (args.size() > maxIdx) - { - ret.add(Txt.implode(args.subList(maxIdx, args.size()), " ")); - } - - return ret; - } - // This is where the command action is performed. public void perform() throws MassiveException { // Per default we just act as the help command! - List commandChain = new ArrayList(this.getCommandChain()); - commandChain.add(this); + List chain = new ArrayList(this.getChain()); + chain.add(this); - HelpCommand.get().execute(this.sender, this.getArgs(), commandChain); - } - - // -------------------------------------------- // - // FIX ARG ORDER - // -------------------------------------------- // - - public List fixArgOrder(List args, CommandSender sender) - { - // So if there is too many, or too few args. We can't do much here. - if ( ! this.isArgsValid(args)) return args; - - String[] ret = new String[this.getArgSettings().size()]; - - args: - for (String arg : args) - { - settings: - for (int i = 0; i < this.getArgSettings().size(); i++) - { - AR reader = this.getArgReader(i); - - if (ret[i] != null) continue settings; // If that index is already filled. - - // We do in fact want to allow null args. - // Those are used by us in some special circumstances. - if (arg != null && ! reader.isValid(arg, sender)) continue settings; // If this arg isn't valid for that index. - - ret[i] = arg; - continue args; // That arg is now set :) - } - // We will only end up here if an arg didn't fit any of the arg readers. - // In that case we failed. - return args; - } - - // Ensure that the required args are filled. - for (int i = 0; i < this.getRequiredArgsAmountFor(sender); i++) - { - if (ret[i] != null) continue; - // We end up here if an required arg wasn't filled. In that case we failed. - return args; - } - - return Arrays.asList(ret); + HelpCommand.get().execute(this.sender, this.getArgs(), chain); } // -------------------------------------------- // @@ -706,73 +889,29 @@ public class MassiveCommand return true; } - public boolean isVisibleTo(CommandSender sender) - { - if (this.getVisibilityMode() == VisibilityMode.VISIBLE) return true; - if (this.getVisibilityMode() == VisibilityMode.INVISIBLE) return false; - return this.isRequirementsMet(sender, false); - } - - public boolean isRequirementsMet(CommandSender sender, boolean informSenderIfNot) - { - for (Req req : this.getRequirements()) - { - if (req.apply(sender, this)) continue; - - if (informSenderIfNot) - { - Mixin.messageOne(sender, req.createErrorMessage(sender, this)); - } - return false; - } - return true; - } - public boolean isArgsValid(List args, CommandSender sender) { - if (args.size() < this.getRequiredArgsAmountFor(sender)) + if (args.size() < this.getParameterCountRequired(sender)) { if (sender != null) { - Mixin.msgOne(sender, Lang.COMMAND_TOO_FEW_ARGS); - Mixin.messageOne(sender, this.getUseageTemplate()); + Mixin.msgOne(sender, Lang.COMMAND_TOO_FEW_ARGUMENTS); + Mixin.messageOne(sender, this.getTemplate()); } return false; } // We don't need to take argConcatFrom into account. Because at this point the args // are already concatenated and thus cannot be too many. - if (args.size() > this.getAllArgsAmountFor(sender) && this.isGivingErrorOnTooManyArgs()) + if (args.size() > this.getParameterCount(sender) && this.isOverflowSensitive()) { if (sender != null) { - if (this.isParentCommand()) - { - String arg = args.get(0); - - // Try Levenshtein - List matches = this.getSimilarSubcommandAliases(arg, this.getMaxLevenshteinDistanceForArg(arg)); - - Mixin.messageOne(sender, Lang.COMMAND_NO_SUCH_SUB.replaceAll(Lang.COMMAND_REPLACEMENT, this.getUseageTemplate(false).suggest(this, arg))); - if ( ! matches.isEmpty()) - { - String suggest = Txt.parse(Txt.implodeCommaAnd(matches, ", ", " or ")); - Mixin.messageOne(sender, Lang.COMMAND_SUGGEST_SUB.replaceAll(Lang.COMMAND_REPLACEMENT, this.getUseageTemplate(false).suggest(this, suggest))); - } - else - { - Mixin.messageOne(sender, Lang.COMMAND_GET_HELP.replaceAll(Lang.COMMAND_REPLACEMENT, this.getUseageTemplate(false).suggest(this))); - } - - } - else - { - // Get the too many string slice - List theTooMany = args.subList(this.getAllArgsAmountFor(sender), args.size()); - Mixin.msgOne(sender, Lang.COMMAND_TOO_MANY_ARGS, Txt.implodeCommaAndDot(theTooMany, Txt.parse("%s"), Txt.parse(", "), Txt.parse(" and "), "")); - Mixin.msgOne(sender, Lang.COMMAND_TOO_MANY_ARGS2); - Mixin.messageOne(sender, this.getUseageTemplate()); - } + // Get the too many string slice + List theTooMany = args.subList(this.getParameterCount(sender), args.size()); + Mixin.msgOne(sender, Lang.COMMAND_TOO_MANY_ARGUMENTS, Txt.implodeCommaAndDot(theTooMany, Txt.parse("%s"), Txt.parse(", "), Txt.parse(" and "), "")); + Mixin.msgOne(sender, Lang.COMMAND_TOO_MANY_ARGUMENTS2); + Mixin.messageOne(sender, this.getTemplate()); } return false; } @@ -784,66 +923,18 @@ public class MassiveCommand } // -------------------------------------------- // - // MATCHING SUGGESTIONS + // TEMPLATE // -------------------------------------------- // - public List getSimilarAliases(String arg, int maxLevenshteinDistance) - { - if (arg == null) return Collections.emptyList(); - arg = arg.toLowerCase(); - - List matches = new ArrayList(); - - for (String alias : this.getAliases()) - { - if (alias == null) continue; - String aliaslc = alias.toLowerCase(); - int distance = StringUtils.getLevenshteinDistance(arg, aliaslc); - if (distance > maxLevenshteinDistance) continue; - matches.add(alias); - } - return matches; - } + public static final Mson TEMPLATE_CORE = Mson.mson("/").color(ChatColor.AQUA); - public List getSimilarSubcommandAliases(String arg, int maxLevenshteinDistance) - { - if (arg == null) return Collections.emptyList(); - - // Try Levenshtein - List matches = new ArrayList(); - - for (MassiveCommand sub : this.getSubCommands()) - { - matches.addAll(sub.getSimilarAliases(arg, maxLevenshteinDistance)); - } - return matches; - } - - public int getMaxLevenshteinDistanceForArg(String arg) - { - if (arg == null) return 0; - if (arg.length() <= 1) return 0; // When dealing with 1 character aliases, there is way too many options. So we don't suggest. - if (arg.length() <= 4) return 1; // When dealing with low length aliases, there too many options. So we won't suggest much - if (arg.length() <= 7) return 2; // 2 is default. - - return 3; // If it were 8 characters or more, we end up here. Because many characters allow for more typos. - } - - // -------------------------------------------- // - // USAGE TEMPLATE - // -------------------------------------------- // - // TODO: Misspelled "Useage" - - public static final Mson USAGE_TEMPLATE_CORE = Mson.mson("/").color(ChatColor.AQUA); - - public Mson getUseageTemplate(List commandChain, boolean addDesc, boolean onlyFirstAlias, CommandSender sender) + public Mson getTemplate(List chain, boolean addDesc, boolean onlyFirstAlias, CommandSender sender) { // Create Ret - Mson ret = USAGE_TEMPLATE_CORE; - List extra = new ArrayList(); + Mson ret = TEMPLATE_CORE; - // Get commandchain - List commands = new ArrayList(commandChain); + // Get chain + List commands = new ArrayList(chain); commands.add(this); // Add commands @@ -870,13 +961,13 @@ public class MassiveCommand mson = mson.color(ChatColor.AQUA); } - if ( ! first) extra.add(Mson.SPACE); - extra.add(mson); + if ( ! first) ret = ret.add(Mson.SPACE); + ret = ret.add(mson); first = false; } // Check if last command is parentCommand and make command suggestable/clickable - if (commands.get(commands.size() - 1).isParentCommand()) + if (commands.get(commands.size() - 1).isParent()) { ret = ret.command(this); } @@ -886,53 +977,53 @@ public class MassiveCommand } // Add args - for (Mson arg : this.getArgUseagesFor(sender)) + for (Mson parameter : this.getTemplateParameters(sender)) { - extra.add(Mson.SPACE); - extra.add(arg.color(ChatColor.DARK_AQUA)); + ret = ret.add(Mson.SPACE); + ret = ret.add(parameter.color(ChatColor.DARK_AQUA)); } // Add desc if (addDesc) { - extra.add(Mson.SPACE); - extra.add(mson(this.getDesc()).color(ChatColor.YELLOW)); + ret = ret.add(Mson.SPACE); + ret = ret.add(mson(this.getDesc()).color(ChatColor.YELLOW)); } // Return Ret - return ret.extra(extra); + return ret; } - protected List getArgUseagesFor(CommandSender sender) + protected List getTemplateParameters(CommandSender sender) { List ret = new MassiveList(); - for (ArgSetting setting : this.getArgSettings()) + for (Parameter parameter : this.getParameters()) { - ret.add(setting.getUseageTemplateDisplayFor(sender)); + ret.add(parameter.getTemplate(sender)); } return ret; } - public Mson getUseageTemplate(List commandChain, boolean addDesc, boolean onlyFirstAlias) + public Mson getTemplate(List chain, boolean addDesc, boolean onlyFirstAlias) { - return getUseageTemplate(commandChain, addDesc, onlyFirstAlias, sender); + return getTemplate(chain, addDesc, onlyFirstAlias, sender); } - public Mson getUseageTemplate(List commandChain, boolean addDesc) + public Mson getTemplate(List chain, boolean addDesc) { - return getUseageTemplate(commandChain, addDesc, false); + return getTemplate(chain, addDesc, false); } - public Mson getUseageTemplate(boolean addDesc) + public Mson getTemplate(boolean addDesc) { - return getUseageTemplate(this.getCommandChain(), addDesc); + return getTemplate(this.getChain(), addDesc); } - public Mson getUseageTemplate() + public Mson getTemplate() { - return getUseageTemplate(false); + return getTemplate(false); } // -------------------------------------------- // @@ -953,7 +1044,7 @@ public class MassiveCommand ret.append('/'); // Then parent commands - for (MassiveCommand parent : this.getCommandChain()) + for (MassiveCommand parent : this.getChain()) { // Append parent ret.append(parent.getAliases().get(0)); @@ -991,9 +1082,9 @@ public class MassiveCommand if (sender == null) throw new IllegalArgumentException("sender was null"); if (args.isEmpty()) throw new IllegalArgumentException("args was empty"); - if (this.isParentCommand()) + if (this.isParent()) { - return this.getTabCompletionsSub(args, sender); + return this.getTabCompletionsChild(args, sender); } else { @@ -1001,49 +1092,44 @@ public class MassiveCommand } } - protected List getTabCompletionsSub(List args, CommandSender sender) + protected List getTabCompletionsChild(List args, CommandSender sender) { - // If this isn't the last argument... + // If this isn't the last argument ... if (args.size() != 1) { - // ...we will ask the subcommand for tab completions. - MassiveCommand cmd = this.getSubCommand(args.get(0)); - if (cmd == null) return Collections.emptyList(); + // ... and there is a matching child ... + MassiveCommand child = this.getChild(args.get(0)); + if (child == null) return Collections.emptyList(); + + // ... get tab completions for that child. args.remove(0); - return cmd.getTabCompletions(args, sender); + return child.getTabCompletions(args, sender); } - // ...else check the subcommands. + // ... else check the children. List ret = new ArrayList(); String token = args.get(args.size()-1).toLowerCase(); - for (MassiveCommand sub : this.getSubCommands()) + for (MassiveCommand child : this.getChildren()) { - if ( ! this.shouldSenderTabCompleteSub(sender, sub)) continue; - ret.addAll(Txt.getStartsWithIgnoreCase(sub.getAliases(), token)); + if ( ! child.isRelevant(sender)) continue; + ret.addAll(Txt.getStartsWithIgnoreCase(child.getAliases(), token)); } return addSpaceAtEnd(ret); } - protected boolean shouldSenderTabCompleteSub(CommandSender sender, MassiveCommand sub) - { - if ( ! sub.isVisibleTo(sender)) return false; - if ( ! sub.isRequirementsMet(sender, false)) return false; - return true; - } - protected List getTabCompletionsArg(List args, CommandSender sender) { - args = this.applyConcatFrom(args); + args = this.applyConcatenating(args); int index = args.size() - 1; - if ( ! this.hasArgSettingForIndex(index)) return Collections.emptyList(); - AR reader = this.getArgReader(index); + if ( ! this.hasParameterForIndex(index)) return Collections.emptyList(); + Type type = this.getParameterType(index); - List ret = reader.getTabListFiltered(sender, args.get(index)); + List ret = type.getTabListFiltered(sender, args.get(index)); - // If the reader allows space after tab and this is not the last possible argument... - if (reader.allowSpaceAfterTab() && this.hasArgSettingForIndex(args.size())) + // If the type allows space after tab and this is not the last possible argument... + if (type.allowSpaceAfterTab() && this.hasParameterForIndex(args.size())) { // ...we will sometimes add a space at the end. Depending on list size. ret = addSpaceAtEnd(ret); @@ -1171,18 +1257,18 @@ public class MassiveCommand @SuppressWarnings("unchecked") public 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()); + // Make sure that a Parameter is present. + if ( ! this.hasParameterForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. Parameters size: " + this.getParameters().size()); // Increment nextArg = idx + 1; - // Get the setting - ArgSetting setting = (ArgSetting) this.getArgSetting(idx); - // Return the default in the setting. - if ( ! this.argIsSet(idx) && setting.isDefaultValueSet()) return setting.getDefaultValue(); + // Get the parameter + Parameter parameter = (Parameter) this.getParameter(idx); + // Return the default in the parameter. + if ( ! this.argIsSet(idx) && parameter.isDefaultValueSet()) return parameter.getDefaultValue(); - // OLD: Throw error if there was no arg, or default value in the setting. + // OLD: Throw error if there was no arg, or default value in the parameter. // OLD: if ( ! this.argIsSet(idx)) throw new IllegalArgumentException("Trying to access arg: " + idx + " but that is not set."); // NOTE: This security actually blocks some functionality. Certain AR handle null argument values and specify their own default from within. // NOTE: An example is the MassiveQuest ARMNode which defaults to the used node of the player but must error when the player has no used node: "You must use a quest to skip the optional argument.". @@ -1192,7 +1278,7 @@ public class MassiveCommand if (this.argIsSet(idx)) arg = this.getArgs().get(idx); // Read and return the arg. - return setting.getReader().read(arg, sender); + return parameter.getType().read(arg, sender); } public T readArgAt(int idx, T defaultNotSet) throws MassiveException @@ -1215,23 +1301,23 @@ public class MassiveCommand // TODO: Fix those plugins. @Deprecated - public T readArgFrom(AR argReader) throws MassiveException + public T readArgFrom(Type type) throws MassiveException { - return this.readArgFrom(null, argReader); + return this.readArgFrom(null, type); } @Deprecated - public T readArgFrom(String str, AR argReader) throws MassiveException + public T readArgFrom(String str, Type type) throws MassiveException { - if (argReader == null) throw new IllegalArgumentException("argReader is null"); - return argReader.read(str, this.sender); + if (type == null) throw new IllegalArgumentException("type is null"); + return type.read(str, this.sender); } @Deprecated - public T readArgFrom(String str, AR argReader, T defaultNotSet) throws MassiveException + public T readArgFrom(String str, Type type, T defaultNotSet) throws MassiveException { if (str == null) return defaultNotSet; - return this.readArgFrom(str, argReader); + return this.readArgFrom(str, type); } } diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCoreBukkitCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCoreBukkitCommand.java index bab6a5ad..98bceaa8 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCoreBukkitCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCoreBukkitCommand.java @@ -34,7 +34,7 @@ public class MassiveCoreBukkitCommand extends Command implements PluginIdentifia super( name, massiveCommand.getDesc(), - massiveCommand.getUseageTemplate().toPlain(true), + massiveCommand.getTemplate().toPlain(true), Collections.emptyList() // We don't use aliases ); this.massiveCommand = massiveCommand; @@ -65,7 +65,7 @@ public class MassiveCoreBukkitCommand extends Command implements PluginIdentifia public List createArgList(String[] args) { List ret; - if (this.getMassiveCommand().isUsingTokenizer()) + if (this.getMassiveCommand().isTokenizing()) { ret = Txt.tokenizeArguments(Txt.implode(args, " ")); } @@ -74,7 +74,7 @@ public class MassiveCoreBukkitCommand extends Command implements PluginIdentifia ret = MUtil.list(args); } - if (this.getMassiveCommand().isUsingSmartQuotesRemoval()) + if (this.getMassiveCommand().isUnsmart()) { List oldArgList = ret; ret = new ArrayList(oldArgList.size()); diff --git a/src/com/massivecraft/massivecore/cmd/ArgSetting.java b/src/com/massivecraft/massivecore/cmd/Parameter.java similarity index 60% rename from src/com/massivecraft/massivecore/cmd/ArgSetting.java rename to src/com/massivecraft/massivecore/cmd/Parameter.java index 1253e38f..a1ec2c0a 100644 --- a/src/com/massivecraft/massivecore/cmd/ArgSetting.java +++ b/src/com/massivecraft/massivecore/cmd/Parameter.java @@ -5,11 +5,11 @@ import static com.massivecraft.massivecore.mson.Mson.mson; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.massivecraft.massivecore.cmd.arg.AR; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.type.TypeInteger; +import com.massivecraft.massivecore.cmd.type.Type; import com.massivecraft.massivecore.mson.Mson; -public class ArgSetting +public class Parameter { // -------------------------------------------- // // CONSTANTS @@ -24,16 +24,16 @@ public class ArgSetting // FIELDS // -------------------------------------------- // - protected AR reader; - public AR getReader() { return reader; } - public ArgSetting setReader(AR reader) { this.reader = reader; return this; } + protected Type type; + public Type getType() { return type; } + public Parameter setType(Type type) { this.type = type; return this; } protected String name; public String getName() { return name; } - public ArgSetting setName(String name) { this.name = name; return this; } + public Parameter setName(String name) { this.name = name; return this; } protected String defaultDesc = null; - public ArgSetting setDefaultDesc(String defaultDesc) { this.defaultDesc = defaultDesc; return this; } + public Parameter setDefaultDesc(String defaultDesc) { this.defaultDesc = defaultDesc; return this; } public String getDefaultDesc() { if (this.defaultDesc != null) return defaultDesc; @@ -43,7 +43,7 @@ public class ArgSetting protected T defaultValue = null; public T getDefaultValue() { return defaultValue; } - public ArgSetting setDefaultValue(T defaultValue) + public Parameter setDefaultValue(T defaultValue) { this.defaultValue = defaultValue; this.defaultValueSet = true; @@ -65,7 +65,7 @@ public class ArgSetting // 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 Parameter setRequiredFromConsole(boolean requiredFromConsole) { this.requiredFromConsole = requiredFromConsole; return this; } // An optional description of this argument. // Examples: @@ -74,7 +74,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 Parameter setDesc(String desc) { this.desc = desc; return this; } public boolean hasDesc() { return this.getDesc() != null; } @@ -86,13 +86,13 @@ public class ArgSetting // description must not be set in the constructor. // All - public ArgSetting(T defaultValue, AR reader, boolean requiredFromConsole, String name, String defaultDesc) + public Parameter(T defaultValue, Type type, boolean requiredFromConsole, String name, String defaultDesc) { // Null checks - if (reader == null) throw new IllegalArgumentException("reader mustn't be null"); + if (type == null) throw new IllegalArgumentException("type mustn't be null"); if (name == null) throw new IllegalArgumentException("name mustn't be null"); - this.setReader(reader); + this.setType(type); this.setRequiredFromConsole(requiredFromConsole); this.setName(name); this.setDefaultDesc(defaultDesc); @@ -101,64 +101,48 @@ public class ArgSetting // Without defaultValue @SuppressWarnings("unchecked") - public ArgSetting(AR reader, boolean requiredFromConsole, String name, String defaultDesc) + public Parameter(Type type, boolean requiredFromConsole, String name, String defaultDesc) { - this((T) DEFAULT_VALUE_DEFAULT, reader, requiredFromConsole, name, defaultDesc); + this((T) DEFAULT_VALUE_DEFAULT, type, requiredFromConsole, name, defaultDesc); // In fact the default value is not set. this.defaultValueSet = false; } // Without reqFromConsole. - public ArgSetting(T defaultValue, AR reader, String name, String defaultDesc) + public Parameter(T defaultValue, Type type, String name, String defaultDesc) { - this(defaultValue, reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc); + this(defaultValue, type, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc); } // Without defaultDesc. - public ArgSetting(T defaultValue, AR reader, boolean requiredFromConsole, String name) + public Parameter(T defaultValue, Type type, boolean requiredFromConsole, String name) { - this(defaultValue, reader, requiredFromConsole, name, DEFAULT_DESC_DEFAULT); + this(defaultValue, type, requiredFromConsole, name, DEFAULT_DESC_DEFAULT); } // Without defaultValue & reqFromConsole. - public ArgSetting(AR reader, String name, String defaultDesc) + public Parameter(Type type, String name, String defaultDesc) { - this(reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc); + this(type, REQUIRED_FROM_CONSOLE_DEFAULT, name, defaultDesc); } // Without defaultValue & defaultDesc. - public ArgSetting(AR reader, boolean requiredFromConsole, String name) + public Parameter(Type type, boolean requiredFromConsole, String name) { - this(reader, requiredFromConsole, name, DEFAULT_DESC_DEFAULT); + this(type, requiredFromConsole, name, DEFAULT_DESC_DEFAULT); } // Without reqFromConsole and defaultDesc. - public ArgSetting(T defaultValue, AR reader, String name) + public Parameter(T defaultValue, Type type, String name) { - this(defaultValue, reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT); + this(defaultValue, type, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT); } // Without defaultValue, reqFromConsole and defaultDesc. - public ArgSetting(AR reader, String name) + public Parameter(Type type, String name) { - this(reader, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT); - } - - // -------------------------------------------- // - // STATIC FACTORY (DEPRECATED) - // -------------------------------------------- // - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Deprecated - public static ArgSetting of(AR reader, boolean requiredFromConsole, String name, String def) - { - // Null checks - if (reader == null) throw new IllegalArgumentException("reader mustn't be null"); - if (name == null) throw new IllegalArgumentException("name mustn't be null"); - - // Create - return new ArgSetting(reader, requiredFromConsole, name, def); + this(type, REQUIRED_FROM_CONSOLE_DEFAULT, name, DEFAULT_DESC_DEFAULT); } // -------------------------------------------- // @@ -179,7 +163,7 @@ public class ArgSetting return ! this.isRequiredFor(sender); } - public Mson getUseageTemplateDisplayFor(CommandSender sender) + public Mson getTemplate(CommandSender sender) { Mson ret; @@ -198,14 +182,14 @@ public class ArgSetting } // -------------------------------------------- // - // COMMONLY USED ARG SETTINGS + // COMMONLY USED PARAMETERS // -------------------------------------------- // - public static ArgSetting getPage() + public static Parameter getPage() { // We can't use a singletone, because people might // want to set a description. - return new ArgSetting(1, ARInteger.get(), "page", "1"); + return new Parameter(1, TypeInteger.get(), "page", "1"); } } diff --git a/src/com/massivecraft/massivecore/cmd/VisibilityMode.java b/src/com/massivecraft/massivecore/cmd/Visibility.java similarity index 91% rename from src/com/massivecraft/massivecore/cmd/VisibilityMode.java rename to src/com/massivecraft/massivecore/cmd/Visibility.java index 07d48500..9a166363 100644 --- a/src/com/massivecraft/massivecore/cmd/VisibilityMode.java +++ b/src/com/massivecraft/massivecore/cmd/Visibility.java @@ -1,6 +1,6 @@ package com.massivecraft.massivecore.cmd; -public enum VisibilityMode +public enum Visibility { VISIBLE, // Visible commands are visible to anyone. Even those who don't have permission to use it or is of invalid sender type. SECRET, // Secret commands are visible only to those who can use the command. These commands are usually some kind of admin commands. diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCore.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCore.java index 42cf59ba..82df19d6 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCore.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCore.java @@ -27,15 +27,15 @@ public class CmdMassiveCore extends MassiveCommand public CmdMassiveCore() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreUsys); - this.addSubCommand(this.cmdMassiveCoreMStore); - this.addSubCommand(this.cmdMassiveCoreId); - this.addSubCommand(this.cmdMassiveCoreTest); - this.addSubCommand(this.cmdMassiveCoreHearsound); - this.addSubCommand(this.cmdMassiveCoreBuffer); - this.addSubCommand(this.cmdMassiveCoreCmdurl); - this.addSubCommand(this.cmdMassiveCoreVersion); + // Children + this.addChild(this.cmdMassiveCoreUsys); + this.addChild(this.cmdMassiveCoreMStore); + this.addChild(this.cmdMassiveCoreId); + this.addChild(this.cmdMassiveCoreTest); + this.addChild(this.cmdMassiveCoreHearsound); + this.addChild(this.cmdMassiveCoreBuffer); + this.addChild(this.cmdMassiveCoreCmdurl); + this.addChild(this.cmdMassiveCoreVersion); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BASECOMMAND.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBuffer.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBuffer.java index 03626240..b69a1feb 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBuffer.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBuffer.java @@ -22,12 +22,12 @@ public class CmdMassiveCoreBuffer extends MassiveCommand public CmdMassiveCoreBuffer() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreBufferPrint); - this.addSubCommand(this.cmdMassiveCoreBufferClear); - this.addSubCommand(this.cmdMassiveCoreBufferSet); - this.addSubCommand(this.cmdMassiveCoreBufferAdd); - this.addSubCommand(this.cmdMassiveCoreBufferWhitespace); + // Children + this.addChild(this.cmdMassiveCoreBufferPrint); + this.addChild(this.cmdMassiveCoreBufferClear); + this.addChild(this.cmdMassiveCoreBufferSet); + this.addChild(this.cmdMassiveCoreBufferAdd); + this.addChild(this.cmdMassiveCoreBufferWhitespace); // Aliases this.addAliases("buffer"); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java index 1f6b0da6..c0854058 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferAdd.java @@ -4,8 +4,8 @@ import com.massivecraft.massivecore.MassiveCoreEngineVariable; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreBufferAdd extends MassiveCommand { @@ -18,8 +18,8 @@ public class CmdMassiveCoreBufferAdd extends MassiveCommand // Aliases this.addAliases("a", "add"); - // Args - this.addArg(ARString.get(), "text", true).setDesc("the text to add to your buffer"); + // Parameters + this.addParameter(TypeString.get(), "text", true).setDesc("the text to add to your buffer"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_ADD.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java index 293fd66f..551bba97 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferSet.java @@ -4,8 +4,8 @@ import com.massivecraft.massivecore.MassiveCoreEngineVariable; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreBufferSet extends MassiveCommand { @@ -18,8 +18,8 @@ public class CmdMassiveCoreBufferSet extends MassiveCommand // Aliases this.addAliases("s", "set"); - // Args - this.addArg(ARString.get(), "text", true).setDesc("the text to set your buffer to"); + // Parameters + this.addParameter(TypeString.get(), "text", true).setDesc("the text to set your buffer to"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_SET.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java index f65f1158..406aa21f 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreBufferWhitespace.java @@ -4,8 +4,8 @@ import com.massivecraft.massivecore.MassiveCoreEngineVariable; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; 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.type.TypeInteger; import com.massivecraft.massivecore.util.Txt; public class CmdMassiveCoreBufferWhitespace extends MassiveCommand @@ -19,8 +19,8 @@ public class CmdMassiveCoreBufferWhitespace extends MassiveCommand // Aliases this.addAliases("w", "whitespace"); - // Args - this.addArg(1, ARInteger.get(), "times").setDesc("the amount of whitespace to add to your buffer"); + // Parameters + this.addParameter(1, TypeInteger.get(), "times").setDesc("the amount of whitespace to add to your buffer"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.BUFFER_WHITESPACE.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreCmdurl.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreCmdurl.java index 1af3ff89..82dacde0 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreCmdurl.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreCmdurl.java @@ -11,9 +11,9 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.cmd.type.TypeString; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.util.WebUtil; @@ -28,8 +28,8 @@ public class CmdMassiveCoreCmdurl extends MassiveCommand // Aliases this.addAliases("cmdurl"); - // Args - this.addArg(ARString.get(), "url").setDesc("the url to load"); + // Parameters + this.addParameter(TypeString.get(), "url").setDesc("the url to load"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.CMDURL.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java index 38388bec..254da123 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreHearsound.java @@ -6,10 +6,10 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARList; -import com.massivecraft.massivecore.cmd.arg.ARSoundEffect; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; +import com.massivecraft.massivecore.cmd.type.TypeList; +import com.massivecraft.massivecore.cmd.type.TypeSoundEffect; public class CmdMassiveCoreHearsound extends MassiveCommand { @@ -22,8 +22,8 @@ public class CmdMassiveCoreHearsound extends MassiveCommand // Aliases this.addAliases("hearsound", "hearsounds"); - // Args - this.addArg(ARList.get(ARSoundEffect.get()), "sound(s)", true).setDesc("the sounds to hear"); + // Parameters + this.addParameter(TypeList.get(TypeSoundEffect.get()), "sound(s)", true).setDesc("the sounds to hear"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.HEARSOUND.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStore.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStore.java index fc4af537..4909d46b 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStore.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStore.java @@ -20,12 +20,12 @@ public class CmdMassiveCoreStore extends MassiveCommand public CmdMassiveCoreStore() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreStoreStats); - this.addSubCommand(this.cmdMassiveCoreStoreListcolls); - this.addSubCommand(this.cmdMassiveCoreStoreCopydb); + // Children + this.addChild(this.cmdMassiveCoreStoreStats); + this.addChild(this.cmdMassiveCoreStoreListcolls); + this.addChild(this.cmdMassiveCoreStoreCopydb); - // Args + // Parameters this.addAliases("store"); // Requirements diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreCopydb.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreCopydb.java index 2f764b9a..b66d6323 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreCopydb.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreCopydb.java @@ -8,8 +8,8 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeString; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Db; import com.massivecraft.massivecore.store.MStore; @@ -26,9 +26,9 @@ public class CmdMassiveCoreStoreCopydb extends MassiveCommand // Aliases this.addAliases("copydb"); - // Args - this.addArg(ARString.get(), "from").setDesc("the database to copy from"); - this.addArg(ARString.get(), "to").setDesc("the database to copy to"); + // Parameters + this.addParameter(TypeString.get(), "from").setDesc("the database to copy from"); + this.addParameter(TypeString.get(), "to").setDesc("the database to copy to"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_COPYDB.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java index 111cf368..3fc9467a 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreListcolls.java @@ -8,8 +8,8 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.NaturalOrderComparator; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeString; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.Db; import com.massivecraft.massivecore.store.MStore; @@ -26,8 +26,8 @@ public class CmdMassiveCoreStoreListcolls extends MassiveCommand // Aliases this.addAliases("listcolls"); - // Args - this.addArg(ARString.get(), "db", ConfServer.dburi).setDesc("the database to list colls from"); + // Parameters + this.addParameter(TypeString.get(), "db", ConfServer.dburi).setDesc("the database to list colls from"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_LISTCOLLS.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java index 034667b3..06e9814d 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreStoreStats.java @@ -5,8 +5,8 @@ import java.util.Map.Entry; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARColl; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeColl; import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.ExamineThread; import com.massivecraft.massivecore.util.MUtil; @@ -23,8 +23,8 @@ public class CmdMassiveCoreStoreStats extends MassiveCommand // Aliases this.addAliases("stats"); - // Args - this.addArg(ARColl.get(), "coll", Coll.TOTAL).setDesc("the coll to show info about"); + // Parameters + this.addParameter(TypeColl.get(), "coll", Coll.TOTAL).setDesc("the coll to show info about"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.STORE_STATS.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsys.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsys.java index c2c268f4..246a2055 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsys.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsys.java @@ -21,11 +21,11 @@ public class CmdMassiveCoreUsys extends MassiveCommand public CmdMassiveCoreUsys() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreUsysMultiverse); - this.addSubCommand(this.cmdMassiveCoreUsysUniverse); - this.addSubCommand(this.cmdMassiveCoreUsysWorld); - this.addSubCommand(this.cmdMassiveCoreUsysAspect); + // Children + this.addChild(this.cmdMassiveCoreUsysMultiverse); + this.addChild(this.cmdMassiveCoreUsysUniverse); + this.addChild(this.cmdMassiveCoreUsysWorld); + this.addChild(this.cmdMassiveCoreUsysAspect); // Aliases this.addAliases("usys"); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspect.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspect.java index 85a6f61e..d6e1840a 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspect.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspect.java @@ -20,10 +20,10 @@ public class CmdMassiveCoreUsysAspect extends MassiveCommand public CmdMassiveCoreUsysAspect() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreUsysAspectList); - this.addSubCommand(this.cmdMassiveCoreUsysAspectShow); - this.addSubCommand(this.cmdMassiveCoreUsysAspectUse); + // Children + this.addChild(this.cmdMassiveCoreUsysAspectList); + this.addChild(this.cmdMassiveCoreUsysAspectShow); + this.addChild(this.cmdMassiveCoreUsysAspectUse); // Aliases this.addAliases("a", "aspect"); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java index 3c3b7c0a..4252f151 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java @@ -4,7 +4,7 @@ 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.Parameter; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.pager.Pager; @@ -22,8 +22,8 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand // Aliases this.addAliases("l", "list"); - // Args - this.addArg(ArgSetting.getPage()).setDesc("the page in the aspect list"); + // Parameters + this.addParameter(Parameter.getPage()).setDesc("the page in the aspect list"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_LIST.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java index 59b61181..22c26309 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectShow.java @@ -4,8 +4,8 @@ import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARAspect; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeAspect; import com.massivecraft.massivecore.util.Txt; public class CmdMassiveCoreUsysAspectShow extends MassiveCommand @@ -19,8 +19,8 @@ public class CmdMassiveCoreUsysAspectShow extends MassiveCommand // Aliases this.addAliases("s", "show"); - // Args - this.addArg(ARAspect.get(), "aspect").setDesc("the aspect to show info about"); + // Parameters + this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to show info about"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_SHOW.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java index d8de8170..0f282940 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectUse.java @@ -5,9 +5,9 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARAspect; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeAspect; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; public class CmdMassiveCoreUsysAspectUse extends MassiveCommand { @@ -20,9 +20,9 @@ public class CmdMassiveCoreUsysAspectUse extends MassiveCommand // Aliases this.addAliases("u", "use"); - // Args - this.addArg(ARAspect.get(), "aspect").setDesc("the aspect to modify"); - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse which the aspect should use"); + // Parameters + this.addParameter(TypeAspect.get(), "aspect").setDesc("the aspect to modify"); + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse which the aspect should use"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_ASPECT_USE.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverse.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverse.java index 20e72ad8..6a673752 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverse.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverse.java @@ -21,11 +21,11 @@ public class CmdMassiveCoreUsysMultiverse extends MassiveCommand public CmdMassiveCoreUsysMultiverse() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreUsysMultiverseList); - this.addSubCommand(this.cmdMassiveCoreUsysMultiverseShow); - this.addSubCommand(this.cmdMassiveCoreUsysMultiverseNew); - this.addSubCommand(this.cmdMassiveCoreUsysMultiverseDel); + // Children + this.addChild(this.cmdMassiveCoreUsysMultiverseList); + this.addChild(this.cmdMassiveCoreUsysMultiverseShow); + this.addChild(this.cmdMassiveCoreUsysMultiverseNew); + this.addChild(this.cmdMassiveCoreUsysMultiverseDel); // Aliases this.addAliases("m", "multiverse"); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java index 4b18fb97..ad799d9e 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseDel.java @@ -5,8 +5,8 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand { @@ -19,8 +19,8 @@ public class CmdMassiveCoreUsysMultiverseDel extends MassiveCommand // Aliases this.addAliases("d", "del"); - // Args - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse to delete"); + // Parameters + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to delete"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java index a733ef3e..667c13fe 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java @@ -4,7 +4,7 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.MultiverseColl; -import com.massivecraft.massivecore.cmd.ArgSetting; +import com.massivecraft.massivecore.cmd.Parameter; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.pager.Pager; @@ -22,8 +22,8 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand // Aliases this.addAliases("l", "list"); - // Args - this.addArg(ArgSetting.getPage()); + // Parameters + this.addParameter(Parameter.getPage()); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_LIST.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseNew.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseNew.java index 27da2794..fba71f40 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseNew.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseNew.java @@ -4,8 +4,8 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MultiverseColl; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand { @@ -18,8 +18,8 @@ public class CmdMassiveCoreUsysMultiverseNew extends MassiveCommand // Aliases this.addAliases("n", "new"); - // Args - this.addArg(ARString.get(), "multiverse").setDesc("name of multiverse to create"); + // Parameters + this.addParameter(TypeString.get(), "multiverse").setDesc("name of multiverse to create"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_NEW.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java index 04f91728..ae29bc77 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseShow.java @@ -9,8 +9,8 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; import com.massivecraft.massivecore.util.Txt; public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand @@ -24,8 +24,8 @@ public class CmdMassiveCoreUsysMultiverseShow extends MassiveCommand // Aliases this.addAliases("s", "show"); - // Args - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse to show info about"); + // Parameters + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse to show info about"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_SHOW.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverse.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverse.java index a28b6dc4..71266e9b 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverse.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverse.java @@ -20,10 +20,10 @@ public class CmdMassiveCoreUsysUniverse extends MassiveCommand public CmdMassiveCoreUsysUniverse() { - // SubCommands - this.addSubCommand(this.cmdMassiveCoreUsysUniverseNew); - this.addSubCommand(this.cmdMassiveCoreUsysUniverseDel); - this.addSubCommand(this.cmdMassiveCoreUsysUniverseClear); + // Children + this.addChild(this.cmdMassiveCoreUsysUniverseNew); + this.addChild(this.cmdMassiveCoreUsysUniverseDel); + this.addChild(this.cmdMassiveCoreUsysUniverseClear); // Aliases this.addAliases("u", "universe"); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java index 037a1d8a..ca071856 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseClear.java @@ -5,9 +5,9 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand { @@ -20,9 +20,9 @@ public class CmdMassiveCoreUsysUniverseClear extends MassiveCommand // Aliases this.addAliases("c", "clear"); - // Args - this.addArg(ARString.get(), "universe").setDesc("the universe to clear"); - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to clear"); + // Parameters + this.addParameter(TypeString.get(), "universe").setDesc("the universe to clear"); + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to clear"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_CLEAR.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java index f4346829..8b13f6f6 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseDel.java @@ -5,9 +5,9 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand { @@ -20,9 +20,9 @@ public class CmdMassiveCoreUsysUniverseDel extends MassiveCommand // Aliases this.addAliases("d", "del"); - // Args - this.addArg(ARString.get(), "universe").setDesc("the universe to delete"); - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to delete"); + // Parameters + this.addParameter(TypeString.get(), "universe").setDesc("the universe to delete"); + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to delete"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_MULTIVERSE_DEL.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java index 8575bdea..7a0172e6 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysUniverseNew.java @@ -4,9 +4,9 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand { @@ -19,9 +19,9 @@ public class CmdMassiveCoreUsysUniverseNew extends MassiveCommand // Aliases this.addAliases("n", "new"); - // Args - this.addArg(ARString.get(), "universe").setDesc("name of universe to create"); - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to create"); + // Parameters + this.addParameter(TypeString.get(), "universe").setDesc("name of universe to create"); + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to create"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_UNIVERSE_NEW.node)); diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java index e8c256a0..e2700285 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysWorld.java @@ -4,9 +4,9 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.arg.ARMultiverse; -import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.cmd.type.TypeMultiverse; +import com.massivecraft.massivecore.cmd.type.TypeString; public class CmdMassiveCoreUsysWorld extends MassiveCommand { @@ -19,10 +19,10 @@ public class CmdMassiveCoreUsysWorld extends MassiveCommand // Aliases this.addAliases("w", "world"); - // Args - this.addArg(ARString.get(), "world").setDesc("the world to move"); - this.addArg(ARString.get(), "universe").setDesc("the universe to move the world ro"); - this.addArg(ARMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to move the world to"); + // Parameters + this.addParameter(TypeString.get(), "world").setDesc("the world to move"); + this.addParameter(TypeString.get(), "universe").setDesc("the universe to move the world ro"); + this.addParameter(TypeMultiverse.get(), "multiverse").setDesc("the multiverse of the universe to move the world to"); // Requirements this.addRequirements(ReqHasPerm.get(MassiveCorePerm.USYS_WORLD.node)); diff --git a/src/com/massivecraft/massivecore/cmd/req/Req.java b/src/com/massivecraft/massivecore/cmd/req/Req.java index c8002e87..5cbf2986 100644 --- a/src/com/massivecraft/massivecore/cmd/req/Req.java +++ b/src/com/massivecraft/massivecore/cmd/req/Req.java @@ -2,10 +2,10 @@ package com.massivecraft.massivecore.cmd.req; import org.bukkit.command.CommandSender; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.cmd.MassiveCommand; -public interface Req extends Predictate +public interface Req extends Predicate { public boolean apply(CommandSender sender, MassiveCommand command); diff --git a/src/com/massivecraft/massivecore/cmd/arg/AR.java b/src/com/massivecraft/massivecore/cmd/type/Type.java similarity index 88% rename from src/com/massivecraft/massivecore/cmd/arg/AR.java rename to src/com/massivecraft/massivecore/cmd/type/Type.java index 814ea48b..02b03c9d 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/AR.java +++ b/src/com/massivecraft/massivecore/cmd/type/Type.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.List; @@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; -public interface AR +public interface Type { // Human friendly name public String getTypeName(); @@ -28,7 +28,7 @@ public interface AR public List getTabListFiltered(CommandSender sender, String arg); // Sometimes we put a space after a tab completion. - // That would however not make sense with all ArgReaders. + // That would however not make sense with all Types. // Default is true; public boolean allowSpaceAfterTab(); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java b/src/com/massivecraft/massivecore/cmd/type/TypeAbstract.java similarity index 97% rename from src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAbstract.java index f0faebe3..3c8b9966 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstract.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAbstract.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Collection; @@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.util.Txt; -public abstract class ARAbstract implements AR +public abstract class TypeAbstract implements Type { // -------------------------------------------- // // OVERRIDE: READ @@ -61,10 +61,10 @@ public abstract class ARAbstract implements AR @Override public String getTypeName() { - int prefixLength = "AR".length(); + int prefixLength = "Type".length(); String name = this.getClass().getSimpleName(); - // We don't want the "AR" part + // We don't want the "Type" part name = name.substring(prefixLength); // We split at uppercase letters, because most class names are camel-case. diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractException.java b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractException.java similarity index 89% rename from src/com/massivecraft/massivecore/cmd/arg/ARAbstractException.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAbstractException.java index c4701e78..1d8b5a80 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractException.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractException.java @@ -1,11 +1,11 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.util.Txt; -public abstract class ARAbstractException extends ARAbstract +public abstract class TypeAbstractException extends TypeAbstract { // -------------------------------------------- // // ABSTRACT diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractNumber.java b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractNumber.java similarity index 80% rename from src/com/massivecraft/massivecore/cmd/arg/ARAbstractNumber.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAbstractNumber.java index 28768c2c..889f51d0 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractNumber.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractNumber.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; @@ -6,7 +6,7 @@ import java.util.List; import org.bukkit.command.CommandSender; -public abstract class ARAbstractNumber extends ARAbstractPrimitive +public abstract class TypeAbstractNumber extends TypeAbstractPrimitive { // -------------------------------------------- // // CONSTANTS diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractPrimitive.java similarity index 72% rename from src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAbstractPrimitive.java index 2ec90181..86a7e23c 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractPrimitive.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractPrimitive.java @@ -1,10 +1,10 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.Txt; -public abstract class ARAbstractPrimitive extends ARAbstractException +public abstract class TypeAbstractPrimitive extends TypeAbstractException { // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractSelect.java similarity index 93% rename from src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAbstractSelect.java index 44574783..1521b642 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAbstractSelect.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAbstractSelect.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Collection; @@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.util.Txt; -public abstract class ARAbstractSelect extends ARAbstract +public abstract class TypeAbstractSelect extends TypeAbstract { // -------------------------------------------- // // CONSTANT diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAll.java b/src/com/massivecraft/massivecore/cmd/type/TypeAll.java similarity index 51% rename from src/com/massivecraft/massivecore/cmd/arg/ARAll.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAll.java index fbbf379c..d56fd5b2 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAll.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAll.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; @@ -7,41 +7,41 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; -public final class ARAll +public final class TypeAll { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // @SuppressWarnings("unchecked") - public static AR> get(AR inner) + public static Type> get(Type inner) { - if (inner instanceof ARCollection) return new ARAllCollection((ARCollection>) inner); - if (inner instanceof ARAllAble) return new ARAllDefault((ARAllAble) inner); - throw new IllegalArgumentException("innerArgReader must be an instance of either ARCollection or ARAllAble"); + if (inner instanceof TypeCollection) return new TypeAllCollection((TypeCollection>) inner); + if (inner instanceof TypeAllAble) return new TypeAllDefault((TypeAllAble) inner); + throw new IllegalArgumentException("innerType must be an instance of either TypeCollection or TypeAllAble"); } // -------------------------------------------- // // AR ALL DEFAULT // -------------------------------------------- // - private static class ARAllDefault extends ARWrapper> + private static class TypeAllDefault extends TypeWrapper> { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected ARAllAble innerArgReader; - @Override public ARAllAble getInnerArgReader() { return this.innerArgReader; } + protected TypeAllAble innerType; + @Override public TypeAllAble getInnerType() { return this.innerType; } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public ARAllDefault(ARAllAble inner) + public TypeAllDefault(TypeAllAble inner) { - if (inner == null) throw new IllegalArgumentException("innerArgReader musn't be null"); - this.innerArgReader = inner; + if (inner == null) throw new IllegalArgumentException("innerType musn't be null"); + this.innerType = inner; } // -------------------------------------------- // @@ -51,16 +51,16 @@ public final class ARAll @Override public Collection read(String arg, CommandSender sender) throws MassiveException { - if ("all".equalsIgnoreCase(arg)) return getInnerArgReader().getAll(sender); + if ("all".equalsIgnoreCase(arg)) return getInnerType().getAll(sender); - T innerRet = getInnerArgReader().read(arg, sender); + T innerRet = getInnerType().read(arg, sender); return Collections.singletonList(innerRet); } @Override public boolean isValid(String arg, CommandSender sender) { - return "all".equalsIgnoreCase(arg) || this.getInnerArgReader().isValid(arg, sender); + return "all".equalsIgnoreCase(arg) || this.getInnerType().isValid(arg, sender); } } @@ -69,24 +69,24 @@ public final class ARAll // AR ALL COLLECTION // -------------------------------------------- // - private static class ARAllCollection extends ARWrapper> + private static class TypeAllCollection extends TypeWrapper> { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected ARCollection> innerArgReader; - @Override public ARCollection> getInnerArgReader() { return this.innerArgReader; } + protected TypeCollection> innerType; + @Override public TypeCollection> getInnerType() { return this.innerType; } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public ARAllCollection(ARCollection> inner) + public TypeAllCollection(TypeCollection> inner) { - if (inner == null) throw new IllegalArgumentException("innerArgReader musn't be null"); - if ( !(inner.getInnerArgReader() instanceof ARAllAble)) throw new IllegalArgumentException("innerArgReaders innerArgReader must implement ARAllAble"); - this.innerArgReader = inner; + if (inner == null) throw new IllegalArgumentException("innerType musn't be null"); + if ( !(inner.getInnerType() instanceof TypeAllAble)) throw new IllegalArgumentException("innerType must implement ARAllAble"); + this.innerType = inner; } // -------------------------------------------- // @@ -99,17 +99,17 @@ public final class ARAll if ("all".equalsIgnoreCase(arg)) { @SuppressWarnings("unchecked") - ARAllAble innersInner = (ARAllAble) getInnerArgReader().getInnerArgReader(); + TypeAllAble innersInner = (TypeAllAble) getInnerType().getInnerType(); return innersInner.getAll(sender); } - return getInnerArgReader().read(arg, sender); + return getInnerType().read(arg, sender); } @Override public boolean isValid(String arg, CommandSender sender) { - return "all".equalsIgnoreCase(arg) || this.getInnerArgReader().isValid(arg, sender); + return "all".equalsIgnoreCase(arg) || this.getInnerType().isValid(arg, sender); } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAllAble.java b/src/com/massivecraft/massivecore/cmd/type/TypeAllAble.java similarity index 57% rename from src/com/massivecraft/massivecore/cmd/arg/ARAllAble.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAllAble.java index b9b381a9..cbc74350 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAllAble.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAllAble.java @@ -1,10 +1,10 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import org.bukkit.command.CommandSender; -public interface ARAllAble extends AR +public interface TypeAllAble extends Type { public Collection getAll(CommandSender sender); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARAspect.java b/src/com/massivecraft/massivecore/cmd/type/TypeAspect.java similarity index 79% rename from src/com/massivecraft/massivecore/cmd/arg/ARAspect.java rename to src/com/massivecraft/massivecore/cmd/type/TypeAspect.java index d5f3397e..cc664991 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARAspect.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeAspect.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; @@ -8,14 +8,14 @@ import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.AspectColl; import com.massivecraft.massivecore.MassiveCorePerm; -public class ARAspect extends ARAbstractSelect +public class TypeAspect extends TypeAbstractSelect { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARAspect i = new ARAspect(); - public static ARAspect get() { return i; } + private static TypeAspect i = new TypeAspect(); + public static TypeAspect get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARBiome.java b/src/com/massivecraft/massivecore/cmd/type/TypeBiome.java similarity index 85% rename from src/com/massivecraft/massivecore/cmd/arg/ARBiome.java rename to src/com/massivecraft/massivecore/cmd/type/TypeBiome.java index ba348a84..b5612d82 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARBiome.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeBiome.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Arrays; @@ -8,14 +8,14 @@ import java.util.List; import org.bukkit.block.Biome; import org.bukkit.command.CommandSender; -public class ARBiome extends ARAbstractSelect implements ARAllAble +public class TypeBiome extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARBiome i = new ARBiome(); - public static ARBiome get() { return i; } + private static TypeBiome i = new TypeBiome(); + public static TypeBiome get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARBoolean.java b/src/com/massivecraft/massivecore/cmd/type/TypeBoolean.java similarity index 85% rename from src/com/massivecraft/massivecore/cmd/arg/ARBoolean.java rename to src/com/massivecraft/massivecore/cmd/type/TypeBoolean.java index 7c3729eb..8d7644ec 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARBoolean.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeBoolean.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Collection; @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.MUtil; -public class ARBoolean extends ARAbstractPrimitive +public class TypeBoolean extends TypeAbstractPrimitive { // -------------------------------------------- // // CONSTANTS @@ -29,8 +29,8 @@ public class ARBoolean extends ARAbstractPrimitive // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARBoolean i = new ARBoolean(); - public static ARBoolean get() { return i; } + private static TypeBoolean i = new TypeBoolean(); + public static TypeBoolean get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARByte.java b/src/com/massivecraft/massivecore/cmd/type/TypeByte.java similarity index 69% rename from src/com/massivecraft/massivecore/cmd/arg/ARByte.java rename to src/com/massivecraft/massivecore/cmd/type/TypeByte.java index faee4b7d..9c7bbc2d 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARByte.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeByte.java @@ -1,15 +1,15 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; -public class ARByte extends ARAbstractNumber +public class TypeByte extends TypeAbstractNumber { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARByte i = new ARByte(); - public static ARByte get() { return i; } + private static TypeByte i = new TypeByte(); + public static TypeByte get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARChatColor.java b/src/com/massivecraft/massivecore/cmd/type/TypeChatColor.java similarity index 83% rename from src/com/massivecraft/massivecore/cmd/arg/ARChatColor.java rename to src/com/massivecraft/massivecore/cmd/type/TypeChatColor.java index 8580a23c..e7f5aa6e 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARChatColor.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeChatColor.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Arrays; @@ -8,14 +8,14 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; -public class ARChatColor extends ARAbstractSelect implements ARAllAble +public class TypeChatColor extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARChatColor i = new ARChatColor(); - public static ARChatColor get() { return i; } + private static TypeChatColor i = new TypeChatColor(); + public static TypeChatColor get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARColl.java b/src/com/massivecraft/massivecore/cmd/type/TypeColl.java similarity index 75% rename from src/com/massivecraft/massivecore/cmd/arg/ARColl.java rename to src/com/massivecraft/massivecore/cmd/type/TypeColl.java index 049f0504..288970a8 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARColl.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeColl.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; @@ -6,14 +6,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.store.Coll; -public class ARColl extends ARAbstractSelect> implements ARAllAble> +public class TypeColl extends TypeAbstractSelect> implements TypeAllAble> { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARColl i = new ARColl(); - public static ARColl get() { return i; } + private static TypeColl i = new TypeColl(); + public static TypeColl get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARCollection.java b/src/com/massivecraft/massivecore/cmd/type/TypeCollection.java similarity index 75% rename from src/com/massivecraft/massivecore/cmd/arg/ARCollection.java rename to src/com/massivecraft/massivecore/cmd/type/TypeCollection.java index da81498e..2510c121 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARCollection.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeCollection.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.List; @@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.Txt; -public abstract class ARCollection> extends ARWrapper +public abstract class TypeCollection> extends TypeWrapper { // -------------------------------------------- // // OVERRIDE @@ -18,7 +18,7 @@ public abstract class ARCollection> extends ARWrapper { // Because we accept multiple arguments of the same type. // The passed arg might be more than one. We only want the latest. - return this.getInnerArgReader().getTabList(sender, getLastArg(arg)); + return this.getInnerType().getTabList(sender, getLastArg(arg)); } @Override @@ -26,7 +26,7 @@ public abstract class ARCollection> extends ARWrapper { // Because we accept multiple arguments of the same type. // The passed arg might be more than one. We only want the latest. - return this.getInnerArgReader().getTabListFiltered(sender, getLastArg(arg)); + return this.getInnerType().getTabListFiltered(sender, getLastArg(arg)); } public static String getLastArg(String str) diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARCombined.java b/src/com/massivecraft/massivecore/cmd/type/TypeCombined.java similarity index 69% rename from src/com/massivecraft/massivecore/cmd/arg/ARCombined.java rename to src/com/massivecraft/massivecore/cmd/type/TypeCombined.java index 6029ebed..189b2d94 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARCombined.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeCombined.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -9,27 +9,27 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; -public class ARCombined extends ARAbstract> +public class TypeCombined extends TypeAbstract> { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected List> inners; - public List> getInners() { return this.inners; } + protected List> inners; + public List> getInners() { return this.inners; } // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static ARCombined get(Collection> inners) { return new ARCombined(inners); } - public static ARCombined get(AR... inners) { return new ARCombined(inners); } + public static TypeCombined get(Collection> inners) { return new TypeCombined(inners); } + public static TypeCombined get(Type... inners) { return new TypeCombined(inners); } - public ARCombined(Collection> inners) + public TypeCombined(Collection> inners) { - this.inners = new MassiveList>(inners); + this.inners = new MassiveList>(inners); } - public ARCombined(AR... inners) + public TypeCombined(Type... inners) { this(Arrays.asList(inners)); } @@ -62,9 +62,9 @@ public class ARCombined extends ARAbstract> for (int i = 0; i < parts.size(); i++) { String part = parts.get(i); - AR argReader = this.getInners().get(i); + Type type = this.getInners().get(i); - Object asdf = argReader.read(part, sender); + Object asdf = type.read(part, sender); ret.add(asdf); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARDate.java b/src/com/massivecraft/massivecore/cmd/type/TypeDate.java similarity index 80% rename from src/com/massivecraft/massivecore/cmd/arg/ARDate.java rename to src/com/massivecraft/massivecore/cmd/type/TypeDate.java index 9f990a9b..6f9cb98d 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARDate.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeDate.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -8,7 +8,7 @@ import java.util.Date; import org.bukkit.command.CommandSender; -public class ARDate extends ARAbstractPrimitive +public class TypeDate extends TypeAbstractPrimitive { // -------------------------------------------- // // CONSTANTS @@ -20,8 +20,8 @@ public class ARDate extends ARAbstractPrimitive // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARDate i = new ARDate(); - public static ARDate get() { return i; } + private static TypeDate i = new TypeDate(); + public static TypeDate get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java b/src/com/massivecraft/massivecore/cmd/type/TypeDestination.java similarity index 86% rename from src/com/massivecraft/massivecore/cmd/arg/ARDestination.java rename to src/com/massivecraft/massivecore/cmd/type/TypeDestination.java index 9525b710..142c4a51 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARDestination.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeDestination.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; @@ -9,14 +9,14 @@ import com.massivecraft.massivecore.event.EventMassiveCoreDestination; import com.massivecraft.massivecore.event.EventMassiveCoreDestinationTabList; import com.massivecraft.massivecore.teleport.Destination; -public class ARDestination extends ARAbstract +public class TypeDestination extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARDestination i = new ARDestination(); - public static ARDestination get() { return i; } + private static TypeDestination i = new TypeDestination(); + public static TypeDestination get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARDifficulty.java b/src/com/massivecraft/massivecore/cmd/type/TypeDifficulty.java similarity index 81% rename from src/com/massivecraft/massivecore/cmd/arg/ARDifficulty.java rename to src/com/massivecraft/massivecore/cmd/type/TypeDifficulty.java index 166fc81c..6b06c53a 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARDifficulty.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeDifficulty.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.MUtil; -public class ARDifficulty extends ARAbstractSelect implements ARAllAble +public class TypeDifficulty extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // CONSTANTS @@ -22,8 +22,8 @@ public class ARDifficulty extends ARAbstractSelect implements ARAllA // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARDifficulty i = new ARDifficulty(); - public static ARDifficulty get() { return i; } + private static TypeDifficulty i = new TypeDifficulty(); + public static TypeDifficulty get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARDouble.java b/src/com/massivecraft/massivecore/cmd/type/TypeDouble.java similarity index 68% rename from src/com/massivecraft/massivecore/cmd/arg/ARDouble.java rename to src/com/massivecraft/massivecore/cmd/type/TypeDouble.java index 81c7d412..46df719f 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARDouble.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeDouble.java @@ -1,15 +1,15 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; -public class ARDouble extends ARAbstractNumber +public class TypeDouble extends TypeAbstractNumber { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARDouble i = new ARDouble(); - public static ARDouble get() { return i; } + private static TypeDouble i = new TypeDouble(); + public static TypeDouble get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/AREntityType.java b/src/com/massivecraft/massivecore/cmd/type/TypeEntityType.java similarity index 84% rename from src/com/massivecraft/massivecore/cmd/arg/AREntityType.java rename to src/com/massivecraft/massivecore/cmd/type/TypeEntityType.java index fbd3f843..144a8ca1 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/AREntityType.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeEntityType.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Arrays; @@ -8,14 +8,14 @@ import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; -public class AREntityType extends ARAbstractSelect implements ARAllAble +public class TypeEntityType extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static AREntityType i = new AREntityType(); - public static AREntityType get() { return i; } + private static TypeEntityType i = new TypeEntityType(); + public static TypeEntityType get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/AREnum.java b/src/com/massivecraft/massivecore/cmd/type/TypeEnum.java similarity index 87% rename from src/com/massivecraft/massivecore/cmd/arg/AREnum.java rename to src/com/massivecraft/massivecore/cmd/type/TypeEnum.java index 0f6e7664..f0dd21a0 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/AREnum.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeEnum.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Arrays; @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.Txt; -public class AREnum extends ARAbstractSelect implements ARAllAble +public class TypeEnum extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // FIELD @@ -21,12 +21,12 @@ public class AREnum extends ARAbstractSelect implements ARAllAble // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static AREnum get(Class clazz) + public static TypeEnum get(Class clazz) { - return new AREnum(clazz); + return new TypeEnum(clazz); } - public AREnum(Class clazz) + public TypeEnum(Class clazz) { if ( ! clazz.isEnum()) throw new IllegalArgumentException("passed clazz param must be an enum"); this.clazz = clazz; diff --git a/src/com/massivecraft/massivecore/cmd/arg/AREnvironment.java b/src/com/massivecraft/massivecore/cmd/type/TypeEnvironment.java similarity index 84% rename from src/com/massivecraft/massivecore/cmd/arg/AREnvironment.java rename to src/com/massivecraft/massivecore/cmd/type/TypeEnvironment.java index 4d6d75a0..ae97cf81 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/AREnvironment.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeEnvironment.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.MUtil; -public class AREnvironment extends ARAbstractSelect implements ARAllAble +public class TypeEnvironment extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // CONSTANTS @@ -23,8 +23,8 @@ public class AREnvironment extends ARAbstractSelect implements ARAl // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static AREnvironment i = new AREnvironment(); - public static AREnvironment get() { return i; } + private static TypeEnvironment i = new TypeEnvironment(); + public static TypeEnvironment get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARFloat.java b/src/com/massivecraft/massivecore/cmd/type/TypeFloat.java similarity index 68% rename from src/com/massivecraft/massivecore/cmd/arg/ARFloat.java rename to src/com/massivecraft/massivecore/cmd/type/TypeFloat.java index ccd5ae91..120cfc45 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARFloat.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeFloat.java @@ -1,15 +1,15 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; -public class ARFloat extends ARAbstractNumber +public class TypeFloat extends TypeAbstractNumber { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARFloat i = new ARFloat(); - public static ARFloat get() { return i; } + private static TypeFloat i = new TypeFloat(); + public static TypeFloat get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARGameMode.java b/src/com/massivecraft/massivecore/cmd/type/TypeGameMode.java similarity index 84% rename from src/com/massivecraft/massivecore/cmd/arg/ARGameMode.java rename to src/com/massivecraft/massivecore/cmd/type/TypeGameMode.java index 8ca87f1d..6f05c894 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARGameMode.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeGameMode.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Arrays; @@ -10,14 +10,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.Txt; -public class ARGameMode extends ARAbstractSelect implements ARAllAble +public class TypeGameMode extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARGameMode i = new ARGameMode(); - public static ARGameMode get() { return i; } + private static TypeGameMode i = new TypeGameMode(); + public static TypeGameMode get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARInteger.java b/src/com/massivecraft/massivecore/cmd/type/TypeInteger.java similarity index 67% rename from src/com/massivecraft/massivecore/cmd/arg/ARInteger.java rename to src/com/massivecraft/massivecore/cmd/type/TypeInteger.java index c5fa1ac1..9f8120c8 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARInteger.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeInteger.java @@ -1,15 +1,15 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; -public class ARInteger extends ARAbstractNumber +public class TypeInteger extends TypeAbstractNumber { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARInteger i = new ARInteger(); - public static ARInteger get() { return i; } + private static TypeInteger i = new TypeInteger(); + public static TypeInteger get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARList.java b/src/com/massivecraft/massivecore/cmd/type/TypeList.java similarity index 63% rename from src/com/massivecraft/massivecore/cmd/arg/ARList.java rename to src/com/massivecraft/massivecore/cmd/type/TypeList.java index b7b7244e..447f7f16 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARList.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeList.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.List; @@ -8,28 +8,28 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.util.Txt; -public class ARList extends ARCollection> +public class TypeList extends TypeCollection> { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected AR elementArgReader; - public AR getElementArgReader() { return this.elementArgReader; } - @Override public AR getInnerArgReader() { return this.getElementArgReader(); } + protected Type elementType; + public Type getElementType() { return this.elementType; } + @Override public Type getInnerType() { return this.getElementType(); } // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static ARList get(AR elementArgReader) + public static TypeList get(Type elementType) { - return new ARList(elementArgReader); + return new TypeList(elementType); } - public ARList(AR elementArgReader) + public TypeList(Type elementType) { - this.elementArgReader = elementArgReader; + this.elementType = elementType; } // -------------------------------------------- // @@ -49,7 +49,7 @@ public class ARList extends ARCollection> // For Each for (String elementArg : elementArgs) { - E element = this.getElementArgReader().read(elementArg, sender); + E element = this.getElementType().read(elementArg, sender); ret.add(element); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARLong.java b/src/com/massivecraft/massivecore/cmd/type/TypeLong.java similarity index 68% rename from src/com/massivecraft/massivecore/cmd/arg/ARLong.java rename to src/com/massivecraft/massivecore/cmd/type/TypeLong.java index ffeb0d2c..b7e2299b 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARLong.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeLong.java @@ -1,15 +1,15 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; -public class ARLong extends ARAbstractNumber +public class TypeLong extends TypeAbstractNumber { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARLong i = new ARLong(); - public static ARLong get() { return i; } + private static TypeLong i = new TypeLong(); + public static TypeLong get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java b/src/com/massivecraft/massivecore/cmd/type/TypeMaterial.java similarity index 81% rename from src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java rename to src/com/massivecraft/massivecore/cmd/type/TypeMaterial.java index bad1a94f..80623ae9 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARMaterial.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeMaterial.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -10,14 +10,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; -public class ARMaterial extends ARAbstract implements ARAllAble +public class TypeMaterial extends TypeAbstract implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARMaterial i = new ARMaterial(); - public static ARMaterial get() { return i; } + private static TypeMaterial i = new TypeMaterial(); + public static TypeMaterial get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java b/src/com/massivecraft/massivecore/cmd/type/TypeMillisDiff.java similarity index 73% rename from src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java rename to src/com/massivecraft/massivecore/cmd/type/TypeMillisDiff.java index 68ad595a..ba8f0314 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARMillisDiff.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeMillisDiff.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; @@ -7,14 +7,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.TimeDiffUtil; -public class ARMillisDiff extends ARAbstractException +public class TypeMillisDiff extends TypeAbstractException { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARMillisDiff i = new ARMillisDiff(); - public static ARMillisDiff get() { return i; } + private static TypeMillisDiff i = new TypeMillisDiff(); + public static TypeMillisDiff get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARMultiverse.java b/src/com/massivecraft/massivecore/cmd/type/TypeMultiverse.java similarity index 78% rename from src/com/massivecraft/massivecore/cmd/arg/ARMultiverse.java rename to src/com/massivecraft/massivecore/cmd/type/TypeMultiverse.java index b44e7fce..4cc5b921 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARMultiverse.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeMultiverse.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; @@ -8,14 +8,14 @@ import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.MultiverseColl; -public class ARMultiverse extends ARAbstractSelect +public class TypeMultiverse extends TypeAbstractSelect { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARMultiverse i = new ARMultiverse(); - public static ARMultiverse get() { return i; } + private static TypeMultiverse i = new TypeMultiverse(); + public static TypeMultiverse get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARNullable.java b/src/com/massivecraft/massivecore/cmd/type/TypeNullable.java similarity index 64% rename from src/com/massivecraft/massivecore/cmd/arg/ARNullable.java rename to src/com/massivecraft/massivecore/cmd/type/TypeNullable.java index 8e753378..24092a35 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARNullable.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeNullable.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -11,14 +11,14 @@ import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; -public class ARNullable extends ARAbstract +public class TypeNullable extends TypeAbstract { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected AR innerArgReader; - public AR getInnerArgReader() { return this.innerArgReader; } + protected Type innerType; + public Type getInnerType() { return this.innerType; } protected Collection nulls; public Collection getNulls() { return this.nulls; } @@ -27,40 +27,40 @@ public class ARNullable extends ARAbstract // INSTANCE // -------------------------------------------- // - public static ARNullable get(AR inner, Collection nulls) + public static TypeNullable get(Type inner, Collection nulls) { - return new ARNullable(inner, nulls); + return new TypeNullable(inner, nulls); } - public static ARNullable get(AR inner, String... nulls) + public static TypeNullable get(Type inner, String... nulls) { - return new ARNullable(inner, nulls); + return new TypeNullable(inner, nulls); } - public static ARNullable get(AR inner) + public static TypeNullable get(Type inner) { - return new ARNullable(inner); + return new TypeNullable(inner); } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public ARNullable(AR inner, Collection nulls) + public TypeNullable(Type inner, Collection nulls) { if (inner == null) throw new NullPointerException("inner"); if (nulls == null) nulls = Collections.emptySet(); - this.innerArgReader = inner; + this.innerType = inner; this.nulls = nulls; } - public ARNullable(AR inner, String... nulls) + public TypeNullable(Type inner, String... nulls) { this(inner, Arrays.asList(nulls)); } - public ARNullable(AR inner) + public TypeNullable(Type inner) { this(inner, MassiveCore.NOTHING_REMOVE); } @@ -72,7 +72,7 @@ public class ARNullable extends ARAbstract @Override public String getTypeName() { - return this.getInnerArgReader().getTypeName(); + return this.getInnerType().getTypeName(); } @Override @@ -82,7 +82,7 @@ public class ARNullable extends ARAbstract if (this.getNulls().contains(arg)) return null; // Inner - return this.getInnerArgReader().read(arg, sender); + return this.getInnerType().read(arg, sender); } @Override @@ -92,7 +92,7 @@ public class ARNullable extends ARAbstract List ret = new MassiveList(this.getNulls()); // Fill Ret - ret.addAll(this.getInnerArgReader().getTabList(sender, arg)); + ret.addAll(this.getInnerType().getTabList(sender, arg)); // Return Ret return ret; @@ -101,7 +101,7 @@ public class ARNullable extends ARAbstract @Override public boolean allowSpaceAfterTab() { - return this.getInnerArgReader().allowSpaceAfterTab(); + return this.getInnerType().allowSpaceAfterTab(); } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPS.java b/src/com/massivecraft/massivecore/cmd/type/TypePS.java similarity index 73% rename from src/com/massivecraft/massivecore/cmd/arg/ARPS.java rename to src/com/massivecraft/massivecore/cmd/type/TypePS.java index fecf3608..1dc22e03 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPS.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypePS.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -12,14 +12,14 @@ import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PSBuilder; -public class ARPS extends ARAbstract +public class TypePS extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARPS i = new ARPS(); - public static ARPS get() { return i; } + private static TypePS i = new TypePS(); + public static TypePS get() { return i; } // -------------------------------------------- // // OVERRIDE @@ -51,10 +51,10 @@ public class ARPS extends ARAbstract { try { - String world = ARWorldId.get().read(parts.get(0), sender); - double locationX = ARDouble.get().read(parts.get(1), sender); - double locationY = ARDouble.get().read(parts.get(2), sender); - double locationZ = ARDouble.get().read(parts.get(3), sender); + String world = TypeWorldId.get().read(parts.get(0), sender); + double locationX = TypeDouble.get().read(parts.get(1), sender); + double locationY = TypeDouble.get().read(parts.get(2), sender); + double locationZ = TypeDouble.get().read(parts.get(3), sender); return new PSBuilder(senderPs).world(world).locationX(locationX).locationY(locationY).locationZ(locationZ).build(); } catch (Exception e) @@ -64,10 +64,10 @@ public class ARPS extends ARAbstract try { - double locationX = ARDouble.get().read(parts.get(0), sender); - double locationY = ARDouble.get().read(parts.get(1), sender); - double locationZ = ARDouble.get().read(parts.get(2), sender); - String world = ARWorldId.get().read(parts.get(3), sender); + double locationX = TypeDouble.get().read(parts.get(0), sender); + double locationY = TypeDouble.get().read(parts.get(1), sender); + double locationZ = TypeDouble.get().read(parts.get(2), sender); + String world = TypeWorldId.get().read(parts.get(3), sender); return new PSBuilder(senderPs).world(world).locationX(locationX).locationY(locationY).locationZ(locationZ).build(); } catch (Exception e) @@ -79,9 +79,9 @@ public class ARPS extends ARAbstract { try { - double locationX = ARDouble.get().read(parts.get(0), sender); - double locationY = ARDouble.get().read(parts.get(1), sender); - double locationZ = ARDouble.get().read(parts.get(2), sender); + double locationX = TypeDouble.get().read(parts.get(0), sender); + double locationY = TypeDouble.get().read(parts.get(1), sender); + double locationZ = TypeDouble.get().read(parts.get(2), sender); return new PSBuilder(senderPs).locationX(locationX).locationY(locationY).locationZ(locationZ).build(); } catch (Exception e) @@ -100,98 +100,98 @@ public class ARPS extends ARAbstract value = getValue(part, PS.NAME_SERIALIZED_WORLD, PS.NAME_FULL_WORLD); if (value != null) { - ret.world(ARWorldId.get().read(value, sender)); + ret.world(TypeWorldId.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_BLOCKX, PS.NAME_FULL_BLOCKX); if (value != null) { - ret.blockX(ARInteger.get().read(value, sender)); + ret.blockX(TypeInteger.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_BLOCKY, PS.NAME_FULL_BLOCKY); if (value != null) { - ret.blockY(ARInteger.get().read(value, sender)); + ret.blockY(TypeInteger.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_BLOCKZ, PS.NAME_FULL_BLOCKZ); if (value != null) { - ret.blockZ(ARInteger.get().read(value, sender)); + ret.blockZ(TypeInteger.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_LOCATIONX, PS.NAME_FULL_LOCATIONX, "x"); if (value != null) { - ret.locationX(ARDouble.get().read(value, sender)); + ret.locationX(TypeDouble.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_LOCATIONY, PS.NAME_FULL_LOCATIONY, "y"); if (value != null) { - ret.locationY(ARDouble.get().read(value, sender)); + ret.locationY(TypeDouble.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_LOCATIONZ, PS.NAME_FULL_LOCATIONZ, "z"); if (value != null) { - ret.locationZ(ARDouble.get().read(value, sender)); + ret.locationZ(TypeDouble.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_CHUNKX, PS.NAME_FULL_CHUNKX); if (value != null) { - ret.chunkX(ARInteger.get().read(value, sender)); + ret.chunkX(TypeInteger.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_CHUNKZ, PS.NAME_FULL_CHUNKZ); if (value != null) { - ret.chunkZ(ARInteger.get().read(value, sender)); + ret.chunkZ(TypeInteger.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_PITCH, PS.NAME_FULL_PITCH); if (value != null) { - ret.pitch(ARFloat.get().read(value, sender)); + ret.pitch(TypeFloat.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_YAW, PS.NAME_FULL_YAW); if (value != null) { - ret.yaw(ARFloat.get().read(value, sender)); + ret.yaw(TypeFloat.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_VELOCITYX, PS.NAME_FULL_VELOCITYX); if (value != null) { - ret.velocityX(ARDouble.get().read(value, sender)); + ret.velocityX(TypeDouble.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_VELOCITYY, PS.NAME_FULL_VELOCITYY); if (value != null) { - ret.velocityY(ARDouble.get().read(value, sender)); + ret.velocityY(TypeDouble.get().read(value, sender)); something = true; } value = getValue(part, PS.NAME_SERIALIZED_VELOCITYZ, PS.NAME_FULL_VELOCITYZ); if (value != null) { - ret.velocityZ(ARDouble.get().read(value, sender)); + ret.velocityZ(TypeDouble.get().read(value, sender)); something = true; } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java b/src/com/massivecraft/massivecore/cmd/type/TypePermission.java similarity index 80% rename from src/com/massivecraft/massivecore/cmd/arg/ARPermission.java rename to src/com/massivecraft/massivecore/cmd/type/TypePermission.java index bc15d2fe..77d7440a 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPermission.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypePermission.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Set; @@ -10,14 +10,14 @@ import org.bukkit.permissions.Permission; import com.massivecraft.massivecore.MassiveException; -public class ARPermission extends ARAbstract implements ARAllAble +public class TypePermission extends TypeAbstract implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARPermission i = new ARPermission(); - public static ARPermission get() { return i; } + private static TypePermission i = new TypePermission(); + public static TypePermission get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPlayer.java b/src/com/massivecraft/massivecore/cmd/type/TypePlayer.java similarity index 73% rename from src/com/massivecraft/massivecore/cmd/arg/ARPlayer.java rename to src/com/massivecraft/massivecore/cmd/type/TypePlayer.java index 02c7ed0b..23e8cfae 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPlayer.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypePlayer.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.entity.Player; @@ -7,15 +7,15 @@ import com.massivecraft.massivecore.SenderType; import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds; import com.massivecraft.massivecore.util.IdUtil; -public class ARPlayer extends ARSenderIdAbstract +public class TypePlayer extends TypeSenderIdAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static final ARPlayer i = new ARPlayer(); - public static ARPlayer get() { return i; } - private ARPlayer() + private static final TypePlayer i = new TypePlayer(); + public static TypePlayer get() { return i; } + private TypePlayer() { super(SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.PLAYER); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectType.java b/src/com/massivecraft/massivecore/cmd/type/TypePotionEffectType.java similarity index 87% rename from src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectType.java rename to src/com/massivecraft/massivecore/cmd/type/TypePotionEffectType.java index e8910cdf..905dfcf9 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectType.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypePotionEffectType.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -10,14 +10,14 @@ import org.bukkit.potion.PotionEffectType; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.collections.MassiveList; -public class ARPotionEffectType extends ARAbstractSelect implements ARAllAble +public class TypePotionEffectType extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARPotionEffectType i = new ARPotionEffectType(); - public static ARPotionEffectType get() { return i; } + private static TypePotionEffectType i = new TypePotionEffectType(); + public static TypePotionEffectType get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectWrap.java b/src/com/massivecraft/massivecore/cmd/type/TypePotionEffectWrap.java similarity index 77% rename from src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectWrap.java rename to src/com/massivecraft/massivecore/cmd/type/TypePotionEffectWrap.java index 85ceb8a8..decde792 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARPotionEffectWrap.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypePotionEffectWrap.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.List; @@ -9,25 +9,25 @@ import org.bukkit.potion.PotionEffectType; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.PotionEffectWrap; -public class ARPotionEffectWrap extends ARAbstract +public class TypePotionEffectWrap extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARPotionEffectWrap i = new ARPotionEffectWrap(); - public static ARPotionEffectWrap get() { return i; } + private static TypePotionEffectWrap i = new TypePotionEffectWrap(); + public static TypePotionEffectWrap get() { return i; } // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected final ARCombined combined = new ARCombined( - ARPotionEffectType.get(), - ARInteger.get(), - ARInteger.get(), - ARBoolean.get(), - ARBoolean.get() + protected final TypeCombined combined = new TypeCombined( + TypePotionEffectType.get(), + TypeInteger.get(), + TypeInteger.get(), + TypeBoolean.get(), + TypeBoolean.get() ); // -------------------------------------------- // @@ -81,7 +81,7 @@ public class ARPotionEffectWrap extends ARAbstract @Override public Collection getTabList(CommandSender sender, String arg) { - return ARPotionEffectType.get().getTabList(sender, arg); + return TypePotionEffectType.get().getTabList(sender, arg); } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSender.java b/src/com/massivecraft/massivecore/cmd/type/TypeSender.java similarity index 73% rename from src/com/massivecraft/massivecore/cmd/arg/ARSender.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSender.java index 8a4a1ac1..c396be94 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSender.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSender.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import org.bukkit.command.CommandSender; @@ -7,15 +7,15 @@ import com.massivecraft.massivecore.SenderType; import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds; import com.massivecraft.massivecore.util.IdUtil; -public class ARSender extends ARSenderIdAbstract +public class TypeSender extends TypeSenderIdAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static final ARSender i = new ARSender(); - public static ARSender get() { return i; } - private ARSender() + private static final TypeSender i = new TypeSender(); + public static TypeSender get() { return i; } + private TypeSender() { super(SenderIdSourceMixinAllSenderIds.get(), SenderPresence.LOCAL, SenderType.ANY); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSenderEntity.java b/src/com/massivecraft/massivecore/cmd/type/TypeSenderEntity.java similarity index 56% rename from src/com/massivecraft/massivecore/cmd/arg/ARSenderEntity.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSenderEntity.java index 04388d9b..1e5b6b85 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSenderEntity.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSenderEntity.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import org.bukkit.command.CommandSender; @@ -8,7 +8,7 @@ import com.massivecraft.massivecore.SenderType; import com.massivecraft.massivecore.store.SenderColl; import com.massivecraft.massivecore.store.SenderEntity; -public class ARSenderEntity> extends ARSenderIdAbstract implements ARAllAble +public class TypeSenderEntity> extends TypeSenderIdAbstract implements TypeAllAble { // -------------------------------------------- // // FIELDS @@ -20,19 +20,19 @@ public class ARSenderEntity> extends ARSenderIdAbstrac // CONSTRUCT // -------------------------------------------- // - private ARSenderEntity(SenderColl coll, SenderPresence presence, SenderType type) + private TypeSenderEntity(SenderColl coll, SenderPresence presence, SenderType type) { super(coll, presence, type); this.coll = coll; } - private ARSenderEntity(SenderColl coll, SenderPresence presence) + private TypeSenderEntity(SenderColl coll, SenderPresence presence) { super(coll, presence); this.coll = coll; } - private ARSenderEntity(SenderColl coll) + private TypeSenderEntity(SenderColl coll) { super(coll); this.coll = coll; @@ -42,9 +42,9 @@ public class ARSenderEntity> extends ARSenderIdAbstrac // GET // -------------------------------------------- // - public static > ARSenderEntity get(SenderColl coll, SenderPresence presence, SenderType type) { return new ARSenderEntity(coll, presence, type); } - public static > ARSenderEntity get(SenderColl coll, SenderPresence presence) { return new ARSenderEntity(coll, presence); } - public static > ARSenderEntity get(SenderColl coll) { return new ARSenderEntity(coll); } + public static > TypeSenderEntity get(SenderColl coll, SenderPresence presence, SenderType type) { return new TypeSenderEntity(coll, presence, type); } + public static > TypeSenderEntity get(SenderColl coll, SenderPresence presence) { return new TypeSenderEntity(coll, presence); } + public static > TypeSenderEntity get(SenderColl coll) { return new TypeSenderEntity(coll); } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSenderId.java b/src/com/massivecraft/massivecore/cmd/type/TypeSenderId.java similarity index 50% rename from src/com/massivecraft/massivecore/cmd/arg/ARSenderId.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSenderId.java index 3f2b0bb3..ec0b9ade 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSenderId.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSenderId.java @@ -1,27 +1,27 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import com.massivecraft.massivecore.SenderPresence; import com.massivecraft.massivecore.SenderType; import com.massivecraft.massivecore.store.SenderIdSource; import com.massivecraft.massivecore.store.SenderIdSourceMixinAllSenderIds; -public class ARSenderId extends ARSenderIdAbstract +public class TypeSenderId extends TypeSenderIdAbstract { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - private ARSenderId(SenderIdSource source, SenderPresence presence, SenderType type) + private TypeSenderId(SenderIdSource source, SenderPresence presence, SenderType type) { super(source, presence, type); } - private ARSenderId(SenderIdSource source, SenderPresence presence) + private TypeSenderId(SenderIdSource source, SenderPresence presence) { super(source, presence); } - private ARSenderId(SenderIdSource source) + private TypeSenderId(SenderIdSource source) { super(source); } @@ -30,16 +30,16 @@ public class ARSenderId extends ARSenderIdAbstract // INSTANCE // -------------------------------------------- // - private static final ARSenderId i = new ARSenderId(SenderIdSourceMixinAllSenderIds.get()); - public static ARSenderId get() { return i; } + private static final TypeSenderId i = new TypeSenderId(SenderIdSourceMixinAllSenderIds.get()); + public static TypeSenderId get() { return i; } // -------------------------------------------- // // GET // -------------------------------------------- // - public static ARSenderId get(SenderIdSource source, SenderPresence presence, SenderType type) { return new ARSenderId(source, presence, type); } - public static ARSenderId get(SenderIdSource source, SenderPresence presence) { return new ARSenderId(source, presence); } - public static ARSenderId get(SenderIdSource source) { return new ARSenderId(source); } + public static TypeSenderId get(SenderIdSource source, SenderPresence presence, SenderType type) { return new TypeSenderId(source, presence, type); } + public static TypeSenderId get(SenderIdSource source, SenderPresence presence) { return new TypeSenderId(source, presence); } + public static TypeSenderId get(SenderIdSource source) { return new TypeSenderId(source); } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java b/src/com/massivecraft/massivecore/cmd/type/TypeSenderIdAbstract.java similarity index 90% rename from src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSenderIdAbstract.java index 5ef3e0fd..fb49d7c7 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSenderIdAbstract.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSenderIdAbstract.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; @@ -15,7 +15,7 @@ import com.massivecraft.massivecore.store.SenderIdSource; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; -public abstract class ARSenderIdAbstract extends ARAbstract +public abstract class TypeSenderIdAbstract extends TypeAbstract { // -------------------------------------------- // // FIELDS @@ -29,7 +29,7 @@ public abstract class ARSenderIdAbstract extends ARAbstract // CONSTRUCT // -------------------------------------------- // - public ARSenderIdAbstract(SenderIdSource source, SenderPresence presence, SenderType type) + public TypeSenderIdAbstract(SenderIdSource source, SenderPresence presence, SenderType type) { if (source == null) throw new NullPointerException("source"); if (presence == null) throw new NullPointerException("presence"); @@ -40,12 +40,12 @@ public abstract class ARSenderIdAbstract extends ARAbstract this.type = type; } - public ARSenderIdAbstract(SenderIdSource source, SenderPresence presence) + public TypeSenderIdAbstract(SenderIdSource source, SenderPresence presence) { this(source, presence, SenderType.ANY); } - public ARSenderIdAbstract(SenderIdSource source) + public TypeSenderIdAbstract(SenderIdSource source) { this(source, SenderPresence.ANY); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSet.java b/src/com/massivecraft/massivecore/cmd/type/TypeSet.java similarity index 66% rename from src/com/massivecraft/massivecore/cmd/arg/ARSet.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSet.java index c0fa7005..52f6e8ed 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSet.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSet.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.LinkedHashSet; @@ -10,15 +10,15 @@ import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.util.Txt; -public class ARSet extends ARCollection> +public class TypeSet extends TypeCollection> { // -------------------------------------------- // // FIELDS // -------------------------------------------- // - protected final AR elementArgReader; - public AR getElementArgReader() { return this.elementArgReader; } - @Override public AR getInnerArgReader() { return this.getElementArgReader(); } + protected final Type elementType; + public Type getElementType() { return this.elementType; } + @Override public Type getInnerType() { return this.getElementType(); } protected final boolean warnOnDuplicates; public boolean getWarnOnDuplicate() { return warnOnDuplicates; } @@ -27,14 +27,14 @@ public class ARSet extends ARCollection> // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static ARSet get(AR elementArgReader, boolean warnOnDuplicates) + public static TypeSet get(Type elementType, boolean warnOnDuplicates) { - return new ARSet(elementArgReader, warnOnDuplicates); + return new TypeSet(elementType, warnOnDuplicates); } - public ARSet(AR elementArgReader, boolean warnOnDuplicates) + public TypeSet(Type elementType, boolean warnOnDuplicates) { - this.elementArgReader = elementArgReader; + this.elementType = elementType; this.warnOnDuplicates = warnOnDuplicates; } @@ -45,7 +45,7 @@ public class ARSet extends ARCollection> @Override public String getTypeName() { - return elementArgReader.getTypeName(); + return elementType.getTypeName(); } // NOTE: Must be used with argConcatFrom and setErrorOnTooManyArgs(false). @@ -63,7 +63,7 @@ public class ARSet extends ARCollection> // For Each for (String elementArg : elementArgs) { - E element = this.getElementArgReader().read(elementArg, sender); + E element = this.getElementType().read(elementArg, sender); duplicates = ( ! ret.add(element) || duplicates); } @@ -80,7 +80,7 @@ public class ARSet extends ARCollection> @Override public Collection getTabList(CommandSender sender, String arg) { - return elementArgReader.getTabList(sender, arg); + return elementType.getTabList(sender, arg); } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSound.java b/src/com/massivecraft/massivecore/cmd/type/TypeSound.java similarity index 86% rename from src/com/massivecraft/massivecore/cmd/arg/ARSound.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSound.java index 816aafd1..feb0b3f3 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSound.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSound.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -10,14 +10,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; -public class ARSound extends ARAbstract implements ARAllAble +public class TypeSound extends TypeAbstract implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARSound i = new ARSound(); - public static ARSound get() { return i; } + private static TypeSound i = new TypeSound(); + public static TypeSound get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java b/src/com/massivecraft/massivecore/cmd/type/TypeSoundEffect.java similarity index 71% rename from src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java rename to src/com/massivecraft/massivecore/cmd/type/TypeSoundEffect.java index 20c8d69f..cce87819 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARSoundEffect.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeSoundEffect.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Set; @@ -8,14 +8,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.collections.MassiveSet; -public class ARSoundEffect extends ARAbstractException +public class TypeSoundEffect extends TypeAbstractException { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARSoundEffect i = new ARSoundEffect(); - public static ARSoundEffect get() { return i; } + private static TypeSoundEffect i = new TypeSoundEffect(); + public static TypeSoundEffect get() { return i; } // -------------------------------------------- // // OVERRIDE @@ -32,7 +32,7 @@ public class ARSoundEffect extends ARAbstractException { Set ret = new MassiveSet(); - for (String str : ARSound.get().getTabList(sender, arg)) + for (String str : TypeSound.get().getTabList(sender, arg)) { ret.add(str + "-"); } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARString.java b/src/com/massivecraft/massivecore/cmd/type/TypeString.java similarity index 73% rename from src/com/massivecraft/massivecore/cmd/arg/ARString.java rename to src/com/massivecraft/massivecore/cmd/type/TypeString.java index fb6decce..f31d9e46 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARString.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeString.java @@ -1,18 +1,18 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; import org.bukkit.command.CommandSender; -public class ARString extends ARAbstract +public class TypeString extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARString i = new ARString(); - public static ARString get() { return i; } + private static TypeString i = new TypeString(); + public static TypeString get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARStringCommand.java b/src/com/massivecraft/massivecore/cmd/type/TypeStringCommand.java similarity index 94% rename from src/com/massivecraft/massivecore/cmd/arg/ARStringCommand.java rename to src/com/massivecraft/massivecore/cmd/type/TypeStringCommand.java index 2f10f429..dab3fd3c 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARStringCommand.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeStringCommand.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Arrays; import java.util.Collection; @@ -19,14 +19,14 @@ import com.massivecraft.massivecore.util.Txt; // We return the command without leading slash. // If the player supplies a leading slash we assume they mean some WorldEdit double slash first. // Then we test without if nothing found. -public class ARStringCommand extends ARAbstract +public class TypeStringCommand extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARStringCommand i = new ARStringCommand(); - public static ARStringCommand get() { return i; } + private static TypeStringCommand i = new TypeStringCommand(); + public static TypeStringCommand get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java b/src/com/massivecraft/massivecore/cmd/type/TypeUniverse.java similarity index 78% rename from src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java rename to src/com/massivecraft/massivecore/cmd/type/TypeUniverse.java index 5f9bdcbf..4ce3e962 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARUniverse.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeUniverse.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Collection; @@ -11,7 +11,7 @@ import com.massivecraft.massivecore.Multiverse; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.util.Txt; -public class ARUniverse extends ARAbstract +public class TypeUniverse extends TypeAbstract { // -------------------------------------------- // // FIELDS @@ -30,11 +30,11 @@ public class ARUniverse extends ARAbstract // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static ARUniverse get(Aspect aspect) { return new ARUniverse(aspect); } - public static ARUniverse get(Multiverse multiverse) { return new ARUniverse(multiverse); } + public static TypeUniverse get(Aspect aspect) { return new TypeUniverse(aspect); } + public static TypeUniverse get(Multiverse multiverse) { return new TypeUniverse(multiverse); } - public ARUniverse(Aspect aspect) { this.aspect = aspect; } - public ARUniverse(Multiverse multiverse) { this.multiverse = multiverse; } + public TypeUniverse(Aspect aspect) { this.aspect = aspect; } + public TypeUniverse(Multiverse multiverse) { this.multiverse = multiverse; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java b/src/com/massivecraft/massivecore/cmd/type/TypeWorld.java similarity index 70% rename from src/com/massivecraft/massivecore/cmd/arg/ARWorld.java rename to src/com/massivecraft/massivecore/cmd/type/TypeWorld.java index bef7ebe7..5cc603e9 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARWorld.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeWorld.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; @@ -8,14 +8,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.MassiveException; -public class ARWorld extends ARAbstract +public class TypeWorld extends TypeAbstract { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARWorld i = new ARWorld(); - public static ARWorld get() { return i; } + private static TypeWorld i = new TypeWorld(); + public static TypeWorld get() { return i; } // -------------------------------------------- // // OVERRIDE @@ -24,7 +24,7 @@ public class ARWorld extends ARAbstract @Override public World read(String arg, CommandSender sender) throws MassiveException { - String worldId = ARWorldId.get().read(arg, sender); + String worldId = TypeWorldId.get().read(arg, sender); World ret = Bukkit.getWorld(worldId); @@ -39,7 +39,7 @@ public class ARWorld extends ARAbstract @Override public Collection getTabList(CommandSender sender, String arg) { - return ARWorldId.get().getTabList(sender, arg); + return TypeWorldId.get().getTabList(sender, arg); } } diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARWorldId.java b/src/com/massivecraft/massivecore/cmd/type/TypeWorldId.java similarity index 84% rename from src/com/massivecraft/massivecore/cmd/arg/ARWorldId.java rename to src/com/massivecraft/massivecore/cmd/type/TypeWorldId.java index 17aa0fc7..dddeebca 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARWorldId.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeWorldId.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.ArrayList; import java.util.Collection; @@ -8,14 +8,14 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.mixin.Mixin; -public class ARWorldId extends ARAbstractSelect implements ARAllAble +public class TypeWorldId extends TypeAbstractSelect implements TypeAllAble { // -------------------------------------------- // // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARWorldId i = new ARWorldId(); - public static ARWorldId get() { return i; } + private static TypeWorldId i = new TypeWorldId(); + public static TypeWorldId get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARWorldType.java b/src/com/massivecraft/massivecore/cmd/type/TypeWorldType.java similarity index 86% rename from src/com/massivecraft/massivecore/cmd/arg/ARWorldType.java rename to src/com/massivecraft/massivecore/cmd/type/TypeWorldType.java index 18c4aba1..36c7e8bc 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARWorldType.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeWorldType.java @@ -1,4 +1,4 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import java.util.Collections; @@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.massivecore.util.MUtil; -public class ARWorldType extends ARAbstractSelect +public class TypeWorldType extends TypeAbstractSelect { // -------------------------------------------- // // CONSTANTS @@ -21,8 +21,8 @@ public class ARWorldType extends ARAbstractSelect // INSTANCE & CONSTRUCT // -------------------------------------------- // - private static ARWorldType i = new ARWorldType(); - public static ARWorldType get() { return i; } + private static TypeWorldType i = new TypeWorldType(); + public static TypeWorldType get() { return i; } // -------------------------------------------- // // OVERRIDE diff --git a/src/com/massivecraft/massivecore/cmd/arg/ARWrapper.java b/src/com/massivecraft/massivecore/cmd/type/TypeWrapper.java similarity index 61% rename from src/com/massivecraft/massivecore/cmd/arg/ARWrapper.java rename to src/com/massivecraft/massivecore/cmd/type/TypeWrapper.java index c00218e0..a61f0956 100644 --- a/src/com/massivecraft/massivecore/cmd/arg/ARWrapper.java +++ b/src/com/massivecraft/massivecore/cmd/type/TypeWrapper.java @@ -1,16 +1,16 @@ -package com.massivecraft.massivecore.cmd.arg; +package com.massivecraft.massivecore.cmd.type; import java.util.Collection; import org.bukkit.command.CommandSender; -public abstract class ARWrapper extends ARAbstract +public abstract class TypeWrapper extends TypeAbstract { // -------------------------------------------- // // ABSTRACT // -------------------------------------------- // - public abstract AR getInnerArgReader(); + public abstract Type getInnerType(); // -------------------------------------------- // // OVERRIDE @@ -19,25 +19,25 @@ public abstract class ARWrapper extends ARAbstract @Override public String getTypeName() { - return this.getInnerArgReader().getTypeName(); + return this.getInnerType().getTypeName(); } @Override public boolean isValid(String arg, CommandSender sender) { - return this.getInnerArgReader().isValid(arg, sender); + return this.getInnerType().isValid(arg, sender); } @Override public Collection getTabList(CommandSender sender, String arg) { - return this.getInnerArgReader().getTabList(sender, arg); + return this.getInnerType().getTabList(sender, arg); } @Override public boolean allowSpaceAfterTab() { - return this.getInnerArgReader().allowSpaceAfterTab(); + return this.getInnerType().allowSpaceAfterTab(); } } diff --git a/src/com/massivecraft/massivecore/mixin/MessageMixin.java b/src/com/massivecraft/massivecore/mixin/MessageMixin.java index 2f8205a0..a0cfcb45 100644 --- a/src/com/massivecraft/massivecore/mixin/MessageMixin.java +++ b/src/com/massivecraft/massivecore/mixin/MessageMixin.java @@ -4,7 +4,7 @@ import java.util.Collection; import org.bukkit.command.CommandSender; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; public interface MessageMixin { @@ -19,9 +19,9 @@ public interface MessageMixin public boolean msgAll(Collection msgs); // Predicate - public boolean msgPredictate(Predictate predictate, String msg); - public boolean msgPredictate(Predictate predictate, String msg, Object... args); - public boolean msgPredictate(Predictate predictate, Collection msgs); + public boolean msgPredicate(Predicate predicate, String msg); + public boolean msgPredicate(Predicate predicate, String msg, Object... args); + public boolean msgPredicate(Predicate predicate, Collection msgs); // One public boolean msgOne(Object sendeeObject, String msg); @@ -38,9 +38,9 @@ public interface MessageMixin public boolean messageAll(Collection messages); // Predicate - public boolean messagePredictate(Predictate predictate, Object message); - public boolean messagePredictate(Predictate predictate, Object... messages); - public boolean messagePredictate(Predictate predictate, Collection messages); + public boolean messagePredicate(Predicate predicate, Object message); + public boolean messagePredicate(Predicate predicate, Object... messages); + public boolean messagePredicate(Predicate predicate, Collection messages); // One public boolean messageOne(Object sendeeObject, Object message); diff --git a/src/com/massivecraft/massivecore/mixin/MessageMixinAbstract.java b/src/com/massivecraft/massivecore/mixin/MessageMixinAbstract.java index 839bfa4b..fc7689e1 100644 --- a/src/com/massivecraft/massivecore/mixin/MessageMixinAbstract.java +++ b/src/com/massivecraft/massivecore/mixin/MessageMixinAbstract.java @@ -6,7 +6,7 @@ import java.util.Collections; import org.bukkit.command.CommandSender; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.util.Txt; public abstract class MessageMixinAbstract implements MessageMixin @@ -35,23 +35,23 @@ public abstract class MessageMixinAbstract implements MessageMixin return this.messageAll(Txt.parse(msgs)); } - // Predictate + // Predicate @Override - public boolean msgPredictate(Predictate predictate, String msg) + public boolean msgPredicate(Predicate predicate, String msg) { - return this.messagePredictate(predictate, Txt.parse(msg)); + return this.messagePredicate(predicate, Txt.parse(msg)); } @Override - public boolean msgPredictate(Predictate predictate, String msg, Object... args) + public boolean msgPredicate(Predicate predicate, String msg, Object... args) { - return this.messagePredictate(predictate, Txt.parse(msg, args)); + return this.messagePredicate(predicate, Txt.parse(msg, args)); } @Override - public boolean msgPredictate(Predictate predictate, Collection msgs) + public boolean msgPredicate(Predicate predicate, Collection msgs) { - return this.messagePredictate(predictate, Txt.parse(msgs)); + return this.messagePredicate(predicate, Txt.parse(msgs)); } // One @@ -92,15 +92,15 @@ public abstract class MessageMixinAbstract implements MessageMixin // Predicate @Override - public boolean messagePredictate(Predictate predictate, Object message) + public boolean messagePredicate(Predicate predicate, Object message) { - return this.messagePredictate(predictate, Collections.singleton(message)); + return this.messagePredicate(predicate, Collections.singleton(message)); } @Override - public boolean messagePredictate(Predictate predictate, Object... messages) + public boolean messagePredicate(Predicate predicate, Object... messages) { - return this.messagePredictate(predictate, Arrays.asList(messages)); + return this.messagePredicate(predicate, Arrays.asList(messages)); } // One diff --git a/src/com/massivecraft/massivecore/mixin/MessageMixinDefault.java b/src/com/massivecraft/massivecore/mixin/MessageMixinDefault.java index 092c4a94..da53d875 100644 --- a/src/com/massivecraft/massivecore/mixin/MessageMixinDefault.java +++ b/src/com/massivecraft/massivecore/mixin/MessageMixinDefault.java @@ -5,7 +5,7 @@ import java.util.Collection; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.nms.NmsPacket; import com.massivecraft.massivecore.util.IdUtil; @@ -45,10 +45,10 @@ public class MessageMixinDefault extends MessageMixinAbstract // Predicate // NOTE: Targets messageOne @Override - public boolean messagePredictate(Predictate predictate, Collection messages) + public boolean messagePredicate(Predicate predicate, Collection messages) { // Check Predicate - if (predictate == null) return false; + if (predicate == null) return false; // Check Messages if (messages == null) return false; @@ -57,7 +57,7 @@ public class MessageMixinDefault extends MessageMixinAbstract // Here for (CommandSender sender : IdUtil.getLocalSenders()) { - if (!predictate.apply(sender)) continue; + if (!predicate.apply(sender)) continue; this.messageOne(sender, messages); } diff --git a/src/com/massivecraft/massivecore/mixin/Mixin.java b/src/com/massivecraft/massivecore/mixin/Mixin.java index a4388abd..64eaee5c 100644 --- a/src/com/massivecraft/massivecore/mixin/Mixin.java +++ b/src/com/massivecraft/massivecore/mixin/Mixin.java @@ -12,7 +12,7 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.PlayerInventory; import org.bukkit.permissions.Permissible; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.ps.PS; @@ -255,19 +255,19 @@ public class Mixin } // MSG: Predicate - public static boolean msgPredictate(Predictate predictate, String msg) + public static boolean msgPredicate(Predicate predicate, String msg) { - return getMessageMixin().msgPredictate(predictate, msg); + return getMessageMixin().msgPredicate(predicate, msg); } - public static boolean msgPredictate(Predictate predictate, String msg, Object... args) + public static boolean msgPredicate(Predicate predicate, String msg, Object... args) { - return getMessageMixin().msgPredictate(predictate, msg, args); + return getMessageMixin().msgPredicate(predicate, msg, args); } - public static boolean msgPredictate(Predictate predictate, Collection msgs) + public static boolean msgPredicate(Predicate predicate, Collection msgs) { - return getMessageMixin().msgPredictate(predictate, msgs); + return getMessageMixin().msgPredicate(predicate, msgs); } // MSG: One @@ -303,19 +303,19 @@ public class Mixin } // MESSAGE: Predicate - public static boolean messagePredictate(Predictate predictate, Object message) + public static boolean messagePredicate(Predicate predicate, Object message) { - return getMessageMixin().messagePredictate(predictate, message); + return getMessageMixin().messagePredicate(predicate, message); } - public static boolean messagePredictate(Predictate predictate, Object... messages) + public static boolean messagePredicate(Predicate predicate, Object... messages) { - return getMessageMixin().messagePredictate(predictate, messages); + return getMessageMixin().messagePredicate(predicate, messages); } - public static boolean messagePredictate(Predictate predictate, Collection messages) + public static boolean messagePredicate(Predicate predicate, Collection messages) { - return getMessageMixin().messagePredictate(predictate, messages); + return getMessageMixin().messagePredicate(predicate, messages); } // MESSAGE: One diff --git a/src/com/massivecraft/massivecore/mson/Mson.java b/src/com/massivecraft/massivecore/mson/Mson.java index 20cee32c..bbd3d9ee 100644 --- a/src/com/massivecraft/massivecore/mson/Mson.java +++ b/src/com/massivecraft/massivecore/mson/Mson.java @@ -15,7 +15,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.inventory.ItemStack; import com.google.common.collect.ImmutableList; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.adapter.LowercaseEnumAdapter; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.collections.MassiveList; @@ -903,10 +903,10 @@ public class Mson implements Serializable return Mixin.messageAll(this); } - // Predictate - public boolean messagePredictate(Predictate predictate) + // Predicate + public boolean messagePredicate(Predicate predicate) { - return Mixin.messagePredictate(predictate, this); + return Mixin.messagePredicate(predicate, this); } // One diff --git a/src/com/massivecraft/massivecore/store/CollAbstract.java b/src/com/massivecraft/massivecore/store/CollAbstract.java index c6b53b61..76a97416 100644 --- a/src/com/massivecraft/massivecore/store/CollAbstract.java +++ b/src/com/massivecraft/massivecore/store/CollAbstract.java @@ -5,7 +5,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map.Entry; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.xlib.gson.JsonElement; @@ -58,14 +58,14 @@ public abstract class CollAbstract implements CollInterface return this.containsIdFixed(this.fixId(oid)); } - @Override public List getAll(Iterable oids, Predictate where, Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, orderby, limit, offset); } - @Override public List getAll(Iterable oids, Predictate where, Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(oids), where, orderby, limit); } - @Override public List getAll(Iterable oids, Predictate where, Comparator orderby) { return MUtil.transform(this.getAll(oids), where, orderby); } - @Override public List getAll(Iterable oids, Predictate where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, limit, offset); } - @Override public List getAll(Iterable oids, Predictate where, Integer limit) { return MUtil.transform(this.getAll(oids), where, limit); } + @Override public List getAll(Iterable oids, Predicate where, Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, orderby, limit, offset); } + @Override public List getAll(Iterable oids, Predicate where, Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(oids), where, orderby, limit); } + @Override public List getAll(Iterable oids, Predicate where, Comparator orderby) { return MUtil.transform(this.getAll(oids), where, orderby); } + @Override public List getAll(Iterable oids, Predicate where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), where, limit, offset); } + @Override public List getAll(Iterable oids, Predicate where, Integer limit) { return MUtil.transform(this.getAll(oids), where, limit); } @Override public List getAll(Iterable oids, Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), limit, offset); } @Override public List getAll(Iterable oids, Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(oids), limit); } - @Override public List getAll(Iterable oids, Predictate where) { return MUtil.transform(this.getAll(oids), where); } + @Override public List getAll(Iterable oids, Predicate where) { return MUtil.transform(this.getAll(oids), where); } @Override public List getAll(Iterable oids, Comparator orderby) { return MUtil.transform(this.getAll(oids), orderby); } @Override public List getAll(Iterable oids, Integer limit, Integer offset) { return MUtil.transform(this.getAll(oids), limit, offset); } @Override public List getAll(Iterable oids, Integer limit) { return MUtil.transform(this.getAll(oids), limit); } @@ -87,14 +87,14 @@ public abstract class CollAbstract implements CollInterface return ret; } - @Override public List getAll(Predictate where, Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, orderby, limit, offset); } - @Override public List getAll(Predictate where, Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(), where, orderby, limit); } - @Override public List getAll(Predictate where, Comparator orderby) { return MUtil.transform(this.getAll(), where, orderby); } - @Override public List getAll(Predictate where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, limit, offset); } - @Override public List getAll(Predictate where, Integer limit) { return MUtil.transform(this.getAll(), where, limit); } + @Override public List getAll(Predicate where, Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, orderby, limit, offset); } + @Override public List getAll(Predicate where, Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(), where, orderby, limit); } + @Override public List getAll(Predicate where, Comparator orderby) { return MUtil.transform(this.getAll(), where, orderby); } + @Override public List getAll(Predicate where, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), where, limit, offset); } + @Override public List getAll(Predicate where, Integer limit) { return MUtil.transform(this.getAll(), where, limit); } @Override public List getAll(Comparator orderby, Integer limit, Integer offset) { return MUtil.transform(this.getAll(), limit, offset); } @Override public List getAll(Comparator orderby, Integer limit) { return MUtil.transform(this.getAll(), limit); } - @Override public List getAll(Predictate where) { return MUtil.transform(this.getAll(), where); } + @Override public List getAll(Predicate where) { return MUtil.transform(this.getAll(), where); } @Override public List getAll(Comparator orderby) { return MUtil.transform(this.getAll(), orderby); } @Override public List getAll(Integer limit, Integer offset) { return MUtil.transform(this.getAll(), limit, offset); } @Override public List getAll(Integer limit) { return MUtil.transform(this.getAll(), limit); } diff --git a/src/com/massivecraft/massivecore/store/CollInterface.java b/src/com/massivecraft/massivecore/store/CollInterface.java index f3449633..2c0d2f1a 100644 --- a/src/com/massivecraft/massivecore/store/CollInterface.java +++ b/src/com/massivecraft/massivecore/store/CollInterface.java @@ -8,7 +8,7 @@ import java.util.Map.Entry; import org.bukkit.plugin.Plugin; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.xlib.gson.JsonElement; public interface CollInterface @@ -54,27 +54,27 @@ public interface CollInterface public Collection getAll(); - public List getAll(Iterable oids, Predictate where, Comparator orderby, Integer limit, Integer offset); - public List getAll(Iterable oids, Predictate where, Comparator orderby, Integer limit); - public List getAll(Iterable oids, Predictate where, Comparator orderby); - public List getAll(Iterable oids, Predictate where, Integer limit, Integer offset); - public List getAll(Iterable oids, Predictate where, Integer limit); + public List getAll(Iterable oids, Predicate where, Comparator orderby, Integer limit, Integer offset); + public List getAll(Iterable oids, Predicate where, Comparator orderby, Integer limit); + public List getAll(Iterable oids, Predicate where, Comparator orderby); + public List getAll(Iterable oids, Predicate where, Integer limit, Integer offset); + public List getAll(Iterable oids, Predicate where, Integer limit); public List getAll(Iterable oids, Comparator orderby, Integer limit, Integer offset); public List getAll(Iterable oids, Comparator orderby, Integer limit); - public List getAll(Iterable oids, Predictate where); + public List getAll(Iterable oids, Predicate where); public List getAll(Iterable oids, Comparator orderby); public List getAll(Iterable oids, Integer limit, Integer offset); public List getAll(Iterable oids, Integer limit); public List getAll(Iterable oids); - public List getAll(Predictate where, Comparator orderby, Integer limit, Integer offset); - public List getAll(Predictate where, Comparator orderby, Integer limit); - public List getAll(Predictate where, Comparator orderby); - public List getAll(Predictate where, Integer limit, Integer offset); - public List getAll(Predictate where, Integer limit); + public List getAll(Predicate where, Comparator orderby, Integer limit, Integer offset); + public List getAll(Predicate where, Comparator orderby, Integer limit); + public List getAll(Predicate where, Comparator orderby); + public List getAll(Predicate where, Integer limit, Integer offset); + public List getAll(Predicate where, Integer limit); public List getAll(Comparator orderby, Integer limit, Integer offset); public List getAll(Comparator orderby, Integer limit); - public List getAll(Predictate where); + public List getAll(Predicate where); public List getAll(Comparator orderby); public List getAll(Integer limit, Integer offset); public List getAll(Integer limit); diff --git a/src/com/massivecraft/massivecore/store/SenderColl.java b/src/com/massivecraft/massivecore/store/SenderColl.java index 1a10df2d..3f0f820b 100644 --- a/src/com/massivecraft/massivecore/store/SenderColl.java +++ b/src/com/massivecraft/massivecore/store/SenderColl.java @@ -7,11 +7,11 @@ import java.util.List; import org.bukkit.command.CommandSender; import org.bukkit.plugin.Plugin; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.SenderPresence; import com.massivecraft.massivecore.SenderType; -import com.massivecraft.massivecore.cmd.arg.ARSenderEntity; -import com.massivecraft.massivecore.cmd.arg.ARSenderId; +import com.massivecraft.massivecore.cmd.type.TypeSenderEntity; +import com.massivecraft.massivecore.cmd.type.TypeSenderId; import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; @@ -120,31 +120,31 @@ public class SenderColl> extends Coll implements Se // ARGUMENT READERS // -------------------------------------------- // - public ARSenderEntity getAREntity() + public TypeSenderEntity getTypeEntity() { - return ARSenderEntity.get(this); + return TypeSenderEntity.get(this); } - public ARSenderEntity getAREntity(SenderPresence presence) + public TypeSenderEntity getTypeEntity(SenderPresence presence) { - return ARSenderEntity.get(this, presence); + return TypeSenderEntity.get(this, presence); } - public ARSenderId getARId() + public TypeSenderId getTypeId() { - return ARSenderId.get(this); + return TypeSenderId.get(this); } - public ARSenderId getARId(SenderPresence presence) + public TypeSenderId getTypeId(SenderPresence presence) { - return ARSenderId.get(this, presence); + return TypeSenderId.get(this, presence); } // -------------------------------------------- // // GET ALL ONLINE / OFFLINE // -------------------------------------------- // - public static final Predictate> PREDICTATE_ONLINE = new Predictate>() + public static final Predicate> PREDICATE_ONLINE = new Predicate>() { @Override public boolean apply(SenderEntity entity) @@ -153,7 +153,7 @@ public class SenderColl> extends Coll implements Se } }; - public static final Predictate> PREDICTATE_OFFLINE = new Predictate>() + public static final Predicate> PREDICATE_OFFLINE = new Predicate>() { @Override public boolean apply(SenderEntity entity) @@ -164,12 +164,12 @@ public class SenderColl> extends Coll implements Se public Collection getAllOnline() { - return this.getAll(PREDICTATE_ONLINE); + return this.getAll(PREDICATE_ONLINE); } public Collection getAllOffline() { - return this.getAll(PREDICTATE_OFFLINE); + return this.getAll(PREDICATE_OFFLINE); } // -------------------------------------------- // diff --git a/src/com/massivecraft/massivecore/util/MUtil.java b/src/com/massivecraft/massivecore/util/MUtil.java index b25778d5..cc4f73e3 100644 --- a/src/com/massivecraft/massivecore/util/MUtil.java +++ b/src/com/massivecraft/massivecore/util/MUtil.java @@ -61,7 +61,7 @@ import com.massivecraft.massivecore.CaseInsensitiveComparator; import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveCoreEngineMain; import com.massivecraft.massivecore.MassiveCoreEngineWorldNameSet; -import com.massivecraft.massivecore.Predictate; +import com.massivecraft.massivecore.Predicate; import com.massivecraft.massivecore.collections.MassiveList; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.collections.MassiveTreeSet; @@ -1289,7 +1289,7 @@ public class MUtil // TRANSFORM // -------------------------------------------- // - public static List transform(Collection items, Predictate where, Comparator orderby, Integer limit, Integer offset) + public static List transform(Collection items, Predicate where, Comparator orderby, Integer limit, Integer offset) { List ret = new ArrayList(items.size()); @@ -1353,11 +1353,11 @@ public class MUtil return new ArrayList(ret.subList(fromIndex, toIndex)); } - public static List transform(Collection items, Predictate where) { return transform(items, where, null, null, null); } - public static List transform(Collection items, Predictate where, Comparator orderby) { return transform(items, where, orderby, null, null); } - public static List transform(Collection items, Predictate where, Comparator orderby, Integer limit) { return transform(items, where, orderby, limit, null); } - public static List transform(Collection items, Predictate where, Integer limit) { return transform(items, where, null, limit, null); } - public static List transform(Collection items, Predictate where, Integer limit, Integer offset) { return transform(items, where, null, limit, offset); } + public static List transform(Collection items, Predicate where) { return transform(items, where, null, null, null); } + public static List transform(Collection items, Predicate where, Comparator orderby) { return transform(items, where, orderby, null, null); } + public static List transform(Collection items, Predicate where, Comparator orderby, Integer limit) { return transform(items, where, orderby, limit, null); } + public static List transform(Collection items, Predicate where, Integer limit) { return transform(items, where, null, limit, null); } + public static List transform(Collection items, Predicate where, Integer limit, Integer offset) { return transform(items, where, null, limit, offset); } public static List transform(Collection items, Comparator orderby) { return transform(items, null, orderby, null, null); } public static List transform(Collection items, Comparator orderby, Integer limit) { return transform(items, null, orderby, limit, null); } public static List transform(Collection items, Comparator orderby, Integer limit, Integer offset) { return transform(items, null, orderby, limit, offset); } diff --git a/src/com/massivecraft/massivecore/util/Txt.java b/src/com/massivecraft/massivecore/util/Txt.java index 9f919f98..009955e2 100644 --- a/src/com/massivecraft/massivecore/util/Txt.java +++ b/src/com/massivecraft/massivecore/util/Txt.java @@ -19,8 +19,8 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import com.massivecraft.massivecore.Predictate; -import com.massivecraft.massivecore.PredictateStartsWithIgnoreCase; +import com.massivecraft.massivecore.Predicate; +import com.massivecraft.massivecore.PredicateStartsWithIgnoreCase; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.mson.Mson; @@ -756,7 +756,7 @@ public class Txt // FILTER // -------------------------------------------- // - public static List getFiltered(Iterable elements, Predictate predictate) + public static List getFiltered(Iterable elements, Predicate predicate) { // Create Ret List ret = new ArrayList(); @@ -764,7 +764,7 @@ public class Txt // Fill Ret for (T element : elements) { - if ( ! predictate.apply(element)) continue; + if ( ! predicate.apply(element)) continue; ret.add(element); } @@ -772,14 +772,14 @@ public class Txt return ret; } - public static List getFiltered(T[] elements, Predictate predictate) + public static List getFiltered(T[] elements, Predicate predicate) { - return getFiltered(Arrays.asList(elements), predictate); + return getFiltered(Arrays.asList(elements), predicate); } public static List getStartsWithIgnoreCase(Iterable elements, String prefix) { - return getFiltered(elements, PredictateStartsWithIgnoreCase.get(prefix)); + return getFiltered(elements, PredicateStartsWithIgnoreCase.get(prefix)); } public static List getStartsWithIgnoreCase(String[] elements, String prefix)