Skip to content

Commit

Permalink
Update playsound
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 27, 2013
1 parent 58f7ef3 commit b79e531
Showing 1 changed file with 17 additions and 20 deletions.
Expand Up @@ -52,11 +52,7 @@ else if (!scriptEntry.hasObject("pitch")

else if (!scriptEntry.hasObject("sound")
&& arg.matchesPrimitive(aH.PrimitiveType.String)) {
try {
scriptEntry.addObject("sound", Sound.valueOf(arg.asElement().asString().toUpperCase()));
} catch (Exception e) {
dB.echoError("Invalid sound!");
}
scriptEntry.addObject("sound", arg.asElement());
}

else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg.raw_value);
Expand All @@ -76,21 +72,22 @@ else if (!scriptEntry.hasObject("sound")
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

// Extract objects from ScriptEntry
Location location = (Location) scriptEntry.getObject("location");
Sound sound = (Sound) scriptEntry.getObject("sound");
Float volume = ((Element) scriptEntry.getObject("volume")).asFloat();
Float pitch = ((Element) scriptEntry.getObject("pitch")).asFloat();

// Debugger
dB.echoApproval("Executing '" + getName() + "': "
+ "Location='" + location.getX() + "," + location.getY()
+ "," + location.getZ() + "," + location.getWorld().getName() + "', "
+ "Sound='" + sound.toString() + ", "
+ "Volume/Pitch='" + volume + "/" + pitch + "'");

// Play the sound
location.getWorld().playSound(location, sound, volume, pitch);
dLocation location = (dLocation) scriptEntry.getObject("location");
Element sound = scriptEntry.getElement("sound");
Element volume = scriptEntry.getElement("volume");
Element pitch = scriptEntry.getElement("pitch");

dB.report(getName(),
location.debug() +
sound.debug() +
volume.debug() +
pitch.debug());

try {
location.getWorld().playSound(location, Sound.valueOf(sound.asString().toUpperCase()), volume.asFloat(), pitch.asFloat());
} catch (Exception e) {
dB.echoError("Invalid sound!");
}
}

}

0 comments on commit b79e531

Please sign in to comment.