Merge pull request 'Complete native House T0 kit collection and original-kit repair quests' (#520) from feature/starter-kit-native-20261123 into main
All checks were successful
DuneRealms Web CI / web (push) Successful in 2m42s

This commit is contained in:
unimatrix 2026-11-23 08:08:23 +00:00
commit de5bfb2954
31 changed files with 352 additions and 29 deletions

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.dunerealms"
version = "1.1.13"
version = "1.1.14"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")

View file

@ -70,6 +70,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
departure=Bukkit.createBossBar("Spacing Guild · next Imperial departure",BarColor.YELLOW,BarStyle.SOLID);
Bukkit.getScheduler().runTaskTimer(this,this::tick,20L,20L);
Bukkit.getScheduler().runTaskLater(this,this::ensureRegistrar,40L);
new QuartermasterNpc(this,p->quests.quartermaster(p,()->exchange.open(p),()->exchange.openKits(p)));
Bukkit.getScheduler().runTaskTimer(this,()->{for(Player p:Bukkit.getOnlinePlayers()){removeOldNavigators(p);refreshSidebar(p);}},80L,600L);
getLogger().info("House selector and Mentat screens enabled; central J.A.R.V.I.S. bridge; no Core/Lobby replacement.");
}

View file

@ -28,6 +28,7 @@ final class ExchangeMenus implements Listener,AutoCloseable {
private final java.util.concurrent.ConcurrentMap<UUID,org.bukkit.conversations.Conversation> priceInputs=new java.util.concurrent.ConcurrentHashMap<>();
ExchangeMenus(JavaPlugin plugin,HouseBridge bridge,Consumer<Player> back,Predicate<Player> artwork){this.plugin=plugin;this.bridge=bridge;this.back=back;this.artwork=artwork;Bukkit.getPluginManager().registerEvents(this,plugin);Bukkit.getScheduler().runTaskTimer(plugin,()->{for(Player p:Bukkit.getOnlinePlayers())deliver(p,false);},80L,1200L);}
void open(Player p){deliver(p,false);var retry=retries.get(p.getUniqueId());if(retry!=null){purchase(p,retry);return;}list(p,false,0);}
void openKits(Player p){deliver(p,false);kits(p,0);}
private static String money(long value){return BigDecimal.valueOf(value,2).toPlainString()+" DM";}
static long price(String text){return ExchangePrice.parse(text);}
private static ItemStack icon(Material material,String title,String... lore){var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(lore).map(s->Component.text(s,NamedTextColor.GRAY)).toList());item.setItemMeta(meta);return item;}

View file

