@ -33,6 +33,12 @@ final class OrganisationMenus implements Listener {
Bukkit.getScheduler().runTask(plugin,()->{busy.remove(p.getUniqueId());if(!p.isOnline())return;if(result==null){p.sendMessage("Your organisation keys are temporarily unavailable. Please reopen the menu.");return;}if(kind==null)start(p,result);elsechoose(p,result,kind);});
Bukkit.getScheduler().runTask(plugin,()->{busy.remove(p.getUniqueId());if(!p.isOnline()||!world.equals(p.getWorld().getUID()))return;if(result!=null&&result.has(kind))for(varitem:result.getAsJsonArray(kind)){varrow=item.getAsJsonObject();if(row.has("id")&&id.equals(row.get("id").getAsString())){organisation(p,result,kind,row);return;}}p.sendMessage("This organisation contact is available to current authorised members.");});
privatestaticStringprogress(JsonObjectdata){if(data==null||string(data,"quest")==null)return"—";if(data.has("questReady")&&data.get("questReady").getAsBoolean())return"Ready to claim";Stringp=string(data,"questProgress"),t=string(data,"questTarget");returnp==null||t==null?"—":p+" / "+t;}
privatevoidsave(Rolerole,LivingEntitynpc){Locationl=npc.getLocation();Stringb=base(role);positions.set(b+".entity",npc.getUniqueId().toString());positions.set(b+".x",l.getX());positions.set(b+".y",l.getY());positions.set(b+".z",l.getZ());positions.set(b+".yaw",l.getYaw());positions.set(b+".pitch",l.getPitch());try{positions.save(file);}catch(java.io.IOExceptionfailure){plugin.getLogger().warning("Quest NPC position could not be saved: "+role.key());}}
@SuppressWarnings("unchecked")privateLivingEntityspawn(Rolerole,Locationat){try{Class<?extendsLivingEntity>type=(Class<?extendsLivingEntity>)Class.forName("org.bukkit.entity.Mannequin");Objectappearance=skin(role.key());LivingEntitynpc=at.getWorld().spawn(at,type,e->configure(role,e));try{profile(npc,appearance);returnnpc;}catch(ReflectiveOperationExceptionfailure){npc.remove();throwfailure;}}catch(ReflectiveOperationException|LinkageError|IllegalArgumentExceptionunavailable){plugin.getLogger().warning("Character appearance is unavailable for "+role.key()+"; using neutral stationary fallback.");returnat.getWorld().spawn(at,Villager.class,v->{v.setProfession(Villager.Profession.LIBRARIAN);configure(role,v);});}}
booleanmove(Playerplayer,Stringkey){if(!player.hasPermission("dune.admin")){player.sendMessage("Current NPC administration permission required.");returnfalse;}Rolerole=role(key,player.getWorld());if(role==null){player.sendMessage("Choose a quest character assigned to this world.");returnfalse;}Locationat=player.getLocation();if(!usable(at)){player.sendMessage("Choose a clear standing space for the NPC.");returnfalse;}Locationold=saved(role,player.getWorld());if(old!=null)old.getChunk().load();LivingEntitynpc=existing(role,player.getWorld());if(npc==null){player.sendMessage("The original quest NPC is unavailable; no duplicate was created.");returnfalse;}if(!npc.teleport(at))returnfalse;save(role,npc);player.sendMessage("Moved "+role.name()+"; its original identity was retained.");returntrue;}
finalUUIDowner;finalGuiSessiongate;finalMap<Integer,Runnable>actions=newHashMap<>();finalList<BedrockForms.Choice>choices=newArrayList<>();finalInventoryinventory;finalStringtitle;Stringdescription="Your current J.A.R.V.I.S. mission journal";
varscreen=panel(p,"NPC dashboard · "+role.name());screen.description="Choose the exact mission you wish to discuss.";roleAvatar(screen,data,role);varordered=newArrayList<JsonObject>(available);ordered.sort(Comparator.comparingInt(q->Set.of("active","completed").contains(text(q,"state",""))?0:1));
intslot=9;for(varq:ordered){if(slot>=45)break;Stringstatus=Set.of("active","completed").contains(text(q,"state",""))?"Progress: "+text(q,"progress","0")+" / "+text(q,"target","1"):"Eligible to accept";put(screen,slot++,text(q,"title","Mission"),status+"\n"+text(q,"objective",""),Material.WRITABLE_BOOK,()->roleSelected(p,data,role,q));}
if(ordered.isEmpty())put(screen,13,"No eligible missions","Read the website journal for the full record.",Material.MAP,null);
if(Set.of("thufir_hawat","piter_de_vries","hasimir_fenring","roma_atani","imperial_attendant","jessica_atreides","gaius_helen_mohiam","alia_atreides","edric","guild_navigator","duncan_idaho").contains(role.key()))put(screen,48,"POL decisions","See only current executable political decisions",Material.BOOK,()->roleDecisionDashboard(p,data,role));put(screen,49,"Website journal","Full mission choices and history",Material.MAP,()->website(p));show(p,screen);
}
privatevoidroleDecisionDashboard(Playerp,JsonObjectcontact,PolQuestNpc.Rolerole){varinput=newJsonObject();input.addProperty("action","read");input.addProperty("npcRole",role.key());decisionRequest(p,role,input,data->{varscreen=panel(p,"NPC dashboard · "+role.name());screen.description="Choose a decision you currently have the authority to execute.";roleAvatar(screen,contact,role);intslot=9;for(vare:data.getAsJsonArray("decisions")){varrow=e.getAsJsonObject();if(slot>=45)break;put(screen,slot++,text(row,"title","Decision"),"Required Reputation: "+text(row,"level","—")+"\n"+(text(row,"kind","").equals("website")?"Continue through the verified website workflow.":"Review funding and confirm."),Material.BOOK,()->roleDecisionDetails(p,contact,role,row,null,null));}if(slot==9)put(screen,13,"No executable decisions","Your current office, authority and cooldown determine what appears here.",Material.MAP,null);put(screen,48,"Back","Mission dashboard",Material.ARROW,()->load(p,"pol",null,null,0));put(screen,49,"Website","Full decision definitions and history",Material.MAP,()->decisionWebsite(p));show(p,screen);});}
privatevoiddecisionWebsite(Playerp){p.closeInventory();p.sendMessage(Component.text("Review POL decisions on the website →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl("https://clans.dunerealms.com/#quests/quests")));}
privatevoidroleDecisionDetails(Playerp,JsonObjectcontact,PolQuestNpc.Rolerole,JsonObjectrow,Stringaccount,Stringparameter){varscreen=panel(p,"NPC turn-in · "+role.name());screen.description="Review your explicit political decision before committing any funds.";roleAvatar(screen,contact,role);Stringkind=text(row,"kind","");Stringfee=text(row,"feeMinor","0");Stringamount;try{amount=newjava.math.BigDecimal(fee).movePointLeft(2).toPlainString()+" DM";}catch(NumberFormatExceptioninvalid){amount="—";}put(screen,13,text(row,"title","Decision"),"Required Reputation: "+text(row,"level","—")+"\nBase cost: "+amount+"\nAward: "+text(row,"reputation","—")+" Reputation",Material.BOOK,null);
if(kind.equals("website")){put(screen,31,"Open website workflow","This decision requires the existing website controls.",Material.MAP,()->decisionWebsite(p));}
elseif(account==null){intslot=18;for(vare:row.getAsJsonArray("accounts")){vara=e.getAsJsonObject();if(slot>=35)break;Stringid=text(a,"id","");try{if(newjava.math.BigInteger(text(a,"availableMinor","0")).compareTo(newjava.math.BigInteger(fee))<0)continue;}catch(NumberFormatExceptioninvalid){continue;}put(screen,slot++,text(a,"name","Funding account"),"Account "+text(a,"number","")+" · available "+newjava.math.BigDecimal(text(a,"availableMinor","0")).movePointLeft(2).toPlainString()+" DM",Material.GOLD_INGOT,()->roleDecisionDetails(p,contact,role,row,id,parameter));}}
elseif(row.has("parameters")&¶meter==null){intslot=18;for(varitem:row.getAsJsonArray("parameters")){varvalue=item.getAsJsonObject();if(slot>=35)break;put(screen,slot++,text(value,"label","Parameter"),"Select this exact parameter",Material.PAPER,()->roleDecisionDetails(p,contact,role,row,account,text(value,"value","")));}}
else{put(screen,22,"Confirmed selection","Funding account "+account+(parameter==null?"":"\nParameter: "+parameter),Material.GOLD_INGOT,null);UUIDrequestId=UUID.randomUUID();put(screen,31,"Confirm and execute","Commit the reviewed decision once through J.A.R.V.I.S.",Material.LIME_DYE,()->{varinput=newJsonObject();input.addProperty("action","execute");input.addProperty("npcRole",role.key());input.addProperty("decisionId",text(row,"id",""));input.addProperty("requestId",requestId.toString());input.addProperty("sourceAccount",account);input.addProperty("confirmed",true);if(parameter!=null)input.addProperty("parameter",parameter);decisionRequest(p,role,input,result->roleDecisionResult(p,contact,role,row,result));});}
privatevoidroleDecisionResult(Playerp,JsonObjectcontact,PolQuestNpc.Rolerole,JsonObjectrow,JsonObjectresult){varscreen=panel(p,"NPC next quest · "+role.name());screen.description="The decision has been recorded. Review the signed history for its full effect.";roleAvatar(screen,contact,role);put(screen,13,text(row,"title","Decision"),"Reference: "+text(result,"keyId","Recorded")+"\nReputation: "+text(result,"xp","—"),Material.LIME_DYE,null);put(screen,31,"Next decision","See the remaining current eligible decisions",Material.BOOK,()->roleDecisionDashboard(p,contact,role));put(screen,49,"Later","Return to the contact dashboard",Material.ARROW,()->load(p,"pol",null,null,0));show(p,screen);}
privatevoiddecisionRequest(Playerp,PolQuestNpc.Rolerole,JsonObjectinput,Consumer<JsonObject>callback){try{bridge.questCharacterNpc(p,role.key());request(p,input,callback,true);}catch(Exceptionunavailable){p.sendMessage("Return to this political quest contact.");}}
privatevoidroleIntro(Playerp,JsonObjectdata,PolQuestNpc.Rolerole,JsonObjectrow){varscreen=panel(p,"NPC next quest · "+role.name());screen.description="There is work still to be done. Will you accept this mission?";roleAvatar(screen,data,role);put(screen,13,text(row,"title","Next mission"),text(row,"objective","")+"\nReputation: "+text(row,"xp","—"),Material.WRITABLE_BOOK,null);put(screen,30,"Accept","Accept exactly this mission",Material.LIME_DYE,()->act(p,"pol",text(row,"branch",""),0,row,"start"));put(screen,32,"Later","Return to the contact's mission dashboard",Material.ARROW,()->roleJournal(p,data,role,null));show(p,screen);}
privatevoidroleThanks(Playerp,JsonObjectdata,PolQuestNpc.Rolerole,JsonObjectrow){varscreen=panel(p,"NPC turn-in · "+role.name());screen.description="Your work has been verified. Thank you.";roleAvatar(screen,data,role);put(screen,13,text(row,"title","Completed mission"),"Verified reward recorded through J.A.R.V.I.S.",Material.LIME_DYE,null);put(screen,31,"Next quest","Find the next eligible mission in this selected arc",Material.BOOK,()->roleNext(p,role,row));put(screen,49,"Later","Return to the mission dashboard",Material.ARROW,()->load(p,"pol",null,null,0));show(p,screen);}
privatevoidwebsite(Playerp){p.closeInventory();p.sendMessage(Component.text("Open your Mentat Report →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl("https://clans.dunerealms.com/#quests/quests")));}
privatevoidworkshop(Playerp,intpage){varinput=newJsonObject();input.addProperty("action","read_refits");input.addProperty("kind","pol");request(p,input,data->{varscreen=panel(p,"Organisation workshop");varowners=data.getAsJsonArray("owners");intoffset=page*36;for(inti=offset;i<Math.min(owners.size(),offset+36);i++){varowner=owners.get(i).getAsJsonObject();put(screen,i-offset,text(owner,"label","Organisation"),"Use your specialist’s researched MK and rarity for this organisation",Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE,()->prepareRefit(p,owner));}if(owners.isEmpty())put(screen,22,"Specialist required","Your current organisation deed must grant equipment research authority.",Material.GRAY_DYE,null);if(page>0)put(screen,45,"Previous","Earlier organisations",Material.ARROW,()->workshop(p,page-1));if(offset+36<owners.size())put(screen,53,"Next","More organisations",Material.ARROW,()->workshop(p,page+1));put(screen,49,"Back","Mission journal",Material.ARROW,()->open(p));show(p,screen);});}
privatevoidprepareRefit(Playerp,JsonObjectowner){try{varinput=newJsonObject();input.addProperty("action","prepare_refit");input.addProperty("kind","pol");varselected=newJsonObject();selected.add("kind",owner.get("kind"));selected.add("id",owner.get("id"));input.add("owner",selected);input.add("snapshot",bridge.refitSnapshot(p));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{varplan=permit.getAsJsonObject("plan");varoutput=plan.getAsJsonObject("output");varscreen=panel(p,"Review equipment refit");StringBuildercost=newStringBuilder("Surrender the held original and:");for(vartoken:plan.getAsJsonObject("consume").getAsJsonArray("templates"))cost.append("\n1 ").append(token.getAsJsonObject().get("id").getAsString().replace("dr_","").replace('_',' '));Materialmaterial=Material.matchMaterial(output.get("material").getAsString());put(screen,13,"MK "+output.get("equipmentMark").getAsString()+" · "+output.get("quality").getAsString().replace('_',' '),"Original identity, name, lore and wear retained.\nExisting enchantments scale with the next tier.\nReputation level "+plan.get("requiredReputationLevel").getAsString()+" required.\n"+cost,material==null?Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE:material,null);put(screen,30,"Refit original",cost+"\nOne minute between refits. Review expires after 30 seconds.",Material.LIME_DYE,()->confirmRefit(p,input));put(screen,32,"Back","Return without consuming anything",Material.ARROW,()->workshop(p,0));show(p,screen);});}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Hold your original near Gurney’s quartermaster.":failure.getMessage(),NamedTextColor.RED));}}
@ -46,13 +73,14 @@ final class QuestMenus implements Listener {
request(p,input,verified->{try{booleandone=bridge.refitEquipment(p,verified);p.sendMessage(Component.text(done?"Original equipment upgraded. Organisation name and MK are purple.":"This refit was already processed.",NamedTextColor.GREEN));}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Refit not confirmed. Reopen the workshop.":failure.getMessage(),NamedTextColor.RED));}});
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObjectdata=null;Stringerror=null;try{data=bridge.quests(owner,input);}catch(Exceptionfailure){error=failureinstanceofjava.io.IOException?failure.getMessage():"The mission journal is unavailable. Reopen it before retrying.";}JsonObjectreceived=data;Stringmessage=error;if(!plugin.isEnabled())return;
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObjectdata=null;Stringerror=null;try{data=decision?bridge.decisions(owner,input):bridge.quests(owner,input);}catch(Exceptionfailure){error=failureinstanceofjava.io.IOException?failure.getMessage():"The mission journal is unavailable. Reopen it before retrying.";}JsonObjectreceived=data;Stringmessage=error;if(!plugin.isEnabled())return;
privatevoidload(Playerp,Stringkind,Stringbranch,Stringselected,intpage){varinput=newJsonObject();input.addProperty("action","read");input.addProperty("kind",kind);request(p,input,data->{if(!"active".equals(text(data,"state",""))){p.sendMessage("No active quest season is available.");open(p);return;}if(branch==null)branches(p,kind,data);elseif(selected==null)quests(p,kind,data,branch,page);else{JsonObjectrow=null;for(varentry:data.getAsJsonArray("quests"))if(selected.equals(text(entry.getAsJsonObject(),"id","")))row=entry.getAsJsonObject();if(row==null)quests(p,kind,data,branch,page);elsedetails(p,kind,data,branch,page,row);}});}
privatevoidload(Playerp,Stringkind,Stringbranch,Stringselected,intpage){varinput=newJsonObject();input.addProperty("action","read");input.addProperty("kind",kind);varcontact=roleScope.get(p.getUniqueId());if(contact!=null&&kind.equals("pol"))input.addProperty("npcRole",contact.key());request(p,input,data->{if(!"active".equals(text(data,"state",""))){p.sendMessage("No active quest season is available.");open(p);return;}varrole=roleScope.get(p.getUniqueId());if(role!=null&&kind.equals("pol")){roleJournal(p,data,role,selected);return;}if(branch==null)branches(p,kind,data);elseif(selected==null)quests(p,kind,data,branch,page);else{JsonObjectrow=null;for(varentry:data.getAsJsonArray("quests"))if(selected.equals(text(entry.getAsJsonObject(),"id","")))row=entry.getAsJsonObject();if(row==null)quests(p,kind,data,branch,page);elsedetails(p,kind,data,branch,page,row);}});}
@ -66,7 +94,7 @@ final class QuestMenus implements Listener {
put(screen,45,"Branches","Choose another branch",Material.ARROW,()->branches(p,kind,data));if(page>0)put(screen,47,"Previous","Previous missions",Material.PAPER,()->quests(p,kind,data,branch,page-1));put(screen,49,"Refresh","Read current verified quest records",Material.CLOCK,()->load(p,kind,branch,null,page));if(offset+36<rows.size())put(screen,51,"Next","More missions",Material.PAPER,()->quests(p,kind,data,branch,page+1));show(p,screen);
if(website(row))put(screen,31,"Open website journal","This objective belongs to the website",Material.MAP,()->website(p));
@ -80,19 +108,19 @@ final class QuestMenus implements Listener {
if(kind.equals("pol")&&text(row,"id","").equals("POL-SMUGGLERS-01")&&!state.equals("claimed")&&(yes(row,"canStart")||state.equals("active")))put(screen,33,"Meet the underground network","Stand near an Arrakis Smuggler.\nAccept Esmar Tuek’s introduction, then claim the quest.",Material.ORANGE_DYE,()->{try{bridge.smugglerIntroduction(p);p.sendMessage("Introduction recorded. Refresh this quest in a few seconds.");}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Visit an Arrakis Smuggler first.":failure.getMessage());}});
if(kind.equals("pol")&&Set.of("POL-BOUNTY-01","POL-BOUNTY-02").contains(text(row,"id",""))&&!state.equals("claimed"))put(screen,33,"View active bounty jobs","On Arrakis, use the native bounty list and accept a target.",Material.MAP,()->{p.closeInventory();p.performCommand("dune bounty");});
if(kind.equals("pol")&&row.has("research")&&!state.equals("claimed")&&(yes(row,"canStart")||state.equals("active")||state.equals("completed")))put(screen,33,"Submit research samples","Stand near Gurney Halleck.\nSurrender the materials shown in this quest.",Material.SMITHING_TABLE,()->research(p,kind,branch,page,row));
if(kind.equals("pol")&&Set.of("pol-jerboa-meat-25","pol-jerboa-meat-50").contains(text(row,"metric",""))&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active")))put(screen,33,"Surrender cooked Jerboa meat","Stand near Gurney Halleck on Arrakis.\nSurrender the required genuine cooked Jerboa meat; no reuse of previous turn-ins.",Material.COOKED_RABBIT,()->meatTurnin(p,kind,branch,page,row));
if(kind.equals("pol")&&row.has("supply")&&!row.get("supply").isJsonNull()&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active"))){varsupply=row.getAsJsonObject("supply");put(screen,33,"Surrender mission supplies","Stand near Gurney's quartermaster on Arrakis.\nSurrender "+supply.get("quantity").getAsInt()+" genuine "+text(supply,"label","supplies")+".",Material.CHEST,()->supplyTurnin(p,kind,branch,page,row));}
if(kind.equals("pol")&&Set.of("pol-jerboa-meat-25","pol-jerboa-meat-50").contains(text(row,"metric",""))&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active")))put(screen,33,"Surrender cooked Jerboa meat","Stand near Shadout Mapes on Arrakis.\nSurrender the required genuine cooked Jerboa meat; no reuse of previous turn-ins.",Material.COOKED_RABBIT,()->meatTurnin(p,kind,branch,page,row));
if(kind.equals("pol")&&row.has("supply")&&!row.get("supply").isJsonNull()&&!state.equals("claimed")&&!yes(row,"canClaim")&&(yes(row,"canStart")||state.equals("active"))){varsupply=row.getAsJsonObject("supply");put(screen,33,"Surrender mission supplies","Stand near "+text(supply,"contact","the mission contact")+".\nSurrender "+supply.get("quantity").getAsInt()+" genuine "+text(supply,"label","supplies")+".",Material.CHEST,()->supplyTurnin(p,kind,branch,page,row));}
if(text(row,"id","").equals("S1-H-01"))put(screen,33,"Collect House T0 kit","Available directly from /start.\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","Buy, craft with genuine spice or collect native 5% mob drops.\nRepair plate, Binding patch, Tool fitting, Calibration piece.\nOptional: prepare all four from the ordinary materials.",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 verified repair parts.\nThen claim this quest to receive the intact kit.",Material.ANVIL,()->starter(p,kind,branch,page,row,"repair"));}
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);
put(screen,45,"Back","Mission selection",Material.ARROW,()->{varcurrentRole=roleScope.get(p.getUniqueId());if(currentRole!=null&&kind.equals("pol"))roleJournal(p,data,currentRole,null);elsequests(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);
}
privatevoidrefine(Playerp,Stringkind,JsonObjectdata,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();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(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Refinement unavailable. Reopen the quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit an Arrakis Smuggler first.":failure.getMessage(),NamedTextColor.RED));}}
privatevoidresearch(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();input.addProperty("action","prepare_research");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.research(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Research receipt pending. Refresh your quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit Gurney Halleck.":failure.getMessage(),NamedTextColor.RED));}}
privatevoidmeatTurnin(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();input.addProperty("action","prepare_husbandry_turnin");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.husbandryTurnin(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Meat turn-in not confirmed.":failure.getMessage());}});}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Visit Gurney Halleck on Arrakis.":failure.getMessage());}}
privatevoidsupplyTurnin(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();input.addProperty("action","prepare_pol_supply");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.starterNpc(p).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.polSupplyTurnin(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Supply turn-in not confirmed.":failure.getMessage());}});}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Visit the Arrakis quartermaster.":failure.getMessage());}}
privatevoidmeatTurnin(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();input.addProperty("action","prepare_husbandry_turnin");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.questCharacterNpc(p,"shadout_mapes").toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.husbandryTurnin(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Meat turn-in not confirmed.":failure.getMessage());}});}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Visit Shadout Mapes on Arrakis.":failure.getMessage());}}
privatevoidsupplyTurnin(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow){try{varinput=newJsonObject();input.addProperty("action","prepare_pol_supply");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("npcUuid",bridge.questCharacterNpc(p,row.getAsJsonObject("supply").get("role").getAsString()).toString());input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.polSupplyTurnin(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Supply turn-in not confirmed.":failure.getMessage());}});}catch(Exceptionfailure){p.sendMessage(failure.getMessage()==null?"Visit the named quest contact.":failure.getMessage());}}
privatevoidstarter(Playerp,Stringkind,Stringbranch,intpage,JsonObjectrow,Stringoperation){try{varinput=newJsonObject();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("access","journal");input.addProperty("confirmed",true);request(p,input,permit->{try{bridge.starterKit(p,permit);load(p,kind,branch,text(row,"id",""),page);}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Your equipment exchange remains available. Reopen the quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exceptionfailure){p.sendMessage(Component.text(failure.getMessage()==null?"Open /start in Survival or Adventure mode.":failure.getMessage(),NamedTextColor.RED));}}
@ -100,9 +128,9 @@ final class QuestMenus implements Listener {
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(Exceptionunavailable){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);