Search in sources :

Example 76 with LocationTag

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);
}
Also used : MaterialTag(com.denizenscript.denizen.objects.MaterialTag) LocationTag(com.denizenscript.denizen.objects.LocationTag) PlayerChangesSignScriptEvent(com.denizenscript.denizen.events.player.PlayerChangesSignScriptEvent) SignChangeEvent(org.bukkit.event.block.SignChangeEvent)

Example 77 with LocationTag

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);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) EventHandler(org.bukkit.event.EventHandler)

Example 78 with LocationTag

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);
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) ItemTag(com.denizenscript.denizen.objects.ItemTag) EventHandler(org.bukkit.event.EventHandler)

Example 79 with LocationTag

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]));
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) BlockState(org.bukkit.block.BlockState) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 80 with LocationTag

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);
        }
    }
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) MaterialTag(com.denizenscript.denizen.objects.MaterialTag) Block(org.bukkit.block.Block) List(java.util.List) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) BlockData(org.bukkit.block.data.BlockData)

Aggregations

LocationTag (com.denizenscript.denizen.objects.LocationTag)133 EventHandler (org.bukkit.event.EventHandler)69 EntityTag (com.denizenscript.denizen.objects.EntityTag)45 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)40 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)33 List (java.util.List)21 ItemTag (com.denizenscript.denizen.objects.ItemTag)18 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)15 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)14 ListTag (com.denizenscript.denizencore.objects.core.ListTag)13 NPCTag (com.denizenscript.denizen.objects.NPCTag)12 Location (org.bukkit.Location)11 ArrayList (java.util.ArrayList)8 Entity (org.bukkit.entity.Entity)8 FakeBlock (com.denizenscript.denizen.utilities.blocks.FakeBlock)6 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)6 Player (org.bukkit.entity.Player)6 Vector (org.bukkit.util.Vector)6 UUID (java.util.UUID)5 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)5