Skip to content

Commit

Permalink
More work to the aH/argument objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
aufdemrand committed May 21, 2013
1 parent 03bbbb3 commit 6a8166d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 31 deletions.
58 changes: 29 additions & 29 deletions src/main/java/net/aufdemrand/denizen/arguments/aH.java
Expand Up @@ -33,34 +33,6 @@
*/
public class aH {

/**
* 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>' ";
}

public enum PrimitiveType { Float, Double, Integer, Boolean, String, Word}

final static Pattern floatPrimitive = Pattern.compile("^[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?$");
Expand Down Expand Up @@ -164,7 +136,6 @@ public <T extends dScriptArgument> T asType(Class<? extends dScriptArgument> cla

return null;
}

}


Expand Down Expand Up @@ -200,6 +171,35 @@ public static List<Argument> interpret(List<String> args) {
// OLD SKOOL METHODS


/**
* 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>' ";
}


public enum ArgumentType {
LivingEntity,
Item,
Expand Down
@@ -0,0 +1,14 @@
package net.aufdemrand.denizen.scripts.commands;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ScriptCommand {

String value();

}
Expand Up @@ -25,6 +25,22 @@
*/
public class AnchorCommand extends AbstractCommand {

public String getHelp() {
return "Controls NPCs' anchors. Anchors are 'bookmarked locations'" +
"stored at the NPC-level. Valid actions are Add, Remove, " +
"Assume Walk_To, and Walk_Near. \n" +
" \n" +
"Use to add or remove an anchor from a NPC. \n" +
"- anchor add id:pride_rock location:<npc.location> \n" +
"- anchor remove id:the_jungle \n" +
"Use to 'teleport' the npc directly to an existing anchor. \n" +
"- anchor assume id:bedroom \n" +
"Use to make a NPC navigate to or near an anchor for easy" +
"'waypoint behavior'. \n" +
"- anchor walkto id:anchor_1 \n" +
"- anchor walknear id:front_porch range:5";
}

private enum Action { ADD, REMOVE, ASSUME, WALKTO, WALKNEAR }

@Override
Expand Down Expand Up @@ -98,8 +114,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
return;

case WALKNEAR:
npc.getNavigator().setTarget(Utilities
.getWalkableLocationNear(npc.getCitizen().getTrait(Anchors.class)
npc.getNavigator().setTarget(
Utilities.getWalkableLocationNear(npc.getCitizen().getTrait(Anchors.class)
.getAnchor(id.asString()).getLocation(), range.asInt()));
return;

Expand Down

0 comments on commit 6a8166d

Please sign in to comment.