Program: 10416
Project: 10416
Buggy source:
/** 
 * <p> This is the trigger that fires when any player moves in the entire world.  The trigger ONLY checks if the player moves to a new BLOCK in the world</p> When the trigger determines that the player has moved to a different block in the world, all of the NPCs are checked for the following criteria: <ol> <li>Does the NPC have the trigger trait?</li> <li>Is the trigger enabled?</li> <li>Is the NPC available (i.e. not busy)?</li> <li>Is the NPC Spawned?</li> <li>Is the NPC in the same World as the player</li> </ol> If the NPC passes all of these criteria, there are three events that can occur (only one of them): <ol> <li>If the player was outside of the NPC's radius, and moved inside the radius, and there's a SCRIPT or an ENTRY SCRIPT, then execute that entry script.</li> <li>If the player was INSIDE of the NPC's radius, and moved OUTSIDE the radius, and there's an EXIT SCRIPT, then execute that exit script. <li>If the player was INSIDE of the NPC's radius, and moved WITHIN the radius, and there's an MOVE SCRIPT, then execute that move script. </ol>
 * @param event	The player's move event (which includes their location).
 */
@EventHandler public void proximityTrigger(PlayerMoveEvent event){
  if (!event.getTo().getBlock().equals(event.getFrom().getBlock())) {
    Location toBlockLocation=event.getTo().getBlock().getLocation();
    Iterator<dNPC> it=DenizenAPI.getCurrentInstance().getNPCRegistry().getSpawnedNPCs().iterator();
    while (it.hasNext()) {
      dNPC npc=it.next();
      if (!npc.getCitizen().hasTrait(TriggerTrait.class))       continue;
      if (!npc.getCitizen().getTrait(TriggerTrait.class).isEnabled(name))       continue;
      if (!npc.isSpawned() || (!npc.getWorld().equals(event.getPlayer().getWorld()) && hasExitedProximityOf(event.getPlayer(),npc)))       continue;
      if (!isCloseEnough(event.getPlayer(),npc) && hasExitedProximityOf(event.getPlayer(),npc))       continue;
      Player player=event.getPlayer();
      InteractScriptContainer script=npc.getInteractScriptQuietly(event.getPlayer(),this.getClass());
      double entryRadius=npc.getTriggerTrait().getRadius(name);
      double exitRadius=npc.getTriggerTrait().getRadius(name);
      double moveRadius=npc.getTriggerTrait().getRadius(name);
      if (script != null) {
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           entryRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + entryRadius + "String_Node_Str");
        }
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           exitRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + exitRadius + "String_Node_Str");
        }
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           moveRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + moveRadius + "String_Node_Str");
        }
      }
      Location npcLocation=npc.getLocation();
      boolean playerChangedWorlds=false;
      if (npcLocation.getWorld() != event.getPlayer().getWorld())       playerChangedWorlds=true;
      boolean exitedProximity=hasExitedProximityOf(event.getPlayer(),npc);
      double distance=npcLocation.distance(toBlockLocation);
      if (!exitedProximity && (playerChangedWorlds || distance >= exitRadius)) {
        if (!npc.getTriggerTrait().triggerCooldownOnly(this,event.getPlayer()))         continue;
        exitProximityOf(event.getPlayer(),npc);
        dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + npc.getName()+ "String_Node_Str");
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
 else       if (exitedProximity && distance <= entryRadius) {
        if (!npc.getTriggerTrait().triggerCooldownOnly(this,event.getPlayer()))         continue;
        enterProximityOf(event.getPlayer(),npc);
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
 else       if (!exitedProximity && distance <= moveRadius) {
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * <p> This is the trigger that fires when any player moves in the entire world.  The trigger ONLY checks if the player moves to a new BLOCK in the world</p> When the trigger determines that the player has moved to a different block in the world, all of the NPCs are checked for the following criteria: <ol> <li>Does the NPC have the trigger trait?</li> <li>Is the trigger enabled?</li> <li>Is the NPC available (i.e. not busy)?</li> <li>Is the NPC Spawned?</li> <li>Is the NPC in the same World as the player</li> </ol> If the NPC passes all of these criteria, there are three events that can occur (only one of them): <ol> <li>If the player was outside of the NPC's radius, and moved inside the radius, and there's a SCRIPT or an ENTRY SCRIPT, then execute that entry script.</li> <li>If the player was INSIDE of the NPC's radius, and moved OUTSIDE the radius, and there's an EXIT SCRIPT, then execute that exit script. <li>If the player was INSIDE of the NPC's radius, and moved WITHIN the radius, and there's an MOVE SCRIPT, then execute that move script. </ol>
 * @param event	The player's move event (which includes their location).
 */
@EventHandler public void proximityTrigger(PlayerMoveEvent event){
  if (!event.getTo().getBlock().equals(event.getFrom().getBlock())) {
    Location toBlockLocation=event.getTo().getBlock().getLocation();
    Iterator<dNPC> it=DenizenAPI.getCurrentInstance().getNPCRegistry().getSpawnedNPCs().iterator();
    while (it.hasNext()) {
      dNPC npc=it.next();
      if (!npc.getCitizen().hasTrait(TriggerTrait.class))       continue;
      if (!npc.getCitizen().getTrait(TriggerTrait.class).isEnabled(name))       continue;
      if (!npc.isSpawned() || (!npc.getWorld().equals(event.getPlayer().getWorld()) && hasExitedProximityOf(event.getPlayer(),npc)))       continue;
      if (!isCloseEnough(event.getPlayer(),npc) && hasExitedProximityOf(event.getPlayer(),npc))       continue;
      Player player=event.getPlayer();
      InteractScriptContainer script=npc.getInteractScriptQuietly(event.getPlayer(),this.getClass());
      double entryRadius=npc.getTriggerTrait().getRadius(name);
      double exitRadius=npc.getTriggerTrait().getRadius(name);
      double moveRadius=npc.getTriggerTrait().getRadius(name);
      if (script != null) {
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           entryRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + entryRadius + "String_Node_Str");
        }
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           exitRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + exitRadius + "String_Node_Str");
        }
        try {
          if (script.hasTriggerOptionFor(getClass(),player,null,"String_Node_Str"))           moveRadius=Integer.valueOf(script.getTriggerOptionFor(getClass(),player,null,"String_Node_Str"));
        }
 catch (        NumberFormatException nfe) {
          dB.echoDebug("String_Node_Str" + moveRadius + "String_Node_Str");
        }
      }
      Location npcLocation=npc.getLocation();
      boolean playerChangedWorlds=false;
      if (npcLocation.getWorld() != event.getPlayer().getWorld())       playerChangedWorlds=true;
      boolean exitedProximity=hasExitedProximityOf(event.getPlayer(),npc);
      double distance=0;
      if (!playerChangedWorlds)       distance=npcLocation.distance(toBlockLocation);
      if (!exitedProximity && (playerChangedWorlds || distance >= exitRadius)) {
        if (!npc.getTriggerTrait().triggerCooldownOnly(this,event.getPlayer()))         continue;
        exitProximityOf(event.getPlayer(),npc);
        dB.echoDebug(ChatColor.YELLOW + "String_Node_Str" + npc.getName()+ "String_Node_Str");
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
 else       if (exitedProximity && distance <= entryRadius) {
        if (!npc.getTriggerTrait().triggerCooldownOnly(this,event.getPlayer()))         continue;
        enterProximityOf(event.getPlayer(),npc);
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
 else       if (!exitedProximity && distance <= moveRadius) {
        npc.action("String_Node_Str",event.getPlayer());
        parse(npc,player,script,"String_Node_Str");
      }
    }
  }
}