use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class LightCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
LocationTag location = scriptEntry.getObjectTag("location");
ElementTag light = scriptEntry.getElement("light");
ElementTag reset = scriptEntry.getElement("reset");
DurationTag duration = scriptEntry.getObjectTag("duration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), location, reset, light, duration);
}
if (!Utilities.isLocationYSafe(location)) {
Debug.echoError(scriptEntry, "Invalid light location!");
return;
}
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
location.clone().add(x * 16, 0, z * 16).getChunk().load();
}
}
if (!reset.asBoolean()) {
int brightness = light.asInt();
if (brightness < 0 || brightness > 15) {
Debug.echoError("Light brightness must be between 0 and 15, inclusive!");
return;
}
NMSHandler.getInstance().createBlockLight(location, brightness, duration == null ? 0 : duration.getTicks());
} else {
BlockLight.removeLight(location);
}
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class PlaySoundCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
List<LocationTag> locations = (List<LocationTag>) scriptEntry.getObject("locations");
List<PlayerTag> players = (List<PlayerTag>) scriptEntry.getObject("entities");
ElementTag soundElement = scriptEntry.getElement("sound");
ElementTag volumeElement = scriptEntry.argForPrefixAsElement("volume", "1");
ElementTag pitchElement = scriptEntry.argForPrefixAsElement("pitch", "1");
boolean custom = scriptEntry.argAsBoolean("custom");
ElementTag sound_category = scriptEntry.argForPrefixAsElement("sound_category", "MASTER");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("locations", locations), db("entities", players), soundElement, volumeElement, pitchElement, db("custom", custom));
}
String sound = soundElement.asString();
float volume = volumeElement.asFloat();
float pitch = pitchElement.asFloat();
String category = sound_category.asString().toUpperCase();
try {
if (players == null) {
if (custom) {
for (LocationTag location : locations) {
NMSHandler.getSoundHelper().playSound(null, location, sound, volume, pitch, category);
}
} else {
for (LocationTag location : locations) {
NMSHandler.getSoundHelper().playSound(null, location, Sound.valueOf(sound.toUpperCase()), volume, pitch, category);
}
}
} else if (locations != null) {
for (LocationTag location : locations) {
for (PlayerTag player : players) {
if (custom) {
NMSHandler.getSoundHelper().playSound(player.getPlayerEntity(), location, sound, volume, pitch, category);
} else {
NMSHandler.getSoundHelper().playSound(player.getPlayerEntity(), location, Sound.valueOf(sound.toUpperCase()), volume, pitch, category);
}
}
}
} else {
for (PlayerTag player : players) {
if (custom) {
NMSHandler.getSoundHelper().playSound(player.getPlayerEntity(), player.getLocation(), sound, volume, pitch, category);
} else {
NMSHandler.getSoundHelper().playSound(player.getPlayerEntity(), player.getLocation(), Sound.valueOf(sound.toUpperCase()), volume, pitch, category);
}
}
}
} catch (Exception e) {
Debug.echoDebug(scriptEntry, "Unable to play sound.");
if (Debug.verbose) {
Debug.echoError(e);
}
}
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerItemTakesDamageScriptEvent method onPlayerItemTakesDamage.
@EventHandler
public void onPlayerItemTakesDamage(PlayerItemDamageEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
item = new ItemTag(event.getItem());
location = new LocationTag(event.getPlayer().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerUsesPortalScriptEvent method onPlayerEntersPortal.
@EventHandler
public void onPlayerEntersPortal(PlayerPortalEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
entity = new EntityTag(event.getPlayer());
to = event.getTo() == null ? null : new LocationTag(event.getTo());
from = new LocationTag(event.getFrom());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerWalkScriptEvent method onPlayerMoves.
@EventHandler
public void onPlayerMoves(PlayerMoveEvent event) {
if (EntityTag.isNPC(event.getPlayer())) {
return;
}
old_location = new LocationTag(event.getFrom());
new_location = new LocationTag(event.getTo());
this.event = event;
fire(event);
}
Aggregations