Emberveil source

tests/PublicServerStatusCheck.java

import com.rs2.game.content.emberveil.PublicServerStatus;
import com.rs2.game.players.Player;
import com.rs2.game.players.Client;
import java.nio.file.*;
import java.nio.charset.StandardCharsets;

public final class PublicServerStatusCheck {
 public static void main(String[] args)throws Exception {
  Client active=new Client(null,1); active.isActive=true; active.disconnected=false;
  Client offline=new Client(null,2); offline.isActive=true; offline.disconnected=true;
  Client pending=new Client(null,3); pending.isActive=false;
  Client bot=new Client(null); bot.isActive=true; bot.disconnected=false;
  Player[] players={null,active,offline,pending,bot};
  if(PublicServerStatus.countPlayers(players)!=1) throw new AssertionError("Only active human accounts count");
  Path file=Paths.get("runtime/status-test.json");
  PublicServerStatus.write(file,2,123456789L);
  String json=new String(Files.readAllBytes(file),StandardCharsets.UTF_8);
  if(!json.equals("{\"online\":true,\"players\":2,\"updatedAt\":123456789}\n")) throw new AssertionError(json);
  PublicServerStatus.write(file,0,123456790L);
  if(!new String(Files.readAllBytes(file),StandardCharsets.UTF_8).contains("\"players\":0")) throw new AssertionError("Count did not replace");
  if(Files.exists(Paths.get("runtime/status-test.json.tmp"))) throw new AssertionError("Partial file remains");
  System.out.println("PASS: live human filtering, zero players, aggregate-only output and atomic file replacement");
 }
}