Program: 10419
Project: 10419
Buggy source:
/** 
 * Replaces FLAG TAGs. Called automatically by the dScript ScriptBuilder and Executer.
 * @param event ReplaceableTagEvent
 */
@EventHandler public void flagTag(ReplaceableTagEvent event){
  if (!event.matches("String_Node_Str"))   return;
  String flagName=event.getValue().split("String_Node_Str").length > 1 ? event.getValue().split("String_Node_Str")[0].toUpperCase() : event.getValue().toUpperCase();
  String flagFallback=event.getAlternative() != null ? event.getAlternative() : "String_Node_Str";
  int index=-1;
  ReplaceType replaceType=ReplaceType.ASSTRING;
  if (flagName.contains("String_Node_Str")) {
    try {
      int replaceTypeIndex=flagName.split("String_Node_Str").length - 1;
      replaceType=ReplaceType.valueOf(flagName.split("String_Node_Str")[replaceTypeIndex].replace("String_Node_Str","String_Node_Str").toUpperCase());
      flagName=flagName.replace("String_Node_Str" + flagName.split("String_Node_Str")[replaceTypeIndex],"String_Node_Str");
    }
 catch (    Exception e) {
      e.printStackTrace();
      replaceType=ReplaceType.ASSTRING;
    }
  }
  if (event.hasValueContext()) {
    try {
      index=Integer.valueOf(event.getValueContext());
    }
 catch (    NumberFormatException e) {
      index=-1;
    }
  }
  if (event.getType().toUpperCase().startsWith("String_Node_Str")) {
    if (denizen.flagManager().getGlobalFlag(flagName).get(index).isEmpty()) {
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getGlobalFlag(flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
 else   if (event.getType().toUpperCase().startsWith("String_Node_Str") || event.getType().toUpperCase().startsWith("String_Node_Str")) {
    if (denizen.flagManager().getNPCFlag(event.getNPC().getId(),flagName).get(index).isEmpty()) {
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getNPCFlag(event.getNPC().getId(),flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
 else   if (event.getType().toUpperCase().startsWith("String_Node_Str")) {
    String name=null;
    if (event.getPlayer() != null)     name=event.getPlayer().getName();
    if (name == null && event.hasOfflinePlayer())     name=event.getOfflinePlayer().getName();
    if (name == null)     return;
    if (denizen.flagManager().getPlayerFlag(name,flagName).get(index).isEmpty()) {
      if (replaceType.toString() == "String_Node_Str")       event.setReplaced("String_Node_Str");
 else       dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getPlayerFlag(name,flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
}

Fixed version (ground truth):
/** 
 * Replaces FLAG TAGs. Called automatically by the dScript ScriptBuilder and Executer.
 * @param event ReplaceableTagEvent
 */
@EventHandler public void flagTag(ReplaceableTagEvent event){
  if (!event.matches("String_Node_Str"))   return;
  if (!event.hasValue())   return;
  String flagName=event.getValue().split("String_Node_Str").length > 1 ? event.getValue().split("String_Node_Str")[0].toUpperCase() : event.getValue().toUpperCase();
  String flagFallback=event.getAlternative() != null ? event.getAlternative() : "String_Node_Str";
  int index=-1;
  ReplaceType replaceType=ReplaceType.ASSTRING;
  if (flagName.contains("String_Node_Str")) {
    try {
      int replaceTypeIndex=flagName.split("String_Node_Str").length - 1;
      replaceType=ReplaceType.valueOf(flagName.split("String_Node_Str")[replaceTypeIndex].replace("String_Node_Str","String_Node_Str").toUpperCase());
      flagName=flagName.replace("String_Node_Str" + flagName.split("String_Node_Str")[replaceTypeIndex],"String_Node_Str");
    }
 catch (    Exception e) {
      e.printStackTrace();
      replaceType=ReplaceType.ASSTRING;
    }
  }
  if (event.hasValueContext()) {
    try {
      index=Integer.valueOf(event.getValueContext());
    }
 catch (    NumberFormatException e) {
      index=-1;
    }
  }
  if (event.getType().toUpperCase().startsWith("String_Node_Str")) {
    if (denizen.flagManager().getGlobalFlag(flagName).get(index).isEmpty()) {
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getGlobalFlag(flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
 else   if (event.getType().toUpperCase().startsWith("String_Node_Str") || event.getType().toUpperCase().startsWith("String_Node_Str")) {
    if (denizen.flagManager().getNPCFlag(event.getNPC().getId(),flagName).get(index).isEmpty()) {
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getNPCFlag(event.getNPC().getId(),flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
 else   if (event.getType().toUpperCase().startsWith("String_Node_Str")) {
    String name=null;
    if (event.getPlayer() != null)     name=event.getPlayer().getName();
    if (name == null && event.hasOfflinePlayer())     name=event.getOfflinePlayer().getName();
    if (name == null)     return;
    if (denizen.flagManager().getPlayerFlag(name,flagName).get(index).isEmpty()) {
      if (replaceType.toString() == "String_Node_Str")       event.setReplaced("String_Node_Str");
 else       dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str",flagName);
    }
 else {
      FlagManager.Flag flag=denizen.flagManager().getPlayerFlag(name,flagName);
      event.setReplaced(getReplaceable(flag,flag.get(index),replaceType));
      dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + ChatColor.WHITE+ "String_Node_Str"+ event.getReplaced()+ "String_Node_Str",flagName);
    }
  }
}