Package org.bukkit.block

Examples of org.bukkit.block.Block


        return false;
    }

    public void onBlockPlace(BlockPlaceEvent event) {
        Block b = event.getBlock();

        // If the event didn't happen in the region, or if in edit mode, ignore
        if (!arena.getRegion().contains(b.getLocation()) || arena.inEditMode()) {
            return;
        }

        // If the arena isn't running, or if the player isn't in the arena, cancel.
        if (!arena.isRunning() || !arena.inArena(event.getPlayer())) {
            // But only if we're protecting the region
            if (protect) {
                event.setCancelled(true);
            }
            return;
        }

        // If the block is TNT, set its planter
        if (b.getType() == Material.TNT) {
            // If auto-igniting, set the planter of the primed TNT instead
            if (autoIgniteTNT) {
                event.setCancelled(true);
                event.getPlayer().getInventory().removeItem(new ItemStack(Material.TNT, 1));
                TNTPrimed tnt = b.getWorld().spawn(b.getRelative(BlockFace.UP).getLocation(), TNTPrimed.class);
                setPlanter(tnt, event.getPlayer());
                return;
            }
            setPlanter(b, event.getPlayer());
        }

        // Any other block we don't care about if we're not protecting
        if (!protect) {
            return;
        }

        // Otherwise, block was placed during a session.
        arena.addBlock(b);

        if (b.getType() == Material.WOODEN_DOOR || b.getType() == Material.IRON_DOOR_BLOCK) {
            // For doors, add the block just above (so we get both halves)
            arena.addBlock(b.getRelative(0, 1, 0));
        }
    }
View Full Code Here


    public void onBlockIgnite(BlockIgniteEvent event) {
        // If the arena isn't protected, care
        if (!protect) return;

        Block b = event.getBlock();
        if (!arena.getRegion().contains(b.getLocation()))
            return;

        switch (event.getCause()) {
            case FLINT_AND_STEEL:
                if (arena.inEditMode()) return;
                if (arena.isRunning()) {
                    if (b.getType() == Material.TNT) {
                        Player planter = getPlanter(b);
                        if (planter != null) {
                            b.setTypeId(0);
                            TNTPrimed tnt = b.getWorld().spawn(b.getLocation(), TNTPrimed.class);
                            setPlanter(tnt, planter);
                        }
                    } else {
                        arena.addBlock(event.getBlock().getRelative(BlockFace.UP));
                    }
View Full Code Here

            event.getBlockClicked().getRelative(event.getBlockFace()).setTypeId(0);
            event.setCancelled(true);
            return;
        }

        Block liquid = event.getBlockClicked().getRelative(event.getBlockFace());
        arena.addBlock(liquid);
    }
View Full Code Here

                if (!className.equalsIgnoreCase("random")) {
                    if (useClassChests) {
                        // Check for stored class chests first
                        ArenaClass ac = plugin.getArenaMaster().getClasses().get(className.toLowerCase());
                        Location loc = ac.getClassChest();
                        Block blockChest;
                        if (loc != null) {
                            blockChest = loc.getBlock();
                        } else {
                            // Otherwise, start the search
                            BlockFace backwards = ((org.bukkit.material.Sign) sign.getData()).getFacing().getOppositeFace();
                            Block blockSign   = sign.getBlock();
                            Block blockBelow  = blockSign.getRelative(BlockFace.DOWN);
                            Block blockBehind = blockBelow.getRelative(backwards);

                            // If the block below this sign is a class sign, swap the order
                            if (blockBelow.getType() == Material.WALL_SIGN || blockBelow.getType() == Material.SIGN_POST) {
                                String className = ChatColor.stripColor(((Sign) blockBelow.getState()).getLine(0)).toLowerCase();
                                if (arena.getClasses().containsKey(className)) {
View Full Code Here

            Messenger.tell(sender, "Class not found.");
            return true;
        }

        Player p = (Player) sender;
        Block b = p.getTargetBlock(null, 10);

        switch (b.getType()) {
            case CHEST:
            case LOCKED_CHEST:
            case ENDER_CHEST:
            case TRAPPED_CHEST:
                break;
            default:
                Messenger.tell(sender, "You must look at a chest.");
                return true;
        }

        setLocation(am.getPlugin().getConfig(), "classes." + ac.getConfigName() + ".classchest", b.getLocation());
        am.saveConfig();
        Messenger.tell(sender, "Class chest updated for class " + ac.getConfigName());
        am.loadClasses();
        return true;
    }
View Full Code Here

                arena.scheduleTask(new Runnable() {
                    @Override
                    public void run() {
                        if (!p.isOnline()) return;

                        Block b = loc.getBlock();
                        p.sendBlockChange(loc, b.getTypeId(), b.getData());
                    }
                }, 100);
            }
        }, 0);
    }
View Full Code Here

            @Override
            public void run() {
                // Grab all the blocks, and send block change events.
                final Map<Location,BlockState> blocks = new HashMap<Location,BlockState>();
                for (Location l : points) {
                    Block b = l.getBlock();
                    blocks.put(l, b.getState());
                    p.sendBlockChange(l, 35, (byte) 14);
                }
                arena.scheduleTask(new Runnable() {
                    public void run() {
                        // If the player isn't online, just forget it.
                        if (!p.isOnline()) {
                            return;
                        }

                        // Send block "restore" events.
                        for (Map.Entry<Location,BlockState> entry : blocks.entrySet()) {
                            Location l   = entry.getKey();
                            BlockState b = entry.getValue();
                            int id       = b.getTypeId();
                            byte data    = b.getRawData();

                            p.sendBlockChange(l, id, data);
                        }
                    }
                }, 100);
View Full Code Here

        state.getBlock().setTypeId(1);
    }

    public void repair()
    {
        Block b = getWorld().getBlockAt(x,y,z);
        if (b.getTypeId() == 0)
            b.setTypeId(1);
       
        super.repair();
    }
View Full Code Here

           
            long max = width*height*length;
            int amount = (int) Math.min(20, (max - total));
           
            for (int i = 0; i < amount; i++) {
                Block b = arena.getWorld().getBlockAt(x,y,z);
                blocks[x][y][z] = b.getTypeId();
                data[x][y][z]   = b.getData();

                x = (int) ((x+1) % width);
                y = (int) ((y+1) % height);
                z = (int) ((z+1) % length);
            }
View Full Code Here

           
            long max = width*height*length;
            int amount = (int) Math.min(20, (max - total));
           
            for (int i = 0; i < 20; i++) {
                Block b = arena.getWorld().getBlockAt(x,y,z);
                b.setTypeIdAndData(blocks[x][y][z], data[x][y][z], false);
            }
           
            total += amount;
           
            if (total == max) {
View Full Code Here

TOP

Related Classes of org.bukkit.block.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.