@ -29,6 +29,8 @@ final class HouseBridge {
void refreshKits(org.bukkit.entity.Player player)throws Exception{call(translator.getClass().getMethod("refreshKits",org.bukkit.entity.Player.class),player);}
java.util.UUID refinerNpc(org.bukkit.entity.Player player)throws Exception{return (java.util.UUID)call(translator.getClass().getMethod("refinerNpc",org.bukkit.entity.Player.class),player);}
void refineSpice(org.bukkit.entity.Player player,JsonObject permit)throws Exception{call(translator.getClass().getMethod("refineSpice",org.bukkit.entity.Player.class,JsonObject.class),player,permit);}
java.util.UUID starterNpc(org.bukkit.entity.Player player)throws Exception{return (java.util.UUID)call(translator.getClass().getMethod("starterNpc",org.bukkit.entity.Player.class),player);}
void starterKit(org.bukkit.entity.Player player,JsonObject permit)throws Exception{call(translator.getClass().getMethod("starterKit",org.bukkit.entity.Player.class,JsonObject.class),player,permit);}
void citizenIntroduction(org.bukkit.entity.Player player)throws Exception{call(translator.getClass().getMethod("citizenIntroduction",org.bukkit.entity.Player.class),player);}
JsonObject itemPreview(UUID player,UUID id,int revision)throws Exception{return (JsonObject)call(translator.getClass().getMethod("requestItemPreview",UUID.class,UUID.class,int.class),player,id,revision);}
org.bukkit.inventory.ItemStack buildItemPreview(org.bukkit.entity.Player player,JsonObject data,boolean panels)throws Exception{return (org.bukkit.inventory.ItemStack)call(translator.getClass().getMethod("buildItemPreview",org.bukkit.entity.Player.class,JsonObject.class,boolean.class),player,data,panels);}

View file

@ -0,0 +1,17 @@
package com.dunerealms.gui;
import org.bukkit.*;import org.bukkit.entity.*;import org.bukkit.event.*;import org.bukkit.event.player.PlayerInteractEntityEvent;import org.bukkit.event.world.WorldLoadEvent;import org.bukkit.inventory.EquipmentSlot;import org.bukkit.persistence.PersistentDataType;import org.bukkit.plugin.java.JavaPlugin;
import java.util.function.Consumer;import net.kyori.adventure.text.Component;import net.kyori.adventure.text.format.NamedTextColor;
/** One invulnerable service NPC per primary world, using the existing GUI screens. */
final class QuartermasterNpc implements Listener{
private final JavaPlugin plugin;private final Consumer<Player> open;private final NamespacedKey key=new NamespacedKey("dunerealms","quartermaster");
QuartermasterNpc(JavaPlugin plugin,Consumer<Player> open){this.plugin=plugin;this.open=open;Bukkit.getPluginManager().registerEvents(this,plugin);Bukkit.getScheduler().runTaskLater(plugin,()->Bukkit.getWorlds().forEach(this::ensure),60);}
private void ensure(World world){
if(world.getEnvironment()!=World.Environment.NORMAL&&!world.getName().equals("guild_lobby"))return;
var spawn=world.getSpawnLocation();spawn.getChunk().load();if(world.getEntitiesByClass(Villager.class).stream().anyMatch(e->e.getPersistentDataContainer().has(key,PersistentDataType.BYTE)))return;
var at=spawn.clone().add(3,0,0);if(!at.getBlock().isPassable()||!at.clone().add(0,1,0).getBlock().isPassable()||!at.clone().add(0,-1,0).getBlock().getType().isSolid())at=spawn.clone();
Villager npc=world.spawn(at,Villager.class);npc.setAI(false);npc.setInvulnerable(true);npc.setPersistent(true);npc.setRemoveWhenFarAway(false);npc.setSilent(true);npc.setCollidable(false);npc.setProfession(Villager.Profession.ARMORER);npc.customName(Component.text("Gurney Halleck · Quartermaster",NamedTextColor.GOLD));npc.setCustomNameVisible(true);npc.getPersistentDataContainer().set(key,PersistentDataType.BYTE,(byte)1);
}
@EventHandler public void world(WorldLoadEvent e){Bukkit.getScheduler().runTaskLater(plugin,()->ensure(e.getWorld()),60);}
@EventHandler public void interact(PlayerInteractEntityEvent e){if(!e.getRightClicked().getPersistentDataContainer().has(key,PersistentDataType.BYTE))return;e.setCancelled(true);if(e.getHand()==EquipmentSlot.HAND)open.accept(e.getPlayer());}
}

View file

@ -24,6 +24,7 @@ final class QuestMenus implements Listener {
public Inventory getInventory(){return inventory;}
}
QuestMenus(JavaPlugin plugin,HouseBridge bridge,Consumer<Player> back){this.plugin=plugin;this.bridge=bridge;this.back=back;Bukkit.getPluginManager().registerEvents(this,plugin);}
void quartermaster(Player p,Runnable exchange,Runnable kits){var s=panel(p,"Gurney · Quartermaster");put(s,20,"Exchange","Buy and sell individual items",Material.EMERALD,exchange);put(s,22,"Missions & turn-ins","Collect your House T0 kit or repair its original armour.\nPrepare four parts: one iron ingot, leather, copper ingot and quartz.\nOther missions and rewards use your current central journal.",Material.WRITABLE_BOOK,()->open(p));put(s,24,"Stillsuit kits","Published clan, company and office kits",Material.NETHERITE_CHESTPLATE,kits);put(s,49,"Close","Return to the world",Material.ARROW,p::closeInventory);show(p,s);}
private static String text(JsonObject row,String key,String fallback){return row.has(key)&&!row.get(key).isJsonNull()?row.get(key).getAsString():fallback;}
private static boolean yes(JsonObject row,String key){return row.has(key)&&!row.get(key).isJsonNull()&&row.get(key).getAsBoolean();}
private static boolean website(JsonObject row){return row.has("executionRequirements")&&!row.get("executionRequirements").isJsonNull()&&yes(row.getAsJsonObject("executionRequirements"),"website")&&!yes(row.getAsJsonObject("executionRequirements"),"minecraft");}
@ -65,17 +66,22 @@ final class QuestMenus implements Listener {
else if(yes(row,"canStart")&&!state.equals("active")&&!state.equals("claimed")&&!state.equals("completed"))put(screen,31,"Start mission","Accept this objective through J.A.R.V.I.S.",Material.LIME_DYE,()->act(p,kind,branch,page,row,"start"));
else put(screen,31,state.equals("claimed")?"Reward claimed":"Awaiting verified progress","No reward can be issued from an unverified objective",Material.GRAY_DYE,null);
if(kind.equals("pol")&&Set.of("POL-ELYTRA-REFINE","POL-ELYTRA-CONTAMINATE").contains(text(row,"id",""))&&(yes(row,"canStart")||Set.of("active","completed","claimed").contains(state)))put(screen,33,"Refine at NPC","Stand near an Arrakis Smuggler.\nTurn in the ingredients shown in this quest.",Material.ORANGE_DYE,()->refine(p,kind,data,branch,page,row));
if(kind.equals("personal")&&(yes(row,"canStart")||Set.of("active","completed","claimed").contains(state))){
if(text(row,"id","").equals("S1-H-01"))put(screen,33,"Collect House T0 kit","Visit Gurney's quartermaster.\nFour Common MK 0 stillsuit pieces at half durability.\nOne Uncommon MK I wooden spice shovel.\nOne original kit per account and season.",Material.NETHERITE_CHESTPLATE,()->starter(p,kind,branch,page,row,"obtain"));
if(text(row,"id","").equals("S1-H-02")){put(screen,29,"Prepare four repair parts","Turn in one iron ingot, leather, copper ingot and quartz.\nEach becomes one Uncommon MK I repair component.",Material.IRON_INGOT,()->starter(p,kind,branch,page,row,"parts"));put(screen,33,"Surrender original kit & parts","Hand in the four original bound armour pieces\nand all four prepared parts.\nThen claim this quest to receive the intact kit.",Material.ANVIL,()->starter(p,kind,branch,page,row,"repair"));}
}
if(row.has("recipe")&&!row.get("recipe").isJsonNull())put(screen,22,"Revealed recipe","Craft on Arrakis · Very Rare · MK XI\nNetherite | Membrane | Netherite\nIron | Diamond | Iron\nContaminated spice | Membrane | Contaminated spice",Material.ELYTRA,null);
put(screen,45,"Back","Mission branch",Material.ARROW,()->quests(p,kind,data,branch,page));put(screen,49,"Refresh","Read current progress",Material.CLOCK,()->load(p,kind,branch,text(row,"id",""),page));show(p,screen);
}
private void refine(Player p,String kind,JsonObject data,String branch,int page,JsonObject row){try{var input=new JsonObject();input.addProperty("action","prepare_refine");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.refinerNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.refineSpice(p,permit);p.sendMessage(Component.text("Spice refined. Your quest receipt is queued for confirmation.",NamedTextColor.GREEN));load(p,kind,branch,text(row,"id",""),page);}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Refinement unavailable. Reopen the quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit an Arrakis Smuggler first.":failure.getMessage(),NamedTextColor.RED));}}
private void starter(Player p,String kind,String branch,int page,JsonObject row,String operation){try{var input=new JsonObject();input.addProperty("action","prepare_starter");input.addProperty("kind","personal");input.addProperty("definitionId",text(row,"id",""));input.addProperty("operation",operation);input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.starterKit(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Your equipment exchange remains available. Reopen the quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit the quest quartermaster first.":failure.getMessage(),NamedTextColor.RED));}}
private void introduction(Player p,String kind,JsonObject data,String branch,int page,JsonObject row){
var screen=panel(p,"Imperial Citizen briefing");
put(screen,13,"Welcome, Imperial Citizen","Your House determines normal travel authority.\nGuild travel uses boarding windows and your central bank.\nClan and company actions follow current deeds.\nBlue missions require ingame actions or item turn-ins.\nWebsite missions use your linked website account.\nRead your Mentat Report for current news and duties.",Material.WRITTEN_BOOK,null);
put(screen,30,"I understand","Confirm that you have read this briefing",Material.LIME_DYE,()->{try{bridge.citizenIntroduction(p);p.closeInventory();p.sendMessage(Component.text("Citizen briefing submitted. Refresh your mission journal in a few seconds to claim its verified reward.",NamedTextColor.GREEN));}catch(Exception unavailable){p.sendMessage("The briefing could not be recorded. Please reopen the journal.");}});
put(screen,32,"Back","Return without confirming",Material.ARROW,()->details(p,kind,data,branch,page,row));show(p,screen);
}
private void act(Player p,String kind,String branch,int page,JsonObject row,String action){var input=new JsonObject();input.addProperty("action",action);input.addProperty("kind",kind);input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);if(action.equals("claim"))input.add("revision",row.get("revision"));request(p,input,result->{p.sendMessage(Component.text(action.equals("claim")?"Verified quest reward recorded.":"Mission accepted.",NamedTextColor.GREEN));load(p,kind,branch,text(row,"id",""),page);});}
private void act(Player p,String kind,String branch,int page,JsonObject row,String action){var input=new JsonObject();input.addProperty("action",action);input.addProperty("kind",kind);input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);if(action.equals("claim"))input.add("revision",row.get("revision"));request(p,input,result->{p.sendMessage(Component.text(action.equals("claim")?"Verified quest reward recorded.":"Mission accepted.",NamedTextColor.GREEN));if(action.equals("claim")&&text(row,"id","").equals("S1-H-02"))try{bridge.refreshKits(p);}catch(Exception unavailable){p.sendMessage("Your intact replacement remains queued for delivery.");}load(p,kind,branch,text(row,"id",""),page);});}
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!(e.getWhoClicked() instanceof Player p)||!panel.owner.equals(p.getUniqueId())||e.getClickedInventory()!=panel.inventory||e.getClick()!=ClickType.LEFT)return;var action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(p.getUniqueId()))Bukkit.getScheduler().runTask(plugin,()->{if(p.isOnline()&&p.getOpenInventory().getTopInventory()==panel.inventory)action.run();});}
@EventHandler public void drag(InventoryDragEvent e){if(e.getView().getTopInventory().getHolder() instanceof Panel)e.setCancelled(true);}
@EventHandler public void closed(InventoryCloseEvent e){if(e.getInventory().getHolder() instanceof Panel panel)panel.gate.expire();}

