示例#1
0
  public final void reset() {
    if (this instanceof LiteSniper) {
      this.myBrushes = LiteSniperBrushes.getSniperBrushes();
    } else {
      this.myBrushes = SniperBrushes.getSniperBrushes();
    }

    if (this.brushTools.containsKey(this.player.getItemInHand().getType())) {
      final BrushTool _bt = this.brushTools.get(this.player.getItemInHand().getType());
      _bt.setBrush(new SnipeBrush());

      _bt.data.setVoxelId(0);
      _bt.data.setReplaceId(0);
      _bt.data.setData((byte) 0);
      _bt.data.setBrushSize(3);
      _bt.data.setVoxelHeight(1);
      _bt.data.setcCen(0);
      _bt.data.setReplaceData((byte) 0);
    } else {
      this.current = new SnipeBrush();

      this.fillPrevious();
      this.data.setVoxelId(0);
      this.data.setReplaceId(0);
      this.data.setData((byte) 0);
      this.data.setBrushSize(3);
      this.data.setVoxelHeight(1);
      this.data.setcCen(0);
      this.data.setReplaceData((byte) 0);
      this.range = 1;
      this.distRestrict = false;
    }
    this.fillCurrent();
  }
示例#2
0
  /** Default constructor. */
  public Sniper() {
    this.myBrushes = SniperBrushes.getSniperBrushes();
    this.brushAlt = SniperBrushes.getBrushAlternates();

    this.voxelMessage = new Message(this.data);
    this.data.setVoxelMessage(this.voxelMessage);

    final int[] _currentP = new int[Sniper.SAVE_ARRAY_SIZE];
    _currentP[Sniper.SAVE_ARRAY_VOXEL_ID] = 0;
    _currentP[Sniper.SAVE_ARRAY_REPLACE_VOXEL_ID] = 0;
    _currentP[Sniper.SAVE_ARRAY_DATA_VALUE] = 0;
    _currentP[Sniper.SAVE_ARRAY_BRUSH_SIZE] = 3;
    _currentP[Sniper.SAVE_ARRAY_VOXEL_HEIGHT] = 1;
    _currentP[Sniper.SAVE_ARRAY_CENTROID] = 0;
    this.brushPresetsParamsS.put("current@", _currentP);
    this.brushPresetsParamsS.put("previous@", _currentP);
    this.brushPresetsParamsS.put("twoBack@", _currentP);
    this.brushPresetsS.put("current@", this.myBrushes.get("s"));
    this.brushPresetsS.put("previous@", this.myBrushes.get("s"));
    this.brushPresetsS.put("twoBack@", this.myBrushes.get("s"));
  }
示例#3
0
  /**
   * @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;
    }
  }