@Override public void onBlockRedstoneChange(BlockRedstoneEvent event) { final Block block = event.getBlock(); // Check if the block is of the target powered type if (!BlockUtil.isChest(block) && !BlockUtil.isSign(block)) return; System.out.println("(PowerToggle) Found powered sign or chest."); // Check if location is of interesting type if (!powerManager.isLocationInteresting(block.getLocation())) return; // Check if location is of a known nondormant field (should be!) final long iD = powerManager.getLinkedId(block); if (!fieldManager.isKnownNonDormant(iD)) { ExpensiveStones.infoLog("POWERSYNC ERROR! assigned field blocks don't match powerSet!"); return; } // __Process Event! final ExpensiveField field = fieldManager.getExpensiveField(iD); if (powerManager.isBlockPowered(block)) { if (field.isDisabled()) { fieldManager.enableField(field); field.setSignToPowered(); } } else { if (field.isActive()) fieldManager.disableField(field); } }
@Override public void onSignChange(SignChangeEvent event) { if (event.isCancelled()) return; if (!event.getLine(0).equalsIgnoreCase("[ExpStone]")) return; // Get basics final Block block = event.getBlock(); final Player player = event.getPlayer(); // Get a certein block. final Block fieldBlock = BlockUtil.getFieldStone(block, true); // Chech if any surrounding blocks is a known fieldblock. if (fieldBlock == null) { player.sendMessage(ChatColor.YELLOW + "ExpensiveStones: No Expensive StoneType Found."); return; } // _____________________Test Adming_____________________________ if (event.getLine(2).equalsIgnoreCase("admin")) { // Check rights if (!player.hasPermission(ESPermissionManager.PERM_ADMIN)) { player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: You don't have the permissions to make an adminField."); } else { fieldManager.setAdminField(fieldManager.getExpensiveField(block)); player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: Admin-Field created, field is now handled by PreciousStones."); player.sendMessage(ChatColor.YELLOW + "You can now destroy this sign."); } return; } // _____________________Normal Player___________________________ final Block chestBlock = BlockUtil.getChest(block); // Chech chest if (chestBlock == null) { player.sendMessage(ChatColor.YELLOW + "ExpensiveStones: No chest found for register"); return; } final ExpensiveField expField = new ExpensiveField(block, chestBlock, stones.getForceFieldManager().getField(fieldBlock)); fieldManager.disableField(expField); event.setLine(1, expField.getField().getOwner()); event.setLine(2, expField.getSettings().getMaterial().toString()); event.setLine(3, "<DISABLED>"); player.sendMessage( ChatColor.YELLOW + "ExpensiveStones: Field Registered, click to enable field"); }
@Override public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled()) return; final Block block = event.getBlock(); if (!stones.getSettingsManager().isFieldType(event.getBlock()) && !BlockUtil.isSign(block)) return; // SignCheck if (BlockUtil.isSign(block)) { final Player player = event.getPlayer(); final Block fieldBlock = BlockUtil.getFieldStone(block, false); // Check if fieldBlock has a known field if (fieldBlock == null) { return; } // Get ExpensiveField and dormant it. final ExpensiveField field = fieldManager.getExpensiveField(fieldBlock); fieldManager.setDormantField(field); player.sendMessage(ChatColor.YELLOW + "ExpensiveStones: Field is succesfully dormanted."); return; } // Check if block is known to ExpensiveField if (fieldManager.isKnown(block)) { final ExpensiveField field = fieldManager.getExpensiveField(block); field.setFieldON(); if (!fieldManager.isInDormant(field.getField().getLocation())) field.setError(); fieldManager.removeField(field); event .getPlayer() .sendMessage(ChatColor.YELLOW + "ExpensiveStones: Field is ready to be deleted."); } }