Search in sources :

Example 31 with Block

use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.

the class EntityExplodesScriptEvent method onEntityExplodes.

@EventHandler
public void onEntityExplodes(EntityExplodeEvent event) {
    entity = new dEntity(event.getEntity());
    location = new dLocation(event.getLocation());
    strength = event.getYield();
    blocks = new dList();
    blockSet = false;
    for (Block block : event.blockList()) {
        blocks.add(new dLocation(block.getLocation()).identifySimple());
    }
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    if (blockSet) {
        event.blockList().clear();
        if (blocks.size() > 0) {
            event.blockList().clear();
            for (String loc : blocks) {
                dLocation location = dLocation.valueOf(loc);
                event.blockList().add(location.getWorld().getBlockAt(location));
            }
        }
    }
    event.setYield(strength);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Block(org.bukkit.block.Block) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 32 with Block

use of org.bukkit.block.Block in project Towny by ElgarL.

the class CellUnderAttack method destroyFlag.

public void destroyFlag() {
    flagLightBlock.setType(Material.AIR);
    flagBlock.setType(Material.AIR);
    flagBaseBlock.setType(Material.AIR);
    for (Block block : beaconFlagBlocks) block.setType(Material.AIR);
    for (Block block : beaconWireframeBlocks) block.setType(Material.AIR);
}
Also used : Block(org.bukkit.block.Block)

Example 33 with Block

use of org.bukkit.block.Block in project Towny by ElgarL.

the class CellUnderAttack method updateFlag.

@SuppressWarnings("deprecation")
public void updateFlag() {
    DyeColor[] woolColors = TownyWarConfig.getWoolColors();
    if (flagColorId < woolColors.length) {
        System.out.println(String.format("Flag at %s turned %s.", getCellString(), woolColors[flagColorId].toString()));
        int woolId = BukkitTools.getMaterialId(Material.WOOL);
        byte woolData = woolColors[flagColorId].getDyeData();
        BukkitTools.setTypeIdAndData(flagBlock, woolId, woolData, true);
        for (Block block : beaconFlagBlocks) BukkitTools.setTypeIdAndData(block, woolId, woolData, true);
    }
}
Also used : Block(org.bukkit.block.Block) DyeColor(org.bukkit.DyeColor)

Example 34 with Block

use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.

the class ProjectileHitsScriptEvent method onProjectileHits.

@EventHandler
public void onProjectileHits(ProjectileHitEvent event) {
    projectile = new dEntity(event.getEntity());
    if (projectile.getLocation() == null) {
        // No, I can't explain how or why this would ever happen... nonetheless, it appears it does happen sometimes.
        return;
    }
    if (Double.isNaN(projectile.getLocation().getDirection().normalize().getX())) {
        // I can't explain this one either. It also chooses to happen whenever it pleases.
        return;
    }
    Block block = null;
    try {
        BlockIterator bi = new BlockIterator(projectile.getLocation().getWorld(), projectile.getLocation().toVector(), projectile.getLocation().getDirection().normalize(), 0, 4);
        while (bi.hasNext()) {
            block = bi.next();
            if (block.getTypeId() != 0) {
                break;
            }
        }
    } catch (IllegalStateException ex) {
        // As this error happens on no fault of the user, display no error message... just cancel the event.
        return;
    }
    if (block == null) {
        return;
    }
    material = dMaterial.getMaterialFrom(block.getType(), block.getData());
    shooter = projectile.getShooter();
    location = new dLocation(block.getLocation());
    this.event = event;
    fire();
}
Also used : BlockIterator(org.bukkit.util.BlockIterator) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Block(org.bukkit.block.Block) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 35 with Block

use of org.bukkit.block.Block in project Denizen-For-Bukkit by DenizenScript.

the class PortalCreateScriptEvent method onPortalCreate.

@EventHandler
public void onPortalCreate(PortalCreateEvent event) {
    world = new dWorld(event.getWorld());
    reason = new Element(event.getReason().toString());
    blocks = new dList();
    for (Block block : event.getBlocks()) {
        blocks.add(new dLocation(block.getLocation()).identify());
    }
    this.event = event;
    cancelled = event.isCancelled();
    fire();
    event.setCancelled(cancelled);
}
Also used : Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Block(org.bukkit.block.Block) net.aufdemrand.denizen.objects.dWorld(net.aufdemrand.denizen.objects.dWorld) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Block (org.bukkit.block.Block)187 EventHandler (org.bukkit.event.EventHandler)62 Player (org.bukkit.entity.Player)42 Location (org.bukkit.Location)30 BlockState (org.bukkit.block.BlockState)28 Sign (org.bukkit.block.Sign)24 Material (org.bukkit.Material)23 BlockFace (org.bukkit.block.BlockFace)23 GlowBlock (net.glowstone.block.GlowBlock)19 ASkyBlock (com.wasteofplastic.acidisland.ASkyBlock)16 MaterialData (org.bukkit.material.MaterialData)16 ArrayList (java.util.ArrayList)15 World (org.bukkit.World)14 Entity (org.bukkit.entity.Entity)14 ItemStack (org.bukkit.inventory.ItemStack)14 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)13 Vector (org.bukkit.util.Vector)13 IOException (java.io.IOException)7 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)6 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)5