public void load(DataInputStream in, String name, World w) { this.name = name; try { world = w; try { double x1 = in.readDouble(); double y1 = in.readDouble(); double z1 = in.readDouble(); catArena.setLocB(world, x1, y1, z1); double x2 = in.readDouble(); double y2 = in.readDouble(); double z2 = in.readDouble(); catArena.setLocG(world, x2, y2, z2); while (true) { int d = in.readInt(); if (d == Material.CHEST.getId()) { blocks.add(new BlocksChest(in, world)); } else if (d == Material.SIGN.getId() || d == Material.SIGN_POST.getId()) { blocks.add(new BlocksSign(in, world)); } else { blocks.add(new Blocks(in, world)); } } } catch (EOFException d) { } } catch (Exception e) { e.printStackTrace(); } }
@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; } } }