Search in sources :

Example 21 with WallSign

use of org.bukkit.block.data.type.WallSign in project XPKeeper by eccentricdevotion.

the class XPKArrgghh method onEntityExplode.

@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
    if (event.isCancelled()) {
        return;
    }
    String firstline = plugin.getConfig().getString("firstline");
    List<Block> blockList = new ArrayList<>(event.blockList());
    blockList.forEach((block) -> {
        if (Tag.SIGNS.isTagged(block.getType())) {
            Sign sign = (Sign) block.getState();
            String line0 = ChatColor.stripColor(sign.getLine(0));
            if (line0.equalsIgnoreCase("[" + firstline + "]")) {
                event.blockList().remove(block);
                if (Tag.STANDING_SIGNS.isTagged(block.getType())) {
                    Block blockdown = block.getRelative(BlockFace.DOWN, 1);
                    event.blockList().remove(blockdown);
                }
                if (Tag.WALL_SIGNS.isTagged(block.getType())) {
                    WallSign data = (WallSign) block.getBlockData();
                    Block blockbehind = block.getRelative(data.getFacing().getOppositeFace(), 1);
                    event.blockList().remove(blockbehind);
                }
            }
        }
    });
}
Also used : WallSign(org.bukkit.block.data.type.WallSign) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) Sign(org.bukkit.block.Sign) WallSign(org.bukkit.block.data.type.WallSign) EventHandler(org.bukkit.event.EventHandler)

Example 22 with WallSign

use of org.bukkit.block.data.type.WallSign in project XPKeeper by eccentricdevotion.

the class XPKBreak method onPlayerBreakSign.

@EventHandler
public void onPlayerBreakSign(BlockBreakEvent event) {
    Player player = event.getPlayer();
    Block block = event.getBlock();
    Material blockType = block.getType();
    if (Tag.SIGNS.isTagged(blockType)) {
        if (plugin.getConfig().getBoolean("allow_raids")) {
            raidSign(block, event, player);
        } else {
            // check the text on the sign
            xpkSign(block, event, player, "messages.use_command");
        }
    } else {
        // check if breaking block underneath or behind sign
        for (BlockFace bf : faces) {
            Block faceBlock = block.getRelative(bf);
            Material faceBlockType = faceBlock.getType();
            if (Tag.WALL_SIGNS.isTagged(faceBlockType)) {
                BlockFace attachedFace = ((WallSign) faceBlock.getState().getBlockData()).getFacing();
                if (bf.equals(attachedFace)) {
                    xpkSign(faceBlock, event, player, "messages.no_grief");
                }
            }
            if (bf.equals(BlockFace.UP) && Tag.STANDING_SIGNS.isTagged(faceBlockType)) {
                xpkSign(faceBlock, event, player, "messages.no_grief");
            }
        }
    }
}
Also used : WallSign(org.bukkit.block.data.type.WallSign) Player(org.bukkit.entity.Player) BlockFace(org.bukkit.block.BlockFace) Block(org.bukkit.block.Block) Material(org.bukkit.Material) EventHandler(org.bukkit.event.EventHandler)

Aggregations

WallSign (org.bukkit.block.data.type.WallSign)22 Block (org.bukkit.block.Block)11 EventHandler (org.bukkit.event.EventHandler)11 BlockData (org.bukkit.block.data.BlockData)10 Player (org.bukkit.entity.Player)9 Sign (org.bukkit.block.Sign)7 BlockState (org.bukkit.block.BlockState)6 Sign (org.bukkit.block.data.type.Sign)5 Location (org.bukkit.Location)4 BlockFace (org.bukkit.block.BlockFace)3 ArrayList (java.util.ArrayList)2 Craft (net.countercraft.movecraft.craft.Craft)2 Material (org.bukkit.Material)2 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)1 Structure (eelfloat.replcraft.Structure)1 InvalidStructure (eelfloat.replcraft.exceptions.InvalidStructure)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Knocker (me.gameisntover.kbffa.api.Knocker)1 DataBlock (me.gameisntover.kbffa.arena.regions.DataBlock)1