View file

@ -1,6 +1,6 @@
name: DunerealmsGUI
main: com.dunerealms.gui.DuneGUI
version: 1.1.13
version: 1.1.14
api-version: '1.21.8'
depend: [JarvisTranslator]
softdepend: [DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.dunerealms"
version = "0.5.22"
version = "0.5.23"
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") }
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")

View file

@ -132,6 +132,34 @@ final class ExchangeInventory {
String engine=data.get(new NamespacedKey("executableitems","ei-id"),PersistentDataType.STRING);
return contaminated?"refined_spice".equals(engine):(engine==null||engine.equals("spice"))&&"spice".equals(data.get(new NamespacedKey("dunerealms","item"),PersistentDataType.STRING));
}
record StarterReceipt(UUID id,String kind,String server,long occurredAt){}
private StarterReceipt starterReceipt(Connection c,UUID id)throws SQLException{
try(var q=prepare(c,"SELECT kind,listing_id,created_at FROM dune_exchange_inventory_ops WHERE id=?")){q.setString(1,id.toString());try(var r=q.executeQuery()){if(!r.next())throw new SQLException("Starter receipt unavailable");int origin=r.getInt(2);if(origin<0||origin>=SERVERS.size())throw new SQLException("Invalid starter receipt origin");return new StarterReceipt(id,r.getString(1),SERVERS.get(origin),r.getLong(3));}}
}
List<StarterReceipt> starterReceipts(Player p)throws Exception{return atomic(p,c->{var rows=new ArrayList<StarterReceipt>();try(var q=prepare(c,"SELECT id FROM dune_exchange_inventory_ops WHERE actor_uuid=? AND kind IN ('starter-obtain','starter-repair') ORDER BY created_at DESC LIMIT 16")){q.setString(1,p.getUniqueId().toString());try(var r=q.executeQuery()){while(r.next())rows.add(starterReceipt(c,UUID.fromString(r.getString(1))));}}return rows;});}
static String starterSlot(ItemStack item,String instance){
if(item==null||item.isEmpty()||!item.hasItemMeta())return null;var data=item.getItemMeta().getPersistentDataContainer();if(!instance.equals(data.get(new NamespacedKey("dunerealms","starter_instance"),PersistentDataType.STRING)))return null;
String slot=data.get(new NamespacedKey("dunerealms","starter_slot"),PersistentDataType.STRING);return Set.of("helmet","chestplate","leggings","boots").contains(slot==null?"":slot)&&item.getType().name().endsWith("_"+slot.toUpperCase(Locale.ROOT))?slot:null;
}
static String starterPart(ItemStack item){return item==null||item.isEmpty()||!item.hasItemMeta()?null:item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey("dunerealms","starter_part"),PersistentDataType.STRING);}
StarterReceipt starter(Player p,JsonObject permission,List<ItemStack> kit,List<ItemStack> parts)throws Exception{
UUID request=UUID.fromString(permission.get("requestId").getAsString());permit(p,permission,"prepare_starter",request);
String operation=permission.get("operation").getAsString(),kind="starter-"+operation,instance=permission.get("instanceId").getAsString(),fingerprint=permission.get("instructionHash").getAsString();
if(!Set.of("obtain","parts","repair").contains(operation)||!fingerprint.matches("[a-f0-9]{64}")||kit.size()!=5||parts.size()!=4)throw new IllegalArgumentException("Invalid starter instruction");
return atomic(p,c->{
if(previous(c,request,p.getUniqueId(),kind,fingerprint)!=null)return starterReceipt(c,request);
if(operation.equals("obtain")){for(var item:kit){stamp.accept(item);give(p,item,1);}}
else if(operation.equals("parts")){
var storage=p.getInventory().getStorageContents();for(var part:parts){boolean consumed=false;for(int i=0;i<storage.length;i++){var item=storage[i];if(item==null||item.isEmpty()||item.getType()!=part.getType()||starterPart(item)!=null)continue;var data=item.getItemMeta().getPersistentDataContainer();if(data.has(new NamespacedKey("executableitems","ei-id"))||data.has(new NamespacedKey("dunerealms","starter_instance")))continue;var remaining=item.clone();remaining.setAmount(item.getAmount()-1);storage[i]=remaining.isEmpty()?null:remaining;consumed=true;break;}if(!consumed)throw new IllegalArgumentException("Bring one iron ingot, leather, copper ingot and quartz to prepare the four repair parts.");}
p.getInventory().setStorageContents(storage);for(var part:parts){stamp.accept(part);give(p,part,1);}
}else{
var contents=p.getInventory().getContents();for(String slot:List.of("helmet","chestplate","leggings","boots")){boolean consumed=false;for(int i=0;i<contents.length;i++){var item=contents[i];if(slot.equals(starterSlot(item,instance))){contents[i]=null;consumed=true;break;}}if(!consumed)throw new IllegalArgumentException("Bring all four original bound starter armour pieces. Replacement or preview armour cannot be surrendered.");}
for(var part:parts){String wanted=starterPart(part);boolean consumed=false;for(int i=0;i<contents.length;i++){var item=contents[i];if(wanted.equals(starterPart(item))&&item.getType()==part.getType()){var remaining=item.clone();remaining.setAmount(item.getAmount()-1);contents[i]=remaining.isEmpty()?null:remaining;consumed=true;break;}}if(!consumed)throw new IllegalArgumentException("Bring all four prepared repair parts.");}
p.getInventory().setContents(contents);
}
record(c,request,p.getUniqueId(),kind,fingerprint,SERVERS.indexOf(server));return starterReceipt(c,request);
});
}
private static void record(Connection c,UUID id,UUID actor,String kind,String fingerprint,long listing)throws SQLException{
try(var q=prepare(c,"INSERT INTO dune_exchange_inventory_ops(id,actor_uuid,kind,fingerprint,listing_id,created_at) VALUES(?,?,?,?,?,?)")){q.setString(1,id.toString());q.setString(2,actor.toString());q.setString(3,kind);q.setString(4,fingerprint);q.setLong(5,listing);q.setLong(6,System.currentTimeMillis());q.executeUpdate();}
}

View file

@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
import java.io.File;
import java.util.Objects;
import java.util.UUID;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@ -21,6 +22,9 @@ public final class JarvisTranslator extends JavaPlugin implements Listener {
private ExchangeInventory exchangeInventory;
private QuestObservations questObservations;
private SpiceRefiner spiceRefiner;
private StarterKitFlow starterKit;
public UUID starterNpc(org.bukkit.entity.Player player){return starterKit.nearby(player);}
public void starterKit(org.bukkit.entity.Player player,JsonObject permit)throws Exception{starterKit.execute(player,permit);}
public UUID refinerNpc(org.bukkit.entity.Player player){return spiceRefiner.nearby(player);}
public void refineSpice(org.bukkit.entity.Player player,JsonObject permit)throws Exception{spiceRefiner.execute(player,permit);}
private ItemMetadataOverlay itemMetadata;
@ -61,6 +65,7 @@ public final class JarvisTranslator extends JavaPlugin implements Listener {
questObservations=new QuestObservations(this,api,serverKey);
new FlightObservations(this,questObservations,serverKey);
spiceRefiner=new SpiceRefiner(this,exchangeInventory,questObservations,serverKey);
starterKit=new StarterKitFlow(this,exchangeInventory,itemPreview,questObservations,serverKey);
transport=new OrganisationTransport(this,api,serverKey);
guildTransport=new GuildTransport(this,api,serverKey);
actions = new NativeActions(work -> Bukkit.getScheduler().runTaskAsynchronously(this, work),
@ -84,7 +89,7 @@ public final class JarvisTranslator extends JavaPlugin implements Listener {
}
public JsonObject requestQuests(UUID player,JsonObject input)throws Exception {
if(!isEnabled()||player==null||input==null||input.has("uuid"))throw new IllegalStateException("Invalid quest request");
var request=input.deepCopy();request.addProperty("uuid",player.toString());if("prepare_refine".equals(request.get("action").getAsString()))request.addProperty("server",serverKey);return api.quests(request);
var request=input.deepCopy();request.addProperty("uuid",player.toString());if(Set.of("prepare_refine","prepare_starter").contains(request.get("action").getAsString()))request.addProperty("server",serverKey);return api.quests(request);
}
public JsonObject requestItemPreview(UUID player,UUID id,int revision)throws Exception {
if(!isEnabled()||player==null||id==null||revision<1||revision>999999)throw new IllegalArgumentException("Choose a saved item revision");

View file

@ -34,6 +34,7 @@ final class QuestObservations implements Listener,AutoCloseable {
if(!captured.offer(event))warning();
}
void introduce(Player player){if(!Bukkit.isPrimaryThread()||!player.isOnline()||closing)throw new IllegalStateException("Player unavailable");if(!captured.offer(observation(player,"citizen_introduction",UUID.randomUUID())))throw new IllegalStateException("Quest receipt queue is full");}
void starter(Player player,String kind,UUID id,String origin,long occurredAt){if(!Bukkit.isPrimaryThread()||closing||!Set.of("starter_acquired","starter_repaired").contains(kind))throw new IllegalStateException("Invalid starter receipt");var event=observation(player,kind,id);event.addProperty("server",origin);event.addProperty("occurredAt",occurredAt);if(!captured.offer(event))throw new IllegalStateException("Quest receipt queue is full");}
void flight(Player player,String kind,int quantity,UUID eventId,String source){
flightAt(player,kind,quantity,eventId,source,System.currentTimeMillis());
}

View file

@ -0,0 +1,35 @@
package com.dunerealms.jarvis;
import com.google.gson.JsonObject;
import java.util.*;
import org.bukkit.*;import org.bukkit.entity.*;import org.bukkit.event.*;import org.bukkit.event.player.PlayerJoinEvent;import org.bukkit.inventory.*;import org.bukkit.inventory.meta.Damageable;import org.bukkit.persistence.PersistentDataType;import org.bukkit.plugin.Plugin;
import net.kyori.adventure.text.Component;import net.kyori.adventure.text.format.NamedTextColor;
/** Fixed NPC equipment exchanges; Core's shared profile transaction owns inventory changes. */
final class StarterKitFlow implements Listener{
private final Plugin plugin;private final ExchangeInventory inventory;private final ItemDesignPreview builder;private final QuestObservations observations;private final String server;
private static final NamespacedKey NPC=new NamespacedKey("dunerealms","quartermaster");
StarterKitFlow(Plugin plugin,ExchangeInventory inventory,ItemDesignPreview builder,QuestObservations observations,String server){this.plugin=plugin;this.inventory=inventory;this.builder=builder;this.observations=observations;this.server=server;Bukkit.getPluginManager().registerEvents(this,plugin);}
UUID nearby(Player p){
if(!Bukkit.isPrimaryThread()||!p.isOnline()||p.isDead()||p.getGameMode()!=GameMode.SURVIVAL&&p.getGameMode()!=GameMode.ADVENTURE)throw new IllegalArgumentException("Visit the quest quartermaster in Survival or Adventure mode.");
return p.getNearbyEntities(5,3,5).stream().filter(e->e instanceof Villager&&e.getPersistentDataContainer().has(NPC,PersistentDataType.BYTE)).min(Comparator.comparingDouble(e->e.getLocation().distanceSquared(p.getLocation()))).map(Entity::getUniqueId).orElseThrow(()->new IllegalArgumentException("Stand near Gurney's quartermaster and reopen this quest."));
}
private static final Map<String,Material> PARTS=Map.of("starter-repair-plate-v1",Material.IRON_INGOT,"starter-binding-patch-v1",Material.LEATHER,"starter-tool-fitting-v1",Material.COPPER_INGOT,"starter-calibration-piece-v1",Material.QUARTZ);
private ItemStack part(JsonObject definition){
String id=definition.get("id").getAsString();Material material=PARTS.get(id);if(material==null||!definition.get("material").getAsString().equals("minecraft:"+material.name().toLowerCase(Locale.ROOT)))throw new IllegalArgumentException("The repair component definition changed.");
var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(definition.get("name").getAsString(),NamedTextColor.GREEN));meta.lore(List.of(Component.text(definition.get("purpose").getAsString(),NamedTextColor.GRAY)));var data=meta.getPersistentDataContainer();data.set(new NamespacedKey("dunerealms","starter_part"),PersistentDataType.STRING,id);data.set(new NamespacedKey("dunerealms","item"),PersistentDataType.STRING,id);data.set(ItemMetadataOverlay.QUALITY,PersistentDataType.STRING,"uncommon");data.set(ItemMetadataOverlay.MARK,PersistentDataType.STRING,"1");data.set(ItemMetadataOverlay.CLASS,PersistentDataType.STRING,"resource");data.set(ItemMetadataOverlay.POLICY,PersistentDataType.STRING,ItemMetadataPolicy.VERSION);item.setItemMeta(meta);return item;
}
void execute(Player p,JsonObject permit)throws Exception{
UUID npc=nearby(p);if(!server.equals(permit.get("server").getAsString())||!npc.toString().equals(permit.get("npcUuid").getAsString()))throw new IllegalArgumentException("Return to the same quartermaster to confirm this action.");
String operation=permit.get("operation").getAsString(),instance=UUID.fromString(permit.get("instanceId").getAsString()).toString();var kit=new ArrayList<ItemStack>();var parts=new ArrayList<ItemStack>();
for(var value:permit.getAsJsonArray("items")){var row=value.getAsJsonObject();if(row.get("quantity").getAsInt()!=1)throw new IllegalArgumentException("Invalid starter quantity");var item=builder.issue(row,true);var meta=item.getItemMeta();
if(operation.equals("obtain")){meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","starter_instance"),PersistentDataType.STRING,instance);String material=item.getType().name().toLowerCase(Locale.ROOT);for(String slot:List.of("helmet","chestplate","leggings","boots"))if(material.endsWith("_"+slot))meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","starter_slot"),PersistentDataType.STRING,slot);if(meta instanceof Damageable damage)damage.setDamage(Math.round(item.getType().getMaxDurability()*0.5f));}
item.setItemMeta(meta);kit.add(item);
}
for(var value:permit.getAsJsonArray("parts"))parts.add(part(value.getAsJsonObject()));
var receipt=inventory.starter(p,permit,kit,parts);if(!receipt.kind().equals("starter-parts"))emit(p,receipt);
p.sendMessage(operation.equals("obtain")?"Your half-durability House T0 stillsuit and wooden spice shovel are ready.":operation.equals("parts")?"Four repair parts prepared. Return with your original starter armour.":"Original armour and four repair parts surrendered. Claim Repair Your Starter Kit in this quest menu to receive its intact replacement.");
}
private void emit(Player p,ExchangeInventory.StarterReceipt receipt){observations.starter(p,receipt.kind().equals("starter-obtain")?"starter_acquired":"starter_repaired",receipt.id(),receipt.server(),receipt.occurredAt());}
void recover(Player p){try{for(var receipt:inventory.starterReceipts(p))emit(p,receipt);}catch(Exception failure){plugin.getLogger().warning("Starter inventory receipts remain available for retry.");}}
@EventHandler public void join(PlayerJoinEvent e){Bukkit.getScheduler().runTaskLater(plugin,()->{if(e.getPlayer().isOnline())recover(e.getPlayer());},100);}
}

View file

@ -817,6 +817,13 @@
"itemClass": "weapon",
"material": "mace"
},
"dr_s1_elytra_crafted_v2": {
"policy": "s1-item-metadata-v1",
"quality": "very_rare",
"equipmentMark": 11,
"itemClass": "flight-equipment",
"material": "elytra"
},
"dr_s1_spice_rocket_mk1": {
"policy": "s1-item-metadata-v1",
"quality": "uncommon",
@ -1384,12 +1391,33 @@
"itemClass": "resource",
"material": "bone"
},
"dr_s1_elytra_crafted_v2": {
"starter-repair-plate-v1": {
"policy": "s1-item-metadata-v1",
"quality": "very_rare",
"equipmentMark": 11,
"itemClass": "flight-equipment",
"material": "elytra"
"quality": "uncommon",
"equipmentMark": 1,
"itemClass": "resource",
"material": "iron_ingot"
},
"starter-binding-patch-v1": {
"policy": "s1-item-metadata-v1",
"quality": "uncommon",
"equipmentMark": 1,
"itemClass": "resource",
"material": "leather"
},
"starter-tool-fitting-v1": {
"policy": "s1-item-metadata-v1",
"quality": "uncommon",
"equipmentMark": 1,
"itemClass": "resource",
"material": "copper_ingot"
},
"starter-calibration-piece-v1": {
"policy": "s1-item-metadata-v1",
"quality": "uncommon",
"equipmentMark": 1,
"itemClass": "resource",
"material": "quartz"
}
},
"materialGrades": {

View file

@ -1,6 +1,6 @@
name: JarvisTranslator
main: com.dunerealms.jarvis.JarvisTranslator
version: 0.5.22
version: 0.5.23
api-version: '1.21.8'
description: Shared J.A.R.V.I.S. website API and native server action translator.
softdepend: [SCore, ExecutableItems, ExecutableCrafting, DuneEss, ImageFrame, DecentHolograms, MedievalFactions, Towny, WorldGuard]

View file

@ -30,8 +30,8 @@ export const QUEST_GUIDANCE=Object.freeze({
'civic-ballot-equivalent':live('Cast an eligible election vote. Simply opening the election page or registering as a voter does not count.','Politics → Elections','Attributed election ballot with allocated votes'),
'civic-additional':live('Cast an additional eligible election ballot after your first. Each distinct ballot counts once.','Politics → Elections','Additional distinct attributed election ballots'),
'public-event-equivalent':pending('Complete a registered public event or its configured alternative objective. Attendance must be confirmed by that event.','Events → Current assignments'),
'faction-kit':pending('Obtain your House T0 starter kit ingame. The connector must confirm the actual kit instance; viewing a blueprint or claiming XP alone does not create equipment.','Ingame quest / kit NPC'),
'starter-kit-repair':pending('Bring your original damaged T0 starter kit and one of each: Repair plate, Binding patch, Tool fitting and Calibration piece. Hand them in through the ingame quest menu; the original kit and all four parts must be surrendered.','Ingame quest NPC → Repair Your Starter Kit'),
'faction-kit':live('Visit Gurney Halleck at your world spawn. Open Missions & turn-ins, then Equipment & Upgrades → Obtain faction kit → Collect House T0 kit. Receive four Common MK 0 stillsuit pieces and an Uncommon MK I wooden spice shovel at half durability. Refresh and claim this quest after the inventory receipt is confirmed.','World spawn → Gurney → Missions & turn-ins','Once-per-season bound physical kit delivery'),
'starter-kit-repair':live('Bring one iron ingot, leather, copper ingot and quartz to Gurney. Select Prepare four repair parts to make a Repair plate, Binding patch, Tool fitting and Calibration piece. Then surrender all four original starter armour pieces, including equipped pieces, and the four prepared components. Refresh and claim this quest for one intact replacement through the central inventory connector.','World spawn → Gurney → Missions & turn-ins → Repair Your Starter Kit','Actual original-kit and four-part surrender, followed by a once-only inventory delivery receipt'),
'equipment-use':live('Use equipment in Survival or Adventure mode until it consumes durability. Merely equipping, buying or previewing an item does not count.','Any planet → Use a durable tool, weapon or armour','Actual equipment durability consumed'),
'mark-upgrade':pending('Complete a permitted MK upgrade through your organisation specialist. The original item and required upgrade components must be handed in.','Clan / Company / POL specialist → R&D'),
'rarity-enhancement':pending('Complete a permitted rarity upgrade through your organisation specialist. An editor preview is not an upgrade.','Clan / Company / POL specialist → R&D'),

View file

@ -2,7 +2,17 @@ import {equipmentTemplate} from './equipment-template-policy.mjs';
import {TOOL_TEMPLATES,CRAFTED_ELYTRA_TEMPLATE,elytraTemplate,ROCKET_TEMPLATES} from './tool-template-policy.mjs';
import {EVERYDAY_ITEMS} from './mining-tool-policy.mjs';
import {REFIT_UPGRADE_ITEMS} from './organisation-refit-policy.mjs';
import {STARTER_REPAIR_PARTS} from './starter-kit-policy.mjs';
export const ITEM_METADATA_POLICY='s1-item-metadata-v1';
// Existing Arrakis item definitions must survive every catalogue regeneration.
export const ECOLOGY_ITEM_TEMPLATES=Object.freeze([
{id:'jerboa_raw_meat',quality:'uncommon',equipmentMark:3,itemClass:'consumable',material:'rabbit'},
{id:'jerboa_cooked_meat',quality:'rare',equipmentMark:6,itemClass:'consumable',material:'cooked_rabbit'},
{id:'jerboa_stew',quality:'very_rare',equipmentMark:9,itemClass:'consumable',material:'rabbit_stew'},
{id:'jerboa_hide',quality:'common',equipmentMark:1,itemClass:'resource',material:'rabbit_hide'},
{id:'jerboa_water_vial',quality:'rare',equipmentMark:6,itemClass:'consumable',material:'potion'},
{id:'worm_memorial_bone',quality:'legendary',equipmentMark:14,itemClass:'resource',material:'bone'}
]);
// Native item rarity is a baseline, not an enchantment multiplier or an issuance grant.
export const NATIVE_ITEM_GRADES=Object.freeze({
COMMON:Object.freeze({quality:'common',equipmentMark:1}),
@ -1720,5 +1730,6 @@ export function itemTemplateCatalogue(){
for(const slot of Object.keys(equipmentTemplate({quality,mark}).enchantments))rows.push({id:`dr_s1_${quality}_mk${mark}_${slot}`,material:'netherite_'+slot,quality,equipmentMark:mark,itemClass:'equipment'});
}
for(const slot of ['helmet','chestplate','leggings','boots'])rows.push({id:`dr_s1_mythic_mk14_${slot}`,material:'netherite_'+slot,quality:'mythic',equipmentMark:14,itemClass:'equipment'});
return {policy:ITEM_METADATA_POLICY,nativeRarity:NATIVE_ITEM_GRADES,materialGrades:MATERIAL_ITEM_GRADES,templates:Object.fromEntries(rows.map(t=>[t.id,{...itemMetadata(t),material:t.material}]))};
rows.push(...ECOLOGY_ITEM_TEMPLATES,...STARTER_REPAIR_PARTS.map(t=>({id:t.id,material:t.material.replace('minecraft:',''),quality:'uncommon',equipmentMark:1,itemClass:'resource'})));
return {policy:ITEM_METADATA_POLICY,nativeRarity:NATIVE_ITEM_GRADES,templates:Object.fromEntries(rows.map(t=>[t.id,{...itemMetadata(t),material:t.material}])),materialGrades:MATERIAL_ITEM_GRADES};
}

View file

@ -53,7 +53,7 @@ export const MASTER_KEY_TEMPLATES=[
action('accounts.test-minecraft-identity','Assign a synthetic test Minecraft UUID','account-test-identity',[field('accountName','Target account name'),reference],{webIssue:true,permission:'web.jarvis.accounts.test-identity',effect:'Generate and assign one synthetic test UUID to the named unlinked account. Never overwrites a game link or pending link challenge. This is not proof of Minecraft ownership.'})]},
{id:'items',label:'Items & kits',actions:[
action('equipment.starter-policy','Q0 starter and four-part repair policy','progression-policy',[field('season','Season'),field('policyVersion','Policy version','number',{min:2})],{webIssue:false,recordOnly:true,domainAdapter:'ensureStarterKitRewardPolicy',executionStatus:'recorded-system-policy',effect:'Describe half-durability Q0 faction kits and four repair parts. Configure one intact replacement through the existing quest reward outbox; no item or DM is issued by installing the policy.'}),
action('equipment.starter-event','Verified Q0 acquisition or repair','quest-milestone',[field('eventId','Verified game event'),field('kind','Acquired or repaired'),field('uuid','Linked Minecraft UUID'),field('kitInstanceId','Original Q0 kit instance')],{webIssue:false,recordOnly:true,domainAdapter:'starterKitEvents.record',executionStatus:'trusted-equipment-producer-only',effect:'Record actual faction-kit acquisition or surrender plus all four consumed repair parts. Source keys bind the original kit and season. Minecraft producer is future work; the browser cannot assert inventory events.'})]},
action('equipment.starter-event','Verified Q0 acquisition or repair','quest-milestone',[field('eventId','Verified game event'),field('kind','Acquired or repaired'),field('uuid','Linked Minecraft UUID'),field('kitInstanceId','Original Q0 kit instance')],{webIssue:false,recordOnly:true,version:2,domainAdapter:'createGameStarterKit.record',executionStatus:'trusted-equipment-producer-only',effect:'Record actual faction-kit acquisition or surrender plus all four consumed repair parts. Source keys bind the original kit and season. The native quartermaster grants one bound half-durability House starter kit, exchanges four base materials for repair parts, and surrenders the original armour plus parts through the shared Core inventory transaction. Durable receipts feed the existing quest evidence service; the current central kit delivery grants one intact replacement only after a real repair claim. The browser cannot assert inventory events.'})]},
{id:'items',label:'Items & blueprints',actions:[action('items.kitset-purchase','Published organisation kit purchase','kit-definition',[field('kitsetId','Published kit UUID'),field('requestId','Purchase UUID'),field('priceMinor','Confirmed price in minor units','number',{min:1})],{webIssue:false,recordOnly:true,domainAdapter:'kitsetCommerce.buy/pending/NativeKitGrant',executionStatus:'bank-atomic-native-inventory',effect:'The current linked buyer pays an active organisation account through the central double-entry bank. Payment and the delivery obligation commit in one MySQL transaction against the immutable published source. Whole-kit delivery uses the durable shared-inventory receipt; already paid sources remain owed after catalogue edits or revocation. No player permissions, second wallet or manual redemption code.'}),action('items.kitset-grant','Complimentary published stillsuit kit','kit-definition',[field('kitsetId','Published kit UUID'),field('requestId','Delivery request UUID'),field('recipientUuid','Linked recipient UUID')],{webIssue:false,recordOnly:true,domainAdapter:'issueKitsetGrant/pendingKitsetGrants/NativeKitGrant',executionStatus:'console-native-inventory',effect:'Current item-management authority records an owed gift in the existing key-event journal, bound to an immutable published kit and linked recipient. Connection or clearing inventory obtains fresh short-lived delivery proof. Native delivery checkpoints the entire kit and recipient receipt atomically. No bank charge, arbitrary native commands or end-user issuance.'}),action('items.kitset','Saved kitset definition','kit-definition',[field('kitsetId','Saved kitset'),field('revision','Saved revision','number',{min:1})],{webIssue:false,recordOnly:true,domainAdapter:'kitsets.generate',executionStatus:'authorised-kitset-definition',effect:'Freeze one saved kitset revision into a single definition key. Draft changes create no item keys. This record does not publish or deliver inventory.'}),action('items.definition','Versioned item definition','item-definition',[field('designId','Item design'),field('revision','Design revision','number',{min:1})],{webIssue:false,recordOnly:true,domainAdapter:'itemDesigns.save',executionStatus:'authorised-item-editor-draft',effect:'Save a complete MK and quality-bound item design with immutable versions. Reuse the same item contract for kit pieces and native generation. This record alone cannot publish a native definition, issue inventory or unlock a rarity.'})]},
{id:'events',label:'Events',actions:[]},
{id:'game-exchange',label:'Ingame Exchange',actions:[action('exchange.native-sale','Publish held item','organisation-action',[field('uuid','Linked player UUID'),field('requestId','Inventory instruction UUID'),field('amount','Quantity','number',{min:1}),field('priceMinor','Unit price in minor units','number',{min:1})],{webIssue:false,recordOnly:true,domainAdapter:'createGameExchangeAPI + ExchangeInventory.publish',executionStatus:'authenticated-game-service',effect:'Resolve the current personal bank account centrally, then checkpoint the exact held item and native listing in one shared inventory transaction.'}),action('exchange.native-buy','Buy listed goods','organisation-action',[field('uuid','Linked player UUID'),field('requestId','Purchase UUID'),field('listingId','Native listing'),field('amount','Quantity','number',{min:1}),field('priceMinor','Confirmed unit price','number',{min:1})],{webIssue:false,recordOnly:true,domainAdapter:'createGameExchangeService.buy',executionStatus:'authenticated-game-service',effect:'Revalidate stock, price and debit authority. Commit balanced central bank entries, consumed stock and exact paid item delivery together. Native delivery remains queued when offline or full.'}),action('exchange.native-withdraw','Withdraw unsold goods','organisation-action',[field('uuid','Linked player UUID'),field('requestId','Inventory instruction UUID'),field('listingId','Own listing')],{webIssue:false,recordOnly:true,domainAdapter:'createGameExchangeAPI + ExchangeInventory.cancel',executionStatus:'authenticated-game-service',effect:'Return unsold stock only to its seller and only when the full quantity fits; commit native stock removal and player inventory checkpoint together.'})]},

View file

@ -4,6 +4,7 @@ import {createGameExchangeAPI} from '../node/game-exchange.mjs';
import {createGameKitGrantsAPI} from '../node/game-kit-grants.mjs';
import {createGameGuildAPI} from '../node/game-guild.mjs';
import {createGameHomeAPI} from '../node/game-home.mjs';
import {createGameStarterKit} from '../node/game-starter-kit.mjs';
import {createClanWorkspace} from '../node/clan-workspace.mjs';
import {createGameQuestsAPI} from '../node/game-quests.mjs';
import {createGameQuestEventsAPI} from '../node/game-quest-events.mjs';
@ -248,8 +249,9 @@ export function createPanel(db,settings={},dependencies={}){
const progression=createProgressionAPI(db,{...progressionRuntime,origin});
const polRuntime=dependencies.polProgressionRuntime||(dependencies.organisationKeys?createPOLProgressionRuntime(db,dependencies.organisationKeys):null);
const gameHouseSelection=createHouseSelectionAPI(db,dependencies.organisationKeys,settings,{readBriefing:createGameBriefing({personal:progressionRuntime,pol:polRuntime,bank:dependencies.bankDatabase||null,authority:createPostbankAuthority(db,{bank:dependencies.bankDatabase||null}),organisations:actor=>readGameMemberships(db,actor),identity:actor=>readGamePublicIdentity(db,actor)})});
const gameQuests=createGameQuestsAPI(db,settings,{personal:progressionRuntime,pol:polRuntime});
const gameQuestEvents=createGameQuestEventsAPI(db,dependencies.organisationKeys,settings);
const gameStarter=dependencies.organisationKeys?createGameStarterKit(db,dependencies.organisationKeys,settings):null;
const gameQuests=createGameQuestsAPI(db,settings,{personal:progressionRuntime,pol:polRuntime,starter:gameStarter});
const gameQuestEvents=createGameQuestEventsAPI(db,dependencies.organisationKeys,settings,{starter:gameStarter});
const gameItemDesigns=createGameItemDesignAPI(db,dependencies.organisationKeys,settings);
const gameNativeState=createGameNativeStateAPI(db,settings);
const gameOrganisations=createGameOrganisationsAPI(db,dependencies.organisationKeys,settings,{bank:dependencies.bankDatabase||null});
@ -281,7 +283,7 @@ export function createPanel(db,settings={},dependencies={}){
const kitsetCommerce=dependencies.kitsetCommerce||(dependencies.bankDatabase&&settings.DB_NAME&&settings.DUNE_INVENTORY_DATABASE_URL?createKitsetCommerce(db,dependencies.bankDatabase,settings,{gamePool:pool}):null);
const kitsetPurchase=createKitsetPurchaseAPI(db,kitsetCommerce,settings);
const gameExchange=createGameExchangeAPI(db,dependencies.bankDatabase||null,pool,settings,{kitsetCommerce});
const gameKitGrants=createGameKitGrantsAPI(db,settings,{pool,commerce:kitsetCommerce});
const gameKitGrants=createGameKitGrantsAPI(db,settings,{pool,commerce:kitsetCommerce,starter:gameStarter});
let clans,companyRecruitment;const jarvis=createJarvisServices(db,dependencies.bankDatabase||null,settings,{...dependencies.jarvis,organisationKeys:dependencies.organisationKeys,deedPurchases:dependencies.deedPurchases,promotionChannels:dependencies.promotionDelivery?.channels||[],invokeClans:request=>clans(request),invokeCompany:request=>companyRecruitment(request)});companyRecruitment=createCompanyRecruitment(db,{origin,requestIntegration:jarvis.companyRequests});clans=createClans(db,{origin,onClanCreated:async({id})=>{await dependencies.boardRuntime?.boards.refresh('clan',id).catch(()=>console.error('Clan board key remains pending reconciliation'));await syncClanMailRegistry(db);},onClanDeleted:()=>syncClanMailRegistry(db),requestIntegration:jarvis.requests});const gameTickets=createGameTickets(db,settings);
const companyMailboxSettings=createCompanyMailboxSettings(db,{origin});
const clanEmblems=createClanEmblems(db,{origin}),companyEmblems=createCompanyEmblems(db,{origin});

View file

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"sourceHash": "405e1945e8be3ad0fc745e9b5b80cd2e9c7197e15e8d0f7e00e9f30c99a4ad43",
"sourceHash": "a1475186bffa0eaea05b736599ba7b7e982b751445ca1850a87d0e60cf29fc9f",
"actions": [
{
"id": "clan.clear-protected-rosters",
@ -1864,7 +1864,7 @@
{
"id": "equipment.starter-event",
"label": "Items & kits · Verified Q0 acquisition or repair",
"version": 1,
"version": 2,
"keyType": "quest-milestone",
"fields": [
{
@ -1899,7 +1899,7 @@
"required": true
}
],
"effect": "Record actual faction-kit acquisition or surrender plus all four consumed repair parts. Source keys bind the original kit and season. Minecraft producer is future work; the browser cannot assert inventory events.",
"effect": "Record actual faction-kit acquisition or surrender plus all four consumed repair parts. Source keys bind the original kit and season. The native quartermaster grants one bound half-durability House starter kit, exchanges four base materials for repair parts, and surrenders the original armour plus parts through the shared Core inventory transaction. Durable receipts feed the existing quest evidence service; the current central kit delivery grants one intact replacement only after a real repair claim. The browser cannot assert inventory events.",
"fixedTargets": [],
"webIssue": false,
"recordOnly": true

View file

@ -8,11 +8,12 @@ export function createGameKitGrantsAPI(db,settings,dependencies={}){return async
try{let bytes=0;const parts=[];while(true){const {value,done}=await reader.read();if(done)break;bytes+=value.length;if(bytes>1024){await reader.cancel();return json({message:'Request too large'},413);}parts.push(value);}raw=Buffer.concat(parts).toString('utf8');}finally{reader.releaseLock();}
const input=JSON.parse(raw);if(!input||Object.keys(input).length!==2||!validUuid(input.uuid)||typeof input.serverKey!=='string'||!/^[-a-z0-9_]{1,48}$/.test(input.serverKey))return json({message:'Current game identity required.'},400);
let grants=await (dependencies.pending||pendingKitsetGrants)(db,input.uuid,input.serverKey,settings);
if(dependencies.starter)grants.push(...await dependencies.starter.pendingRepairs(input.uuid,input.serverKey));
if(dependencies.commerce){const actors=await db.query("SELECT a.id FROM site_accounts a JOIN site_game_links l ON l.user_id=a.id WHERE LOWER(l.minecraft_uuid)=? AND a.password_hash NOT LIKE '!%' AND a.role NOT IN ('system_account','official_account','memorial')",[input.uuid]);if(actors.length!==1)throw Error('Current linked buyer required');grants.push(...await dependencies.commerce.pending(actors[0].id,input.uuid,input.serverKey));}
if(dependencies.pool&&grants.length){
const ids=grants.map(g=>JSON.parse(Buffer.from(g.payload,'base64')).recipients[0].receiptId),args=[input.uuid,...ids];
const completed=await dependencies.pool.query({text:"SELECT id FROM dune_exchange_inventory_ops WHERE actor_uuid=$1 AND kind='kit-grant' AND id IN ("+ids.map((_,i)=>'$'+(i+2)).join(',')+')',values:args,query_timeout:5000});
const done=new Set(completed.rows.map(r=>r.id));grants=grants.filter((_,i)=>!done.has(ids[i]));
const done=new Set(completed.rows.map(r=>r.id));if(dependencies.starter)await dependencies.starter.acknowledgeRepairs(input.uuid,input.serverKey,[...done]);grants=grants.filter((_,i)=>!done.has(ids[i]));
}
let bytes=0;grants=grants.filter(g=>{const size=Buffer.byteLength(JSON.stringify(g));if(bytes+size>750000)return false;bytes+=size;return true;}).slice(0,16);
return json({ok:true,schema:1,playerUuid:input.uuid,grants});

Some files were not shown because too many files have changed in this diff Show more