Emberveil source

tests/CrabClueCheck.java

import com.rs2.Constants;
import com.rs2.GameEngine;
import com.rs2.game.players.*;
import com.rs2.game.npcs.*;
import com.rs2.world.ItemHandler;
import com.google.gson.*;
import java.io.FileReader;
public final class CrabClueCheck {
 static class Drops extends ItemHandler {
  int clues,other;
  @Override public void createGroundItem(Player p,int id,int x,int y,int amount,int owner){if(id==2677)clues++;else if(id>0)other++;}
 }
 public static void main(String[] args)throws Exception {
  try(FileReader input=new FileReader("Emberveil.json")){if(!new Gson().fromJson(input,JsonObject.class).get("clues_enabled").getAsBoolean())throw new AssertionError("Clues disabled in config");}
  NpcHandler handler=GameEngine.npcHandler;int count=0,slot=-1;
  for(int i=1;i<NpcHandler.npcs.length;i++){Npc n=NpcHandler.npcs[i];if(n!=null&&n.npcType==1267){count++;slot=i;if(n.MaxHP!=50)throw new AssertionError("Rock crab HP");}}
  if(count<20||slot<0||NpcHandler.getNpcListCombat(1267)!=13)throw new AssertionError("Rock crab spawns/combat definition");
  Client player=new Client(null,1);PlayerHandler.players[1]=player;Npc crab=NpcHandler.npcs[slot];crab.killedBy=1;
  Drops drops=new Drops();GameEngine.itemHandler=drops;Constants.CLUES_ENABLED=true;
  for(int i=0;i<10000;i++)handler.dropItems(slot);
  if(drops.clues==0||drops.other==0)throw new AssertionError("No clue or ordinary drops through actual NPC death path");
  PlayerHandler.players[1]=null;
  System.out.println("PASS "+count+" rock crab spawns, level 13 / 50 HP, and "+drops.clues+" easy clues from 10000 simulated crab deaths; no live world touched");
 }
}