Skip to content

Commit

Permalink
Update command registry.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jul 31, 2013
1 parent 0816a70 commit 868db49
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
Expand Up @@ -59,7 +59,7 @@ public void registerCoreMembers() {
"ANCHOR", "anchor [id:<name>] [assume/add/remove/walkto/walknear] (range:<#>)", 2);

registerCoreMember(AnimateCommand.class,
"ANIMATE", "animate [entities:<entity>|...] [animation:<name>]", 1);
"ANIMATE", "animate [<entity>|...] [animation:<name>]", 1);

registerCoreMember(AnimateChestCommand.class,
"ANIMATECHEST", "animatechest [<location>] ({open}/close) (sound:{true}/false)", 1);
Expand All @@ -71,16 +71,16 @@ public void registerCoreMembers() {
"ASSIGNMENT", "assignment [{set}/remove] (script:<name>)", 1);

registerCoreMember(AttackCommand.class,
"ATTACK", "attack (cancel) (entities:<entity>|...) (target:<entity>)", 0);
"ATTACK", "attack (cancel) (<entity>|...) (target:<entity>)", 0);

registerCoreMember(BreakCommand.class,
"BREAK", "break [<location>] (entity:<entity>) (radius:<#.#>)", 1);

registerCoreMember(BurnCommand.class,
"BURN", "burn [entities:<entity>|...] (duration:<value>)", 1);
"BURN", "burn [<entity>|...] (duration:<value>)", 1);

registerCoreMember(CastCommand.class,
"CAST", "cast [<effect>] (duration:<#>) (power:<#>) (entities:<entity>|...)", 1);
"CAST", "cast [<effect>] (duration:<value>) (power:<#>) (<entity>|...)", 1);

registerCoreMember(ChatCommand.class,
"CHAT", "chat [\"<text>\"] (targets:<entity>|...)", 1);
Expand All @@ -89,7 +89,7 @@ public void registerCoreMembers() {
"CHUNKLOAD", "chunkload ({add}/remove/removeall) [<location>] (duration:<value>)", 1);

registerCoreMember(CooldownCommand.class,
"COOLDOWN", "cooldown (duration:<#>) (global) (script:<name>)", 1);
"COOLDOWN", "cooldown (duration:<value>) (global) (script:<name>)", 1);

registerCoreMember(CopyBlockCommand.class,
"COPYBLOCK", "copyblock [location:<location>] [to:<location>]", 1);
Expand All @@ -107,13 +107,13 @@ public void registerCoreMembers() {
"DISENGAGE", "disengage", 0);

registerCoreMember(DisplayItemCommand.class,
"DISPLAYITEM", "displayitem (remove) [<item>] [<location>] (duration:<#>)", 2);
"DISPLAYITEM", "displayitem (remove) [<item>] [<location>] (duration:<value>)", 2);

registerCoreMember(DropCommand.class,
"DROP", "drop [<item>/<entity>/<xp>] [<location>] (qty:<#>)", 1);

registerCoreMember(EngageCommand.class,
"ENGAGE", "engage (duration:<#>)", 0);
"ENGAGE", "engage (duration:<value>)", 0);

registerCoreMember(EngraveCommand.class,
"ENGRAVE", "engrave (set/remove)", 0);
Expand Down Expand Up @@ -146,10 +146,10 @@ public void registerCoreMembers() {
"FISH", "fish (catchfish) (stop) (<location>) (catchpercent:<#>)", 1);

registerCoreMember(FlagCommand.class,
"FLAG", "flag ({player}/npc/global) [<name>([<#>])](:<action>)[:<value>] (duration:<#>)", 1);
"FLAG", "flag ({player}/npc/global) [<name>([<#>])](:<action>)[:<value>] (duration:<value>)", 1);

registerCoreMember(FlyCommand.class,
"FLY", "fly (cancel) [entities:<entity>|...] (origin:<location>) (destinations:<location>|...) (speed:<#.#>)", 1);
"FLY", "fly (cancel) [<entity>|...] (origin:<location>) (destinations:<location>|...) (speed:<#.#>)", 1);

