Emberveil source

tests/OwnerSlayerLiveCheck.java

import com.rs2.game.content.emberveil.*;
import com.rs2.game.players.*;
import com.rs2.game.npcs.*;
import com.rs2.util.NpcSpawn;
import com.rs2.world.clip.*;
import org.apollo.cache.*;
import org.apollo.cache.decoder.*;
import com.google.gson.Gson;
import java.io.*;import java.nio.file.*;import java.util.*;
/** Isolated player only. Reads world data, never authenticates or saves the owner. */
public final class OwnerSlayerLiveCheck {
 static class F extends Client {
  F(int task,int left){super(null,1);playerName=playerName2="bonds";playerRights=3;slayerTask=task;taskAmount=left;tutorialProgress=36;isActive=true;respawnTimer=-6;absX=3233;absY=3229;heightLevel=0;teleportToX=teleportToY=-1;Arrays.fill(playerLevel,99);Arrays.fill(playerXP,13034431);getOutStream().packetEncryption=new org.apollo.util.security.IsaacRandom(new int[]{1,2,3,4});}
  public void flushOutStream(){getOutStream().currentOffset=0;}
 }
 public static void main(String[]args)throws Exception {
  IndexedFileSystem c=new IndexedFileSystem(Paths.get("data/cache"),true);new ItemDefinitionDecoder(c).run();new NpcDefinitionDecoder(c).run();new ObjectDefinitionDecoder(c).run();RegionFactory.load(c);
  NpcSpawn[] spawns=new Gson().fromJson(new FileReader("data/cfg/spawns.json"),NpcSpawn[].class);int i=1;
  for(NpcSpawn s:spawns){Npc n=new Npc(i,s.getId());n.absX=n.makeX=s.getX();n.absY=n.makeY=s.getY();n.heightLevel=s.getHeight();NpcHandler.npcs[i++]=n;}
  F p=new F(Integer.parseInt(args[0]),Integer.parseInt(args[1]));int[] dest=SlayerTaskTeleport.destination(p.slayerTask);if(dest==null)throw new AssertionError("No live assignment destination");
  for(String command:new String[]{"slayertask","slayertask","slayzone"}) {
   if(!Emberveil.handle(p,command,new String[0])||!p.isTeleporting||p.teleTimer<=0)throw new AssertionError("Command did not initiate teleport");
   p.getPlayerAssistant().processTeleport();p.getNextPlayerMovement();
   if(p.absX!=dest[0]||p.absY!=dest[1]||p.heightLevel!=dest[2])throw new AssertionError("Actual movement did not reach assignment");
   p.teleTimer=0; // Completed timer, intentionally retain legacy flag and do not walk.
  }
  if(p.taskAmount!=Integer.parseInt(args[1]))throw new AssertionError("Assignment changed");
  System.out.println("PASS both commands and repeated completed movement to live assignment "+p.getSlayer().getTaskName(p.slayerTask)+" at "+p.absX+","+p.absY+","+p.heightLevel+"; remaining="+p.taskAmount+"; isolated player, no save changed");
 }
}