forked from unimatrix/web
Fresh production baseline [skip ci]
This commit is contained in:
commit
0a11a18274
1 changed files with 229644 additions and 0 deletions
6
tools/probes/QuestRoleProbe.java
Normal file
6
tools/probes/QuestRoleProbe.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package com.dunerealms.gui;
|
||||
import org.bukkit.*;import org.bukkit.entity.*;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.persistence.PersistentDataType;import java.util.*;
|
||||
public final class QuestRoleProbe extends JavaPlugin{
|
||||
public void onEnable(){Bukkit.getScheduler().runTaskLater(this,()->{try{World w=Bukkit.getWorlds().getFirst();getLogger().info("Probe world "+w.getName());if(!w.getName().equals("arrakis"))throw new AssertionError("Unexpected isolated world name "+w.getName());Location spawn=w.getSpawnLocation();spawn.setY(w.getHighestBlockYAt(spawn)+1);w.setSpawnLocation(spawn);var roles=new PolQuestNpc(this,(p,r)->{});var ensure=PolQuestNpc.class.getDeclaredMethod("ensure",World.class);ensure.setAccessible(true);ensure.invoke(roles,w);var expected=Set.of("stilgar","shadout_mapes","chani","liet_kynes","alia_atreides","esmar_tuek");Map<String,UUID> ids=new HashMap<>();for(var e:w.getEntitiesByClass(LivingEntity.class)){String key=e.getPersistentDataContainer().get(PolQuestNpc.KEY,PersistentDataType.STRING);if(key!=null){if(ids.put(key,e.getUniqueId())!=null)throw new AssertionError("Duplicate NPC "+key);if(!e.isPersistent()||!e.isInvulnerable())throw new AssertionError("Unprotected NPC "+key);}}
|
||||
if(!ids.keySet().equals(expected))throw new AssertionError("Incorrect NPC roles "+ids.keySet());var next=new PolQuestNpc(this,(p,r)->{});ensure.invoke(next,w);Map<String,UUID> after=new HashMap<>();for(var e:w.getEntitiesByClass(LivingEntity.class)){String key=e.getPersistentDataContainer().get(PolQuestNpc.KEY,PersistentDataType.STRING);if(key!=null&&after.put(key,e.getUniqueId())!=null)throw new AssertionError("Duplicate subsequent NPC "+key);}if(!ids.equals(after))throw new AssertionError("Stationary identities changed");getLogger().info("QUEST_ROLE_PROBE_PASS six stationary named NPCs, preserved IDs on reloading positions");}catch(Throwable failure){getLogger().severe("QUEST_ROLE_PROBE_FAIL "+failure);failure.printStackTrace();}finally{Bukkit.shutdown();}},80L);}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff