Skip to content

Commit

Permalink
Fix logic when checking execute types.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed Apr 11, 2013
1 parent b6b0327 commit daafe44
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
Expand Up @@ -47,7 +47,7 @@ else if (aH.matchesArg("ASSERVER, AS_SERVER", arg))
if (executeType == Type.AS_NPC && scriptEntry.getNPC() == null)
throw new InvalidArgumentsException("Must have a NPC link when using AS_NPC.");

if (executeType == Type.AS_OP || executeType == Type.AS_PLAYER
if ((executeType == Type.AS_OP || executeType == Type.AS_PLAYER)
&& scriptEntry.getPlayer() == null)
throw new InvalidArgumentsException("Must have a Player link when using AS_OP or AS_PLAYER.");

Expand Down
72 changes: 64 additions & 8 deletions src/main/java/net/aufdemrand/denizen/utilities/arguments/aH.java
Expand Up @@ -31,17 +31,74 @@
public class aH {

public enum ArgumentType {
LivingEntity, Item, Boolean, Custom, Double, Float, Integer, String, Word, Location, Script, Duration
LivingEntity,
Item,
Boolean,
Custom,
Double,
Float,
Integer,
String,
Word,
Location,
Script,
Duration
}

public static String debugObj(String prefix, String value) {
return "<G>" + prefix + "='<Y>" + value + "<G>' ";
/**
* To be used with the dBuggers' .report to provide debug output for
* objects.
*
* @param prefix name/type/simple description of the object being reported
* @param value object being reported will report the value of toString()
*
* @return color coded debug report
*/
public static String debugObj(String prefix, Object value) {
return "<G>" + prefix + "='<Y>" + value.toString() + "<G>' ";
}

/**
* To be used with the dBuggers' .report to provide debug output for
* objects that may have some kind of id or type also associated with
* the object.
*
* @param prefix name/type/simple description of the object being reported
* @param id additional id/type of the object
* @param value object being reported will report the value of toString()
*
* @return color coded debug report
*/
public static String debugUniqueObj(String prefix, String id, Object value) {
return "<G>" + prefix + "='<A>" + id + "<Y>(" + value.toString() + ")<G>' ";
}

private class Argument {
String raw_value;
String prefix;
String value;
ArgumentType argument_type;
Object argument_object;

public Argument(String string) {
raw_value = string;

string = string.trim();
int first_colon = string.indexOf(":");
int first_space = string.indexOf(" ");

if (first_colon < first_space)

}

}

public static String debugUniqueObj(String prefix, String id, String value) {
return "<G>" + prefix + "='<A>" + id + "<Y>(" + value + ")<G>' ";
public static Argument interpret(String arg) {
// Trim leading/trailing whitespace

}


final static Pattern doublePtrn = Pattern.compile("(-)?(?:(?:\\d+)|)(?:(?:\\.\\d+)|)");
final static Pattern floatPtrn = Pattern.compile("^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$");
final static Pattern integerPtrn = Pattern.compile("(-)?\\d+");
Expand Down Expand Up @@ -257,9 +314,8 @@ public static double getDoubleFrom(String arg) {
*
*/
public static EntityType getEntityFrom(String arg) {
Matcher m = matchesEntityPtrn.matcher(arg);
if (m.matches()) {
// Match against valid EntityTypes using Bukkit enum


for (EntityType validEntity : EntityType.values())
if (m.group(1).equalsIgnoreCase(validEntity.name()))
return validEntity;
Expand Down

0 comments on commit daafe44

Please sign in to comment.