private static void initTransparentBlocks() { transparentBlocks.add(((Integer) Material.AIR.getId()).byteValue()); transparentBlocks.add(((Integer) Material.BREWING_STAND.getId()).byteValue()); transparentBlocks.add(((Integer) Material.BROWN_MUSHROOM.getId()).byteValue()); transparentBlocks.add(((Integer) Material.CAKE.getId()).byteValue()); transparentBlocks.add(((Integer) Material.CROPS.getId()).byteValue()); transparentBlocks.add(((Integer) Material.DETECTOR_RAIL.getId()).byteValue()); transparentBlocks.add(((Integer) Material.DIODE_BLOCK_ON.getId()).byteValue()); transparentBlocks.add(((Integer) Material.DIODE_BLOCK_OFF.getId()).byteValue()); transparentBlocks.add(((Integer) Material.LADDER.getId()).byteValue()); transparentBlocks.add(((Integer) Material.LAVA.getId()).byteValue()); transparentBlocks.add(((Integer) Material.LEVER.getId()).byteValue()); transparentBlocks.add(((Integer) Material.LONG_GRASS.getId()).byteValue()); transparentBlocks.add(((Integer) Material.MELON_STEM.getId()).byteValue()); transparentBlocks.add(((Integer) Material.NETHER_STALK.getId()).byteValue()); transparentBlocks.add(((Integer) Material.PAINTING.getId()).byteValue()); transparentBlocks.add(((Integer) Material.PORTAL.getId()).byteValue()); transparentBlocks.add(((Integer) Material.POWERED_RAIL.getId()).byteValue()); transparentBlocks.add(((Integer) Material.PUMPKIN_STEM.getId()).byteValue()); transparentBlocks.add(((Integer) Material.RAILS.getId()).byteValue()); transparentBlocks.add(((Integer) Material.RED_MUSHROOM.getId()).byteValue()); transparentBlocks.add(((Integer) Material.RED_ROSE.getId()).byteValue()); transparentBlocks.add(((Integer) Material.REDSTONE_TORCH_ON.getId()).byteValue()); transparentBlocks.add(((Integer) Material.REDSTONE_TORCH_OFF.getId()).byteValue()); transparentBlocks.add(((Integer) Material.REDSTONE_WIRE.getId()).byteValue()); transparentBlocks.add(((Integer) Material.SAPLING.getId()).byteValue()); transparentBlocks.add(((Integer) Material.SIGN_POST.getId()).byteValue()); transparentBlocks.add(((Integer) Material.SNOW.getId()).byteValue()); transparentBlocks.add(((Integer) Material.TORCH.getId()).byteValue()); transparentBlocks.add(((Integer) Material.VINE.getId()).byteValue()); transparentBlocks.add(((Integer) Material.WALL_SIGN.getId()).byteValue()); transparentBlocks.add(((Integer) Material.WATER.getId()).byteValue()); transparentBlocks.add(((Integer) Material.YELLOW_FLOWER.getId()).byteValue()); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { if (event.isCancelled()) return; // List<Block> blockList = event.blockList(); int x; // , count = event.blockList().size(); Block block; // Check the block list for any protected blocks, and cancel the event if any are found. for (x = 0; x < event.blockList().size(); ++x) { if (Lockette.explosionProtectionAll) { block = event.blockList().get(x); if (Lockette.isProtected(block)) { // event.setCancelled(true); // return; event.blockList().remove(x); --x; // --count; continue; } if ((block.getTypeId() == Material.CHEST.getId()) || (block.getTypeId() == Material.DISPENSER.getId()) || (block.getTypeId() == Material.FURNACE.getId()) || (block.getTypeId() == Material.BURNING_FURNACE.getId()) || (block.getTypeId() == Material.BREWING_STAND.getId())) { // event.setCancelled(true); // return; event.blockList().remove(x); --x; // --count; continue; } } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteract(PlayerInteractEvent event) { if (!event.hasBlock()) return; Action action = event.getAction(); Player player = event.getPlayer(); Block block = event.getClickedBlock(); int type = block.getTypeId(); BlockFace face = event.getBlockFace(); if (action == Action.RIGHT_CLICK_BLOCK) { if (Lockette.protectTrapDoors) if (type == Material.TRAP_DOOR.getId()) { if (interactDoor(block, player)) return; event.setUseInteractedBlock(Result.DENY); event.setUseItemInHand(Result.DENY); return; } if (Lockette.protectDoors) if ((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId()) || (type == materialFenceGate)) { if (interactDoor(block, player)) return; event.setUseInteractedBlock(Result.DENY); event.setUseItemInHand(Result.DENY); return; } if (type == Material.WALL_SIGN.getId()) { interactSign(block, player); return; } if (type == Material.CHEST.getId()) { // Try at making a 1.7->1.8 chest fixer. Lockette.rotateChestOrientation(block, face); } if ((type == Material.CHEST.getId()) || (type == Material.DISPENSER.getId()) || (type == Material.FURNACE.getId()) || (type == Material.BURNING_FURNACE.getId()) || (type == Material.BREWING_STAND.getId()) || Lockette.isInList(type, Lockette.customBlockList)) { // Trying something out.... if (Lockette.directPlacement) if (event.hasItem()) if ((face != BlockFace.UP) && (face != BlockFace.DOWN)) { ItemStack item = event.getItem(); if (item.getTypeId() == Material.SIGN.getId()) { Block checkBlock = block.getRelative(face); type = checkBlock.getTypeId(); if (type == Material.AIR.getId()) { boolean place = false; if (Lockette.isProtected(block)) { // Add a users sign only if owner. if (Lockette.isOwner(block, player.getName())) place = true; } else place = true; // if(Lockette.altPrivate == null){}//if(Lockette.altMoreUsers == null){} if (place) { // player.sendMessage(ChatColor.RED + "Lockette: Using a sign on a container"); event.setUseItemInHand(Result.ALLOW); // ? seems to work in 568 event.setUseInteractedBlock(Result.DENY); return; } } } } if (interactContainer(block, player)) return; event.setUseInteractedBlock(Result.DENY); event.setUseItemInHand(Result.DENY); return; } if (type == Material.DIRT.getId()) if (event.hasItem()) { ItemStack item = event.getItem(); type = item.getTypeId(); if ((type == Material.DIAMOND_HOE.getId()) || (type == Material.GOLD_HOE.getId()) || (type == Material.IRON_HOE.getId()) || (type == Material.STONE_HOE.getId()) || (type == Material.WOOD_HOE.getId())) { Block checkBlock = block.getRelative(BlockFace.UP); type = checkBlock.getTypeId(); if ((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId()) || (type == materialFenceGate)) { event.setUseInteractedBlock(Result.DENY); return; } } } } else if (action == Action.LEFT_CLICK_BLOCK) { if (Lockette.protectTrapDoors) if (type == Material.TRAP_DOOR.getId()) { if (interactDoor(block, player)) return; event.setUseInteractedBlock(Result.DENY); event.setUseItemInHand(Result.DENY); return; } if (Lockette.protectDoors) if ((type == Material.WOODEN_DOOR.getId()) || (type == Material.IRON_DOOR_BLOCK.getId()) || (type == materialFenceGate)) { if (interactDoor(block, player)) return; event.setUseInteractedBlock(Result.DENY); event.setUseItemInHand(Result.DENY); return; } } }