/** * @param playr * @param action * @param itemInHand * @param clickedBlock * @param clickedFace * @return boolean Success. */ public final boolean snipe( final Player playr, final Action action, final Material itemInHand, final Block clickedBlock, final BlockFace clickedFace) { boolean _success = false; try { this.player = playr; if (this.brushTools.containsKey(this.player.getItemInHand().getType())) { final BrushTool _bt = this.brushTools.get(this.player.getItemInHand().getType()); _success = _bt.snipe(playr, action, itemInHand, clickedBlock, clickedFace); } else { if (this.player.isSneaking()) { _success = this.sneak.perform(action, this.data, itemInHand, clickedBlock, clickedFace); return _success; } _success = this.current.perform(action, this.data, itemInHand, clickedBlock, clickedFace); } } catch (final Exception _e) { this.player.sendMessage(ChatColor.RED + "An Exception has occured! (Sniping error)"); this.player.sendMessage(ChatColor.RED + "" + _e.toString()); final StackTraceElement[] _ste = _e.getStackTrace(); for (final StackTraceElement _se : _ste) { this.player.sendMessage( ChatColor.DARK_GRAY + _se.getClassName() + ChatColor.DARK_GREEN + " : " + ChatColor.DARK_GRAY + _se.getLineNumber()); } VoxelSniper.LOG.warning( "[VoxelSniper] Exception while sniping: (" + this.player.getName() + " " + this.current.getName() + ")"); VoxelSniper.LOG.log(Level.SEVERE, null, _e); return false; } return _success; }
/** * @param args * @return boolean */ public final boolean setBrush(final String[] args) { try { if (args == null || args.length == 0) { this.player.sendMessage(ChatColor.RED + "Invalid input!"); return false; } if (this.myBrushes.containsKey(args[0])) { if (this.brushTools.containsKey(this.player.getItemInHand().getType())) { final BrushTool _bt = this.brushTools.get(this.player.getItemInHand().getType()); _bt.setBrush(SniperBrushes.getBrushInstance(args[0])); } else { this.brushPresetsParamsS.put("twoBack@", this.brushPresetsParamsS.get("previous@")); this.fillPrevious(); this.twoBack = this.previous; this.previous = this.current; this.current = this.myBrushes.get(args[0]); } } else if (this.brushAlt.containsKey(args[0])) { if (this.brushTools.containsKey(this.player.getItemInHand().getType())) { final BrushTool _bt = this.brushTools.get(this.player.getItemInHand().getType()); _bt.setBrush(SniperBrushes.getBrushInstance(args[0])); } else { this.brushPresetsParamsS.put("twoBack@", this.brushPresetsParamsS.get("previous@")); this.fillPrevious(); this.twoBack = this.previous; this.previous = this.current; this.current = this.myBrushes.get(this.brushAlt.get(args[0])); } } else { this.player.sendMessage(ChatColor.LIGHT_PURPLE + "No such brush."); return false; } final String[] _argsParsed = this.parseParams(args); if (_argsParsed.length > 1) { try { if (this.brushTools.containsKey(this.player.getItemInHand().getType())) { final BrushTool _bt = this.brushTools.get(this.player.getItemInHand().getType()); _bt.parse(_argsParsed); } else { if (this.current instanceof Performer) { ((Performer) this.current).parse(_argsParsed, this.data); } else { this.current.parameters(_argsParsed, this.data); } } return true; } catch (final Exception _e) { this.player.sendMessage(ChatColor.RED + "Invalid parameters! (Parameter error)"); this.player.sendMessage(ChatColor.DARK_PURPLE + "" + this.fromArgs(_argsParsed)); this.player.sendMessage(ChatColor.RED + "Is not a valid statement"); this.player.sendMessage(ChatColor.DARK_BLUE + "" + _e.getMessage()); VoxelSniper.LOG.warning( "[VoxelSniper] Exception while receiving parameters: \n(" + this.player.getName() + " " + this.current.getName() + ") par[ " + this.fromArgs(_argsParsed) + "]"); VoxelSniper.LOG.log(Level.SEVERE, null, _e); return false; } } this.info(); return true; } catch (final ArrayIndexOutOfBoundsException _e) { this.player.sendMessage(ChatColor.RED + "Invalid input!"); _e.printStackTrace(); return false; } }