registerCoreMember(FollowCommand.class,
"FOLLOW", "follow (stop) (lead:<#.#>)", 0);
Expand All @@ -167,13 +167,13 @@ public void registerCoreMembers() {
"HEAD", "head (player) [skin:<name>]", 0);

registerCoreMember(HealCommand.class,
"HEAL", "heal (<#.#>) (entities:<entity>|...)", 0);
"HEAL", "heal (<#.#>) (<entity>|...)", 0);

registerCoreMember(HealthCommand.class,
"HEALTH", "health (state:true/false/toggle) (set_max:<#>)", 1);

registerCoreMember(HurtCommand.class,
"HURT", "hurt (<#.#>) (entities:<entity>|...)", 0);
"HURT", "hurt (<#.#>) (<entity>|...)", 0);

registerCoreMember(IfCommand.class,
"IF", "if [<value>] (!)(<operator> <value>) (&&/|| ...) [<commands>] (else <commands>)", 2);
Expand All @@ -200,7 +200,7 @@ public void registerCoreMembers() {
"MIDI", "midi [file:<name>] [<location>/listeners:<player>|...] (tempo:<#.#>)", 1);

registerCoreMember(MountCommand.class,
"MOUNT", "mount (cancel) [entities:<entity>|...] (<location>)", 0);
"MOUNT", "mount (cancel) [<entity>|...] (<location>)", 0);

registerCoreMember(ModifyBlockCommand.class,
"MODIFYBLOCK", "modifyblock [<location>] [<block>] (radius:<#>) (height:<#>) (depth:<#>)", 2);
Expand Down Expand Up @@ -239,7 +239,7 @@ public void registerCoreMembers() {
"RANDOM", "random [<#>]", 1);

registerCoreMember(RemoveCommand.class,
"REMOVE", "remove [entities:<entity>|...] (region:<name>)", 0);
"REMOVE", "remove [<entity>|...] (region:<name>)", 0);

registerCoreMember(RenameCommand.class,
"RENAME", "rename [<npc>] [<name>]", 1);
Expand All @@ -248,7 +248,7 @@ public void registerCoreMembers() {
"RESET", "reset [fails/finishes/cooldown] (script:<name>)", 1);

registerCoreMember(RunCommand.class,
"RUN", "run [<script>] (path:<name>) (as:<player>/<npc>) (define:<element>|...) (id:<name>) (delay:<duration>) (loop) (qty:<#>)", 1);
"RUN", "run [<script>] (path:<name>) (as:<player>/<npc>) (define:<element>|...) (id:<name>) (delay:<value>) (loop) (qty:<#>)", 1);

registerCoreMember(RuntaskCommand.class,
"RUNTASK", "runtask [<name>] (instantly) (queue(:<name>)) (delay:<#>) (define:<element>|...)", 1);
Expand All @@ -260,7 +260,7 @@ public void registerCoreMembers() {
"SCRIBE", "scribe [script:<name>] (give/drop/equip) (<item>) (<location>)", 1);

registerCoreMember(ShootCommand.class,
"SHOOT", "shoot [entities:<entity>|...] (origin:<player>/<npc>) (destination:<location>) (speed:<#.#>) (script:<name>)", 1);
"SHOOT", "shoot [<entity>|...] (origin:<player>/<npc>) (destination:<location>) (speed:<#.#>) (duration:<value>) (script:<name>)", 1);

registerCoreMember(ShowFakeCommand.class,
"SHOWFAKE", "showfake [<material>] [<location>|...] (d:<duration>{10s})", 2);
Expand All @@ -272,7 +272,7 @@ public void registerCoreMembers() {
"SIT", "sit (<location>)", 0);

registerCoreMember(SpawnCommand.class,
"SPAWN", "spawn [entities:<entity>|...] (<location>) (target:<entity>)", 1);
"SPAWN", "spawn [<entity>|...] (<location>) (target:<entity>)", 1);

registerCoreMember(StandCommand.class,
"STAND", "stand", 0);
Expand All @@ -281,13 +281,13 @@ public void registerCoreMembers() {
"STRIKE", "strike (no_damage) [<location>]", 1);

registerCoreMember(SwitchCommand.class,
"SWITCH", "switch [<location>] (state:[{toggle}/on/off]) (duration:<#>)", 1);
"SWITCH", "switch [<location>] (state:[{toggle}/on/off]) (duration:<value>)", 1);

registerCoreMember(TakeCommand.class,
"TAKE", "take [money/iteminhand/<item>] (qty:<#>)", 1);

registerCoreMember(TeleportCommand.class,
"TELEPORT", "teleport (entities:<entity>|...) (<location>)", 1);
"TELEPORT", "teleport (<entity>|...) (<location>)", 1);

registerCoreMember(TimeCommand.class,
"TIME", "time [type:{global}/player] [<value>] (world:<name>)", 1);
Expand All @@ -302,7 +302,7 @@ public void registerCoreMembers() {
"VULNERABLE", "vulnerable (state:{true}/false/toggle)", 0);

registerCoreMember(WaitCommand.class,
"WAIT", "wait (duration:<#>) (queue:<name>)", 0);
"WAIT", "wait (duration:<value>) (queue:<name>)", 0);

registerCoreMember(WalkCommand.class,
"WALK, WALKTO", "walk [<location>] (speed:<#>) (auto_range)", 1);
Expand Down
Expand Up @@ -76,6 +76,13 @@ else if (!scriptEntry.hasObject("speed")
scriptEntry.addObject("speed", arg.asElement());
}

else if (!scriptEntry.hasObject("height")
&& arg.matchesPrimitive(aH.PrimitiveType.Double)
&& arg.matchesPrefix("height, h")) {
// Add value
scriptEntry.addObject("height", arg.asElement());
}

else if (!scriptEntry.hasObject("script")
&& arg.matchesArgumentType(dScript.class)) {
// add value
Expand All @@ -92,7 +99,8 @@ else if (!scriptEntry.hasObject("script")
// Use a default speed of 1.5 if one is not specified

scriptEntry.defaultObject("speed", new Element(1.5));
scriptEntry.defaultObject("duration", new Element("80t"));
scriptEntry.defaultObject("height", new Element(0));
scriptEntry.defaultObject("duration", Duration.valueOf("80t"));

// Check to make sure required arguments have been filled

Expand All @@ -119,6 +127,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
final Element speed = (Element) scriptEntry.getObject("speed");
final dScript script = (dScript) scriptEntry.getObject("script");
final double height = ((Element) scriptEntry.getObject("height")).asDouble();
final int maxTicks = ((Duration) scriptEntry.getObject("duration")).getTicksAsInt() / 2;

// Report to dB
Expand Down Expand Up @@ -169,7 +178,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
int runs = 0;

public void run() {

if (runs < maxTicks && lastEntity.isValid())
{
Vector v1 = lastEntity.getLocation().toVector();
Expand Down Expand Up @@ -204,9 +213,10 @@ public void run() {
{
Map<String, String> context = new HashMap<String, String>();
context.put("1", lastEntity.getLocation().getX() + "," + lastEntity.getLocation().getY() + "," + lastEntity.getLocation().getZ() + "," + lastEntity.getLocation().getWorld().getName());

context.put("2", "e@" + lastEntity.getEntityId());

((TaskScriptContainer) script.getContainer()).setSpeed(new Duration(0))
.runTaskScript(scriptEntry.getPlayer(), scriptEntry.getNPC(), context);
.runTaskScript(scriptEntry.getPlayer(), scriptEntry.getNPC(), context);
}

}
Expand Down

0 comments on commit 868db49

Please sign in to comment.