Program: 97815
Project: 97815
Buggy source:
/** 
 * Sniper execution call.
 * @param action       Action player performed
 * @param itemInHand   Item in hand of player
 * @param clickedBlock Block that the player targeted/interacted with
 * @param clickedFace  Face of that targeted Block
 * @return true if command visibly processed, false otherwise.
 */
public boolean snipe(Action action,Material itemInHand,Block clickedBlock,BlockFace clickedFace){
  String toolId=getToolId(itemInHand);
  SniperTool sniperTool=tools.get(toolId);
  if (sniperTool.getCurrentBrush() == null) {
    player.sendMessage("String_Node_Str");
    return true;
  }
  if (!player.hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) {
    player.sendMessage("String_Node_Str" + sniperTool.getCurrentBrush().getPermissionNode() + "String_Node_Str");
    return true;
  }
  if (sniperTool.hasToolAssigned(itemInHand)) {
    SnipeData snipeData=sniperTool.getSnipeData();
    if (player.isSneaking()) {
      Block targetBlock;
      SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand);
switch (action) {
case LEFT_CLICK_BLOCK:
case LEFT_CLICK_AIR:
        if (clickedBlock != null) {
          targetBlock=clickedBlock;
        }
 else {
          RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
          targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
        }
switch (snipeAction) {
case ARROW:
        if (targetBlock != null) {
          int originalVoxel=snipeData.getVoxelId();
          snipeData.setVoxelId(targetBlock.getTypeId());
          SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(originalVoxel,snipeData.getData()),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
          Bukkit.getPluginManager().callEvent(event);
          snipeData.getVoxelMessage().voxel();
          return true;
        }
 else {
          int originalVoxel=snipeData.getVoxelId();
          snipeData.setVoxelId(0);
          SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(originalVoxel,snipeData.getData()),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
          Bukkit.getPluginManager().callEvent(event);
          snipeData.getVoxelMessage().voxel();
          return true;
        }
case GUNPOWDER:
      if (targetBlock != null) {
        byte originalData=snipeData.getData();
        snipeData.setData(targetBlock.getData());
        SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getVoxelId(),originalData),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
        Bukkit.getPluginManager().callEvent(event);
        snipeData.getVoxelMessage().data();
        return true;
      }
 else {
        byte originalData=snipeData.getData();
        snipeData.setData((byte)0);
        SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getVoxelId(),originalData),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
        Bukkit.getPluginManager().callEvent(event);
        snipeData.getVoxelMessage().data();
        return true;
      }
default :
    break;
}
break;
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
if (clickedBlock != null) {
targetBlock=clickedBlock;
}
 else {
RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
}
switch (snipeAction) {
case ARROW:
if (targetBlock != null) {
int originalId=snipeData.getReplaceId();
snipeData.setReplaceId(targetBlock.getTypeId());
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(originalId,snipeData.getReplaceData()),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replace();
return true;
}
 else {
int originalId=snipeData.getReplaceId();
snipeData.setReplaceId(0);
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(originalId,snipeData.getReplaceData()),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replace();
return true;
}
case GUNPOWDER:
if (targetBlock != null) {
byte originalData=snipeData.getReplaceData();
snipeData.setReplaceData(targetBlock.getData());
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getReplaceId(),originalData),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replaceData();
return true;
}
 else {
byte originalData=snipeData.getReplaceData();
snipeData.setReplaceData((byte)0);
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getReplaceId(),originalData),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replaceData();
return true;
}
default :
break;
}
break;
default :
return false;
}
}
 else {
Block targetBlock;
Block lastBlock;
SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand);
switch (action) {
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
break;
default :
return false;
}
if (clickedBlock != null) {
targetBlock=clickedBlock;
lastBlock=clickedBlock.getRelative(clickedFace);
if (lastBlock == null) {
player.sendMessage(ChatColor.RED + "String_Node_Str");
return true;
}
}
 else {
RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
lastBlock=rangeBlockHelper.getLastBlock();
if (targetBlock == null || lastBlock == null) {
player.sendMessage(ChatColor.RED + "String_Node_Str");
return true;
}
}
if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
PerformBrush performerBrush=(PerformBrush)sniperTool.getCurrentBrush();
performerBrush.initP(snipeData);
}
boolean result=sniperTool.getCurrentBrush().perform(snipeAction,snipeData,targetBlock,lastBlock);
if (result) {
MetricsManager.increaseBrushUsage(sniperTool.getCurrentBrush().getName());
}
return result;
}
}
return false;
}

Fixed version (ground truth):
/** 
 * Sniper execution call.
 * @param action       Action player performed
 * @param itemInHand   Item in hand of player
 * @param clickedBlock Block that the player targeted/interacted with
 * @param clickedFace  Face of that targeted Block
 * @return true if command visibly processed, false otherwise.
 */
public boolean snipe(Action action,Material itemInHand,Block clickedBlock,BlockFace clickedFace){
  String toolId=getToolId(itemInHand);
  SniperTool sniperTool=tools.get(toolId);
switch (action) {
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
    break;
default :
  return false;
}
if (sniperTool.hasToolAssigned(itemInHand)) {
if (sniperTool.getCurrentBrush() == null) {
  player.sendMessage("String_Node_Str");
  return true;
}
if (!player.hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) {
  player.sendMessage("String_Node_Str" + sniperTool.getCurrentBrush().getPermissionNode() + "String_Node_Str");
  return true;
}
SnipeData snipeData=sniperTool.getSnipeData();
if (player.isSneaking()) {
  Block targetBlock;
  SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand);
switch (action) {
case LEFT_CLICK_BLOCK:
case LEFT_CLICK_AIR:
    if (clickedBlock != null) {
      targetBlock=clickedBlock;
    }
 else {
      RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
      targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
    }
switch (snipeAction) {
case ARROW:
    if (targetBlock != null) {
      int originalVoxel=snipeData.getVoxelId();
      snipeData.setVoxelId(targetBlock.getTypeId());
      SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(originalVoxel,snipeData.getData()),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
      Bukkit.getPluginManager().callEvent(event);
      snipeData.getVoxelMessage().voxel();
      return true;
    }
 else {
      int originalVoxel=snipeData.getVoxelId();
      snipeData.setVoxelId(0);
      SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(originalVoxel,snipeData.getData()),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
      Bukkit.getPluginManager().callEvent(event);
      snipeData.getVoxelMessage().voxel();
      return true;
    }
case GUNPOWDER:
  if (targetBlock != null) {
    byte originalData=snipeData.getData();
    snipeData.setData(targetBlock.getData());
    SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getVoxelId(),originalData),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
    Bukkit.getPluginManager().callEvent(event);
    snipeData.getVoxelMessage().data();
    return true;
  }
 else {
    byte originalData=snipeData.getData();
    snipeData.setData((byte)0);
    SniperMaterialChangedEvent event=new SniperMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getVoxelId(),originalData),new MaterialData(snipeData.getVoxelId(),snipeData.getData()));
    Bukkit.getPluginManager().callEvent(event);
    snipeData.getVoxelMessage().data();
    return true;
  }
default :
break;
}
break;
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
if (clickedBlock != null) {
targetBlock=clickedBlock;
}
 else {
RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
}
switch (snipeAction) {
case ARROW:
if (targetBlock != null) {
int originalId=snipeData.getReplaceId();
snipeData.setReplaceId(targetBlock.getTypeId());
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(originalId,snipeData.getReplaceData()),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replace();
return true;
}
 else {
int originalId=snipeData.getReplaceId();
snipeData.setReplaceId(0);
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(originalId,snipeData.getReplaceData()),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replace();
return true;
}
case GUNPOWDER:
if (targetBlock != null) {
byte originalData=snipeData.getReplaceData();
snipeData.setReplaceData(targetBlock.getData());
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getReplaceId(),originalData),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replaceData();
return true;
}
 else {
byte originalData=snipeData.getReplaceData();
snipeData.setReplaceData((byte)0);
SniperReplaceMaterialChangedEvent event=new SniperReplaceMaterialChangedEvent(this,toolId,new MaterialData(snipeData.getReplaceId(),originalData),new MaterialData(snipeData.getReplaceId(),snipeData.getReplaceData()));
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().replaceData();
return true;
}
default :
break;
}
break;
default :
return false;
}
}
 else {
Block targetBlock;
Block lastBlock;
SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand);
switch (action) {
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
break;
default :
return false;
}
if (clickedBlock != null) {
targetBlock=clickedBlock;
lastBlock=clickedBlock.getRelative(clickedFace);
if (lastBlock == null) {
player.sendMessage(ChatColor.RED + "String_Node_Str");
return true;
}
}
 else {
RangeBlockHelper rangeBlockHelper=snipeData.isRanged() ? new RangeBlockHelper(player,player.getWorld(),snipeData.getRange()) : new RangeBlockHelper(player,player.getWorld());
targetBlock=snipeData.isRanged() ? rangeBlockHelper.getRangeBlock() : rangeBlockHelper.getTargetBlock();
lastBlock=rangeBlockHelper.getLastBlock();
if (targetBlock == null || lastBlock == null) {
player.sendMessage(ChatColor.RED + "String_Node_Str");
return true;
}
}
if (sniperTool.getCurrentBrush() instanceof PerformBrush) {
PerformBrush performerBrush=(PerformBrush)sniperTool.getCurrentBrush();
performerBrush.initP(snipeData);
}
boolean result=sniperTool.getCurrentBrush().perform(snipeAction,snipeData,targetBlock,lastBlock);
if (result) {
MetricsManager.increaseBrushUsage(sniperTool.getCurrentBrush().getName());
}
return result;
}
}
return false;
}