Program: 86116
Project: 86116
Buggy source:
public static void openGUI(final JavaPlugin plugin,String p){
  final int credits=MinigamesAPI.getAPI().pinstances.get(plugin).getStatsInstance().getPoints(p);
  IconMenu iconm=new IconMenu("String_Node_Str" + credits + "String_Node_Str",36,new IconMenu.OptionClickEventHandler(){
    @Override public void onOptionClick(    IconMenu.OptionClickEvent event){
      String d=event.getName();
      Player p=event.getPlayer();
      if (MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().containsKey(d)) {
        openGunMainEditGUI(plugin,p.getName(),d);
      }
 else {
        String raw=event.getItem().getItemMeta().getLore().get(0);
        String gun=raw.substring(0,raw.indexOf("String_Node_Str"));
        Gun g=MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().get(gun);
        if (g != null) {
          int[] pattributes=getPlayerGunAttributeLevels(plugin,p.getName(),g);
          boolean done=false;
          double cost=0.0D;
          if (d.startsWith("String_Node_Str")) {
            int i=pattributes[0];
            cost=Math.pow(level_multiplier,i) * speed_cost;
            if (i < 3 && credits >= cost) {
              openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[0] + 1,cost);
              done=true;
            }
          }
 else           if (d.startsWith("String_Node_Str")) {
            int i=pattributes[1];
            cost=Math.pow(level_multiplier,i) * durability_cost;
            if (i < 3 && credits >= cost) {
              openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[1] + 1,cost);
              done=true;
            }
          }
 else           if (d.startsWith("String_Node_Str")) {
            int i=pattributes[2];
            cost=Math.pow(level_multiplier,i) * shoot_amount_cost;
            if (i < 3 && credits >= cost) {
              openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[2] + 1,cost);
              done=true;
            }
          }
 else           if (d.startsWith("String_Node_Str")) {
            int i=pattributes[3];
            cost=Math.pow(level_multiplier,i) * knockback_multiplier_cost;
            if (i < 3 && credits >= cost) {
              openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[3] + 1,cost);
              done=true;
            }
          }
          if (!done) {
            p.sendMessage(MinigamesAPI.getAPI().pinstances.get(plugin).getMessagesConfig().not_enough_credits.replaceAll("String_Node_Str",Double.toString(cost)));
          }
        }
      }
      event.setWillClose(false);
    }
  }
,plugin);
  int c=0;
  for (  String ac : MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().keySet()) {
    Gun ac_=MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().get(ac);
    int[] pattributes=getPlayerGunAttributeLevels(plugin,p,ac_);
    iconm.setOption(c,ac_.icon.get(0),ac,MinigamesAPI.getAPI().pinstances.get(plugin).getGunsConfig().getConfig().getString("String_Node_Str" + ac + "String_Node_Str"));
    iconm.setOption(c + 2,new ItemStack(Material.SUGAR),"String_Node_Str" + ChatColor.DARK_RED + pattributes[0],ac + "String_Node_Str");
    iconm.setOption(c + 3,new ItemStack(Material.DIAMOND),"String_Node_Str" + ChatColor.DARK_RED + pattributes[1],ac + "String_Node_Str");
    iconm.setOption(c + 4,new ItemStack(Material.EGG),"String_Node_Str" + ChatColor.DARK_RED + pattributes[2],ac + "String_Node_Str");
    iconm.setOption(c + 5,new ItemStack(Material.STICK),"String_Node_Str" + ChatColor.DARK_RED + pattributes[3],ac + "String_Node_Str");
    c+=9;
  }
  iconm.open(Bukkit.getPlayerExact(p));
}

Fixed version (ground truth):
public static void openGUI(final JavaPlugin plugin,String p){
  final int credits=MinigamesAPI.getAPI().pinstances.get(plugin).getStatsInstance().getPoints(p);
  IconMenu iconm;
  if (lastmainiconm.containsKey(p)) {
    iconm=lastmainiconm.get(p);
  }
 else {
    iconm=new IconMenu("String_Node_Str" + credits + "String_Node_Str",36,new IconMenu.OptionClickEventHandler(){
      @Override public void onOptionClick(      IconMenu.OptionClickEvent event){
        String d=event.getName();
        Player p=event.getPlayer();
        if (MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().containsKey(d)) {
          openGunMainEditGUI(plugin,p.getName(),d);
        }
 else {
          String raw=event.getItem().getItemMeta().getLore().get(0);
          String gun=raw.substring(0,raw.indexOf("String_Node_Str"));
          Gun g=MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().get(gun);
          if (g != null) {
            int[] pattributes=getPlayerGunAttributeLevels(plugin,p.getName(),g);
            boolean done=false;
            double cost=0.0D;
            if (d.startsWith("String_Node_Str")) {
              int i=pattributes[0];
              cost=Math.pow(level_multiplier,i) * speed_cost;
              if (i < 3 && credits >= cost) {
                openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[0] + 1,cost);
                done=true;
              }
            }
 else             if (d.startsWith("String_Node_Str")) {
              int i=pattributes[1];
              cost=Math.pow(level_multiplier,i) * durability_cost;
              if (i < 3 && credits >= cost) {
                openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[1] + 1,cost);
                done=true;
              }
            }
 else             if (d.startsWith("String_Node_Str")) {
              int i=pattributes[2];
              cost=Math.pow(level_multiplier,i) * shoot_amount_cost;
              if (i < 3 && credits >= cost) {
                openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[2] + 1,cost);
                done=true;
              }
            }
 else             if (d.startsWith("String_Node_Str")) {
              int i=pattributes[3];
              cost=Math.pow(level_multiplier,i) * knockback_multiplier_cost;
              if (i < 3 && credits >= cost) {
                openUpgradeGUI(plugin,p.getName(),gun,"String_Node_Str",pattributes[3] + 1,cost);
                done=true;
              }
            }
            if (!done) {
              p.sendMessage(MinigamesAPI.getAPI().pinstances.get(plugin).getMessagesConfig().not_enough_credits.replaceAll("String_Node_Str",Double.toString(cost)));
            }
          }
        }
        event.setWillClose(false);
      }
    }
,plugin);
    lastmainiconm.put(p,iconm);
  }
  int c=0;
  for (  String ac : MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().keySet()) {
    Gun ac_=MinigamesAPI.getAPI().pinstances.get(plugin).getAllGuns().get(ac);
    int[] pattributes=getPlayerGunAttributeLevels(plugin,p,ac_);
    iconm.setOption(c,ac_.icon.get(0),ac,MinigamesAPI.getAPI().pinstances.get(plugin).getGunsConfig().getConfig().getString("String_Node_Str" + ac + "String_Node_Str"));
    iconm.setOption(c + 2,new ItemStack(Material.SUGAR),"String_Node_Str" + ChatColor.DARK_RED + pattributes[0],ac + "String_Node_Str");
    iconm.setOption(c + 3,new ItemStack(Material.DIAMOND),"String_Node_Str" + ChatColor.DARK_RED + pattributes[1],ac + "String_Node_Str");
    iconm.setOption(c + 4,new ItemStack(Material.EGG),"String_Node_Str" + ChatColor.DARK_RED + pattributes[2],ac + "String_Node_Str");
    iconm.setOption(c + 5,new ItemStack(Material.STICK),"String_Node_Str" + ChatColor.DARK_RED + pattributes[3],ac + "String_Node_Str");
    c+=9;
  }
  iconm.open(Bukkit.getPlayerExact(p));
}