Skip to content

Commit

Permalink
Add spawned entities context back to Spawn command after it was remov…
Browse files Browse the repository at this point in the history
…ed by mistake by someone else. Fix "shot_entities" context in Shoot.
  • Loading branch information
davidcernat committed Sep 4, 2013
1 parent e195a6d commit cca5439
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -168,7 +168,7 @@ public void onEnable() {

dB.echoError("Your Denizen config file is from a different version. " +
"Some settings will not be available unless you generate a new one. " +
"This is easily done by stopping the server, deleting the current config.yml file in the Denizen folder" +
"This is easily done by stopping the server, deleting the current config.yml file in the Denizen folder " +
"and restarting the server.");
}

Expand Down
Expand Up @@ -11,7 +11,7 @@

public class dMaterial implements dObject {

final static Pattern materialPattern = Pattern.compile("(?:m@)?(\\w+)[:,]?(\\d+)?", Pattern.CASE_INSENSITIVE);
final static Pattern materialPattern = Pattern.compile("(?:m@)?(\\w+)[,:]?(\\d+)?", Pattern.CASE_INSENSITIVE);

//////////////////
// OBJECT FETCHER
Expand Down
Expand Up @@ -188,7 +188,10 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
aH.debugObj("speed", speed) + aH.debugObj("duration", new Duration(maxRuns * 2)) : "") +
(script != null ? aH.debugObj("script", script) : ""));

dList shot_entities = new dList();
// Keep a dList of entities that can be called using %entities%
// later in the script queue

dList entityList = new dList();

// Go through all the entities, spawning/teleporting and rotating them

Expand All @@ -201,10 +204,11 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
entity.teleport(originLocation);
}

// Add the spawned entity to the 'shot_entities' context
try {
shot_entities.add("e@" + entity.getBukkitEntity().getEntityId());
} catch (Exception e) { dB.echoError("Entity failed to spawn!"); }
// Only add to entityList after the entities have been
// spawned, otherwise you'll get something like "e@skeleton"
// instead of "e@57" on it

entityList.add(entity.toString());

Rotation.faceLocation(entity.getBukkitEntity(), destination);

Expand All @@ -213,9 +217,10 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
}
}

// Add shot_entities to context so that the specific entities created/spawned
// can be 'fetched'.
scriptEntry.addObject("shot_entities", shot_entities);
// Add entities to context so that the specific entities created/spawned
// can be fetched.

scriptEntry.getResidingQueue().addDefinition("shot_entities", entityList.toString());

Position.mount(Conversion.convert(entities));

Expand Down
Expand Up @@ -81,7 +81,7 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
// Keep a dList of entities that can be called using %entities%
// later in the script queue

dList entityList = new dList("");
dList entityList = new dList();

// Go through all the entities and spawn them or teleport them,
// then set their targets if applicable
Expand All @@ -105,8 +105,10 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept
entity.target(target.getLivingEntity());
}
}




// Add entities to context so that the specific entities created/spawned
// can be fetched.

scriptEntry.getResidingQueue().addDefinition("spawned_entities", entityList.toString());
}
}

0 comments on commit cca5439

Please sign in to comment.