Program: 97777
Project: 97777
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(InteractionType action,ItemStack itemInHand,Location<World> clickedBlock,Direction clickedFace){
  String toolId=getToolId(itemInHand);
  SniperTool sniperTool=this.tools.get(toolId);
  Player player=getPlayer();
  if (sniperTool.hasToolAssigned(itemInHand.getItem())) {
    if (sniperTool.getCurrentBrush() == null) {
      player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
      return true;
    }
    if (!player.hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) {
      player.sendMessage(Text.of(TextColors.RED,"String_Node_Str" + sniperTool.getCurrentBrush().getPermissionNode() + "String_Node_Str"));
      return true;
    }
    SnipeData snipeData=sniperTool.getSnipeData();
    if (player.get(Keys.IS_SNEAKING).orElse(false)) {
      Location<World> targetBlock=null;
      SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand.getItem());
switch (action) {
case PRIMARY_MAINHAND:
case PRIMARY_OFFHAND:
        if (clickedBlock != null) {
          targetBlock=clickedBlock;
        }
 else {
          Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
          if (snipeData.isRanged()) {
            filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
          }
          BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
          BlockRay<World> ray=rayBuilder.build();
          while (ray.hasNext()) {
            targetBlock=ray.next().getLocation();
          }
        }
switch (snipeAction) {
case ARROW:
        snipeData.setVoxelId(targetBlock.getBlockType().getDefaultState());
      snipeData.getVoxelMessage().voxel();
    return true;
case GUNPOWDER:
  snipeData.setVoxelId(targetBlock.getBlock());
snipeData.getVoxelMessage().voxel();
return true;
default :
break;
}
break;
case SECONDARY_MAINHAND:
case SECONDARY_OFFHAND:
if (clickedBlock != null) {
targetBlock=clickedBlock;
}
 else {
Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
if (snipeData.isRanged()) {
filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
}
BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
BlockRay<World> ray=rayBuilder.build();
while (ray.hasNext()) {
targetBlock=ray.next().getLocation();
}
}
switch (snipeAction) {
case ARROW:
snipeData.setReplaceId(targetBlock.getBlockType().getDefaultState());
snipeData.getVoxelMessage().replace();
return true;
case GUNPOWDER:
snipeData.setReplaceId(targetBlock.getBlock());
snipeData.getVoxelMessage().replace();
return true;
default :
break;
}
break;
default :
return false;
}
}
 else {
Location<World> targetBlock=null;
Location<World> lastBlock=null;
SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand.getItem());
if (action == InteractionType.PRIMARY_MAINHAND || action == InteractionType.PRIMARY_OFFHAND) {
return false;
}
if (clickedBlock != null) {
targetBlock=clickedBlock;
lastBlock=clickedBlock.getRelative(clickedFace);
if (lastBlock == null) {
player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
return true;
}
}
 else {
Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
if (snipeData.isRanged()) {
filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
}
BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
BlockRay<World> ray=rayBuilder.build();
while (ray.hasNext()) {
lastBlock=targetBlock;
targetBlock=ray.next().getLocation();
}
if (targetBlock == null) {
player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
return false;
}
if (lastBlock == null) {
lastBlock=targetBlock;
}
}
sniperTool.getCurrentBrush().perform(snipeAction,snipeData,targetBlock,lastBlock);
SniperStats.increaseBrushUsage(sniperTool.getCurrentBrush().getName());
return true;
}
}
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(InteractionType action,ItemStack itemInHand,Location<World> clickedBlock,Direction clickedFace){
  String toolId=getToolId(itemInHand);
  SniperTool sniperTool=this.tools.get(toolId);
  Player player=getPlayer();
  if (sniperTool.hasToolAssigned(itemInHand.getItem())) {
    if (sniperTool.getCurrentBrush() == null) {
      player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
      return true;
    }
    if (!player.hasPermission(sniperTool.getCurrentBrush().getPermissionNode())) {
      player.sendMessage(Text.of(TextColors.RED,"String_Node_Str" + sniperTool.getCurrentBrush().getPermissionNode() + "String_Node_Str"));
      return true;
    }
    SnipeData snipeData=sniperTool.getSnipeData();
    if (player.get(Keys.IS_SNEAKING).orElse(false)) {
      Location<World> targetBlock=null;
      SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand.getItem());
switch (action) {
case PRIMARY_MAINHAND:
case PRIMARY_OFFHAND:
        if (clickedBlock != null) {
          targetBlock=clickedBlock;
        }
 else {
          Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
          if (snipeData.isRanged()) {
            filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
          }
          BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
          BlockRay<World> ray=rayBuilder.build();
          while (ray.hasNext()) {
            targetBlock=ray.next().getLocation();
          }
        }
switch (snipeAction) {
case ARROW:
        snipeData.setVoxelId(targetBlock.getBlockType().getDefaultState());
      snipeData.getVoxelMessage().voxel();
    return true;
case GUNPOWDER:
  snipeData.setVoxelId(targetBlock.getBlock());
snipeData.getVoxelMessage().voxel();
return true;
default :
break;
}
break;
case SECONDARY_MAINHAND:
case SECONDARY_OFFHAND:
if (clickedBlock != null) {
targetBlock=clickedBlock;
}
 else {
Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
if (snipeData.isRanged()) {
filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
}
BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
BlockRay<World> ray=rayBuilder.build();
while (ray.hasNext()) {
targetBlock=ray.next().getLocation();
}
}
switch (snipeAction) {
case ARROW:
snipeData.setReplaceId(targetBlock.getBlockType().getDefaultState());
snipeData.getVoxelMessage().replace();
return true;
case GUNPOWDER:
snipeData.setReplaceId(targetBlock.getBlock());
snipeData.getVoxelMessage().replace();
return true;
default :
break;
}
break;
default :
return false;
}
}
 else {
Location<World> targetBlock=null;
Location<World> lastBlock=null;
SnipeAction snipeAction=sniperTool.getActionAssigned(itemInHand.getItem());
if (action == InteractionType.PRIMARY_MAINHAND || action == InteractionType.PRIMARY_OFFHAND) {
return false;
}
if (clickedBlock != null) {
targetBlock=clickedBlock;
lastBlock=clickedBlock.getRelative(clickedFace);
if (lastBlock == null) {
player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
return true;
}
}
 else {
Predicate<BlockRayHit<World>> filter=BlockRay.continueAfterFilter(BlockRay.onlyAirFilter(),1);
if (snipeData.isRanged()) {
filter=filter.and(BlockRay.maxDistanceFilter(player.getLocation().getPosition().add(0,1.72,0),snipeData.getRange()));
}
BlockRayBuilder<World> rayBuilder=BlockRay.from(player).filter(filter);
BlockRay<World> ray=rayBuilder.build();
while (ray.hasNext()) {
lastBlock=targetBlock;
targetBlock=ray.next().getLocation();
}
if (targetBlock == null) {
player.sendMessage(Text.of(TextColors.RED,"String_Node_Str"));
return false;
}
if (lastBlock == null) {
lastBlock=targetBlock;
}
}
try {
sniperTool.getCurrentBrush().perform(snipeAction,snipeData,targetBlock,lastBlock);
}
 catch (Exception e) {
player.sendMessage(Text.of(TextColors.DARK_RED,"String_Node_Str"));
VoxelSniper.getLogger().error("String_Node_Str" + sniperTool.getCurrentBrush().getName());
e.printStackTrace();
}
SniperStats.increaseBrushUsage(sniperTool.getCurrentBrush().getName());
return true;
}
}
return false;
}