use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class DenizenPacketListenerImpl method handleSignUpdate.
@Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
if (fakeSignExpected != null && packet.getPos().equals(fakeSignExpected)) {
fakeSignExpected = null;
PlayerChangesSignScriptEvent evt = (PlayerChangesSignScriptEvent) PlayerChangesSignScriptEvent.instance.clone();
evt.cancelled = false;
evt.material = new MaterialTag(org.bukkit.Material.OAK_WALL_SIGN);
evt.location = new LocationTag(player.getBukkitEntity().getLocation());
LocationTag loc = evt.location.clone();
loc.setY(0);
evt.event = new SignChangeEvent(loc.getBlock(), player.getBukkitEntity(), packet.getLines());
evt.fire(evt.event);
}
super.handleSignUpdate(packet);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class LightningStrikesScriptEvent method onLightningStrikes.
@EventHandler
public void onLightningStrikes(LightningStrikeEvent event) {
location = new LocationTag(event.getLightning().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class LingeringPotionSplashScriptEvent method onLingeringPotionSplash.
@EventHandler
public void onLingeringPotionSplash(LingeringPotionSplashEvent event) {
item = new ItemTag(event.getEntity().getItem());
location = new LocationTag(event.getAreaEffectCloud().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class SignCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
String direction = scriptEntry.hasObject("direction") ? ((ElementTag) scriptEntry.getObject("direction")).asString() : null;
ElementTag typeElement = scriptEntry.getElement("type");
ListTag text = scriptEntry.getObjectTag("text");
LocationTag location = scriptEntry.getObjectTag("location");
MaterialTag material = scriptEntry.getObjectTag("material");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), typeElement, location, db("direction", direction), material, text);
}
Type type = Type.valueOf(typeElement.asString().toUpperCase());
Block sign = location.getBlock();
if (type != Type.AUTOMATIC || !isAnySign(sign.getType())) {
if (type == Type.WALL_SIGN) {
BlockFace bf;
if (direction != null) {
bf = Utilities.chooseSignRotation(direction);
} else {
bf = Utilities.chooseSignRotation(sign);
}
setWallSign(sign, bf, material);
} else {
sign.setType(material == null ? Material.OAK_SIGN : material.getMaterial(), false);
if (direction != null) {
Utilities.setSignRotation(sign.getState(), direction);
}
}
} else if (!isAnySign(sign.getType())) {
if (sign.getRelative(BlockFace.DOWN).getType().isSolid()) {
sign.setType(material == null ? Material.OAK_SIGN : material.getMaterial(), false);
} else {
BlockFace bf = Utilities.chooseSignRotation(sign);
setWallSign(sign, bf, material);
}
}
BlockState signState = sign.getState();
Utilities.setSignLines((Sign) signState, text.toArray(new String[4]));
}
use of com.denizenscript.denizen.objects.LocationTag in project Denizen-For-Bukkit by DenizenScript.
the class AdjustBlockCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag mechanismName = scriptEntry.getElement("mechanism");
ObjectTag value = scriptEntry.getObjectTag("mechanism_value");
ElementTag noPhysics = scriptEntry.getElement("no_physics");
List<LocationTag> locations = (List<LocationTag>) scriptEntry.getObject("locations");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("locations", locations), mechanismName, noPhysics, value);
}
boolean doPhysics = noPhysics == null || !noPhysics.asBoolean();
for (LocationTag location : locations) {
Block block = location.getBlock();
BlockData data = block.getBlockData();
MaterialTag specialMaterial = new MaterialTag(data);
Mechanism mechanism = new Mechanism(mechanismName.asString(), value, scriptEntry.getContext());
specialMaterial.safeAdjust(mechanism);
if (doPhysics) {
block.setBlockData(data, false);
applyPhysicsAt(location);
} else {
ModifyBlockCommand.setBlock(block.getLocation(), specialMaterial, false, null);
}
}
}
Aggregations