/** * Button lever hit. * * @param p the p * @param clicked the clicked * @param direction the direction * @return true, if successful */ private boolean ButtonLeverHit(Player p, Block clicked, BlockFace direction) { Stargate s = StargateManager.getGateFromBlock(clicked); if (s != null) { if (WXPermissions.checkWXPermissions(p, s, PermissionType.USE)) { if (WorldUtils.isSameBlock(s.ActivationBlock, clicked)) { return this.HandleGateActivationSwitch(s, p); } else if (WorldUtils.isSameBlock(s.IrisActivationBlock, clicked)) { this.HandleIrisActivationSwitch(s, p); if ((s.Active) && (!s.IrisActive)) { s.FillGateInterior(ConfigManager.getPortalMaterial()); } return true; } } else { p.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO)); } return false; } else { if (direction == null) { switch (clicked.getData()) { case 1: direction = BlockFace.SOUTH; break; case 2: direction = BlockFace.NORTH; break; case 3: direction = BlockFace.WEST; break; case 4: direction = BlockFace.EAST; break; } if (direction == null) { return true; } } // Check to see if player has already run the "build" command. StargateShape shape = StargateManager.GetPlayerBuilderShape(p); Stargate new_gate = null; if (shape != null) { new_gate = StargateHelper.checkStargate(clicked, direction, shape); } else { new_gate = StargateHelper.checkStargate(clicked, direction); } if (new_gate != null) { if (WXPermissions.checkWXPermissions(p, new_gate, PermissionType.BUILD)) { if (new_gate.IsSignPowered) { p.sendMessage(ConfigManager.normalheader + "Stargate Design Valid with Sign Nav."); if (new_gate.Name.equals("")) { p.sendMessage(ConfigManager.output_strings.get(StringTypes.CONSTRUCT_NAME_INVALID)); } else { boolean success = StargateManager.CompleteStargate(p, new_gate); if (success) { p.sendMessage(ConfigManager.output_strings.get(StringTypes.CONSTRUCT_SUCCESS)); new_gate.TeleportSign.setLine(0, "-" + new_gate.Name + "-"); new_gate.TeleportSign.setData(new_gate.TeleportSign.getData()); new_gate.TeleportSign.update(); } else { p.sendMessage("Stargate constrution failed!?"); return false; } } } else { // Print to player that it was successful! p.sendMessage( ConfigManager.normalheader + "Valid Stargate Design! \u00A73:: \u00A7B<required> \u00A76[optional]"); p.sendMessage( ConfigManager.normalheader + "Type \'\u00A7F/wxcomplete \u00A7B<name> \u00A76[idc=IDC] [net=NET]\u00A77\' to complete."); // Add gate to unnamed gates. StargateManager.AddIncompleteStargate(p, new_gate); } return true; } else { if (new_gate.IsSignPowered) { new_gate.Network.gate_list.remove(new_gate); new_gate.TeleportSign.setLine(0, new_gate.Name); if (new_gate.Network != null) { new_gate.TeleportSign.setLine(1, new_gate.Network.netName); } new_gate.TeleportSign.setData(new_gate.TeleportSign.getData()); new_gate.TeleportSign.update(); } StargateManager.RemoveIncompleteStargate(p); p.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO)); return false; } } else { WormholeXTreme.thisPlugin.prettyLog( Level.FINEST, false, p.getName() + " has pressed a button or lever but did not find any properly created gates."); return true; } } }