// Extract objects from ScriptEntry
List<dLocation> locations = (List<dLocation>) scriptEntry.getObject("location");
List<dPlayer> targets = (List<dPlayer>) scriptEntry.getObject("targets");
Effect effect = (Effect) scriptEntry.getObject("effect");
ParticleEffect particleEffect = (ParticleEffect) scriptEntry.getObject("particleeffect");
Element iconcrack = scriptEntry.getElement("iconcrack");
Element radius = scriptEntry.getElement("radius");
Element data = scriptEntry.getElement("data");
Element qty = scriptEntry.getElement("qty");
Element offset = scriptEntry.getElement("offset");
// Report to dB
dB.report(scriptEntry, getName(), (effect != null ? aH.debugObj("effect", effect.name()) :
particleEffect != null ? aH.debugObj("special effect", particleEffect.name()) :
iconcrack.debug()) +
aH.debugObj("locations", locations.toString()) +
(targets != null ? aH.debugObj("targets", targets.toString()): "") +
radius.debug() +
data.debug() +
qty.debug() +
(effect != null ? "" : offset.debug()));
for (dLocation location: locations) {
// Slightly increase the location's Y so effects don't seem to come out of the ground
location.add(0, 1, 0);
// Play the Bukkit effect the number of times specified
if (effect != null) {
for (int n = 0; n < qty.asInt(); n++) {
if (targets != null) {
for (dPlayer player: targets)
if (player.isValid() && player.isOnline()) player.getPlayerEntity().playEffect(location, effect, data.asInt());
}
else {
location.getWorld().playEffect(location, effect, data.asInt(), radius.asInt());
}
}
}
// Play a ParticleEffect
else if (particleEffect != null) {
float os = offset.asFloat();
List<Player> players = new ArrayList<Player>();
if (targets == null)
players = ParticleEffect.getPlayersInRange(location, radius.asDouble());
else {
for (dPlayer player: targets)
if (player.isValid() && player.isOnline()) players.add(player.getPlayerEntity());
}
particleEffect.display(location, os, os, os, data.asFloat(), qty.asInt(), players);
}
// Play an iconcrack (item break) effect
else {
float os = offset.asFloat();