Use dossier and cargo mission steps from chat

This commit is contained in:
unimatrixgit 2026-11-28 07:52:12 +01:00
commit 7512824334

View file

@ -42,8 +42,9 @@ final class QuestMenus implements Listener {
if(args.length==0){open(player);return;}
String verb=args[0].toLowerCase(Locale.ROOT);
boolean list=verb.equals("list");
boolean nativeStep=Set.of("research","meat","supply","refine").contains(verb);
if(args.length!=(list?2:3)||!nativeStep&&!Set.of("list","show","start","claim").contains(verb)||
boolean roleStep=Set.of("dossier","cargo","partner").contains(verb);
boolean nativeStep=roleStep||Set.of("research","meat","supply","refine").contains(verb);
if((roleStep?args.length<3||args.length>5:args.length!=(list?2:3))||!nativeStep&&!Set.of("list","show","start","claim").contains(verb)||
!Set.of("personal","pol").contains(args[1].toLowerCase(Locale.ROOT))){
player.sendMessage("Use /missions list <personal|pol> or /missions <show|start|claim> <personal|pol> <id>. POL steps: /missions <research|meat|supply|refine> pol <id>.");
return;
@ -59,6 +60,7 @@ final class QuestMenus implements Listener {
if(!id.equalsIgnoreCase(args[2]))continue;
if(website(row)){website(player);return;}
String state=text(row,"state","");
if(roleStep){roleMissionCommand(player,kind,data,row,verb,Arrays.copyOfRange(args,3,args.length));return;}
if(nativeStep){nativeMissionStep(player,kind,row,verb);return;}
if(verb.equals("show")){
player.sendMessage(id+" · "+text(row,"title","Mission")+" · "+state);
@ -74,6 +76,59 @@ final class QuestMenus implements Listener {
if(!list)player.sendMessage("That mission is not available to you.");
});
}
private void roleMissionCommand(Player player,String kind,JsonObject data,JsonObject row,String verb,String[] args){
String field=verb.equals("dossier")?"dossier":"cargo";
if(!kind.equals("pol")||!text(row,"state","").equals("active")||yes(row,"canClaim")||
!row.has(field)||!row.get(field).isJsonObject()){
player.sendMessage("That NPC step is unavailable for this mission.");return;
}
var state=row.getAsJsonObject(field);
var role=PolQuestNpc.decisionContact(text(state,"role",""));
if(role==null){player.sendMessage("No current mission contact is available.");return;}
if(field.equals("dossier")){
if(yes(state,"complete")){player.sendMessage("This dossier is complete.");return;}
int stage=state.get("stage").getAsInt();
if(stage<2&&args.length==0){dossierStep(player,data,role,row,stage,null,false);return;}
if(stage>=2&&state.has("answers")){
var answers=state.getAsJsonArray("answers");
int answer=-1;
if(args.length==1)try{answer=Integer.parseInt(args[0])-1;}catch(NumberFormatException ignored){}
if(answer>=0&&answer<answers.size()){dossierStep(player,data,role,row,stage,answer,false);return;}
for(int index=0;index<answers.size();index++)player.sendMessage((index+1)+". "+answers.get(index).getAsString());
player.sendMessage("Use /missions dossier pol "+text(row,"id","")+" <answer-number>.");
}
return;
}
String phase=text(state,"stage","");
if(verb.equals("cargo")&&args.length==0&&
(Set.of("seal","pickup").contains(phase)||phase.equals("deliver")&&yes(state,"routeReady"))){
cargoMission(player,role,row,phase,false);return;
}
if(verb.equals("partner")&&phase.equals("partner")){
String status=text(state,"partnerState","");
if(status.equals("choose")&&state.has("candidates")){
for(var value:state.getAsJsonArray("candidates")){
var candidate=value.getAsJsonObject();String id=text(candidate,"id","");
if(args.length==2&&args[0].equalsIgnoreCase("offer")&&id.equalsIgnoreCase(args[1])){
cargoPartner(player,role,row,"offer",id,false);return;
}
if(args.length==0)player.sendMessage(text(candidate,"name","Candidate")+" · "+id);
}
if(args.length==0)player.sendMessage("Use /missions partner pol "+text(row,"id","")+" offer <partner-id>.");
else player.sendMessage("Choose a current eligible partner.");
return;
}
String pair=text(state,"pairId","");
if(!pair.isEmpty()&&args.length==1){
String action=args[0].toLowerCase(Locale.ROOT);
if(status.equals("accept")&&Set.of("accept","decline").contains(action)||
!Set.of("choose","accept").contains(status)&&action.equals("withdraw")){
cargoPartner(player,role,row,action,pair,false);return;
}
}
}
player.sendMessage("Current cargo step: "+phase+" · Contact: "+role.name()+".");
}
private void nativeMissionStep(Player player,String kind,JsonObject row,String operation){
String state=text(row,"state",""),branch=text(row,"branch","");
boolean active=state.equals("active"),available=active||yes(row,"canStart");
@ -236,10 +291,13 @@ final class QuestMenus implements Listener {
private void meatTurnin(Player p,String kind,String branch,int page,JsonObject row,boolean reopen){try{var input=new JsonObject();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);if(reopen)load(p,kind,branch,text(row,"id",""),page);else p.sendMessage("NPC step submitted. Check /missions show pol "+text(row,"id","")+" for progress.");}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Meat turn-in not confirmed.":failure.getMessage());}});}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Visit Shadout Mapes on Arrakis.":failure.getMessage());}}
private void supplyTurnin(Player p,String kind,String branch,int page,JsonObject row){supplyTurnin(p,kind,branch,page,row,true);}
private void supplyTurnin(Player p,String kind,String branch,int page,JsonObject row,boolean reopen){try{var input=new JsonObject();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);if(reopen)load(p,kind,branch,text(row,"id",""),page);else p.sendMessage("NPC step submitted. Check /missions show pol "+text(row,"id","")+" for progress.");}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Supply turn-in not confirmed.":failure.getMessage());}});}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Visit the named quest contact.":failure.getMessage());}}
private void dossierStep(Player p,JsonObject data,PolQuestNpc.Role role,JsonObject row,int stage,Integer answer){try{var input=new JsonObject();input.addProperty("action","dossier_step");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("stage",stage);if(answer!=null)input.addProperty("answer",answer);request(p,input,result->{var screen=panel(p,"NPC turn-in · "+role.name());screen.description=text(result,"dialogue","");roleAvatar(screen,data,role);put(screen,13,text(row,"title","Mission"),yes(result,"complete")?"Completed · return to claim the verified reward":"Next contact: "+text(result,"nextRole","").replace('_',' '),Material.WRITTEN_BOOK,null);put(screen,31,"Continue","Return to current mission",Material.LIME_DYE,()->load(p,"pol",text(row,"branch",""),text(row,"id",""),0));show(p,screen);});}catch(Exception failure){p.sendMessage("Visit the exact named mission contact.");}}
private void cargoMission(Player p,PolQuestNpc.Role role,JsonObject row,String phase){try{var input=new JsonObject();input.addProperty("action","prepare_pol_cargo");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("phase",phase);request(p,input,permit->{try{bridge.polCargo(p,permit);load(p,"pol",text(row,"branch",""),text(row,"id",""),0);}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Cargo not confirmed.":failure.getMessage());}});}catch(Exception unavailable){p.sendMessage("Visit the exact assigned cargo contact.");}}
private void dossierStep(Player p,JsonObject data,PolQuestNpc.Role role,JsonObject row,int stage,Integer answer){dossierStep(p,data,role,row,stage,answer,true);}
private void dossierStep(Player p,JsonObject data,PolQuestNpc.Role role,JsonObject row,int stage,Integer answer,boolean reopen){try{var input=new JsonObject();input.addProperty("action","dossier_step");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("stage",stage);if(answer!=null)input.addProperty("answer",answer);request(p,input,result->{if(!reopen){p.sendMessage(text(result,"dialogue","Dossier step recorded."));p.sendMessage(yes(result,"complete")?"Dossier complete. Claim the verified reward.":"Next contact: "+text(result,"nextRole","").replace('_',' '));return;}var screen=panel(p,"NPC turn-in · "+role.name());screen.description=text(result,"dialogue","");roleAvatar(screen,data,role);put(screen,13,text(row,"title","Mission"),yes(result,"complete")?"Completed · return to claim the verified reward":"Next contact: "+text(result,"nextRole","").replace('_',' '),Material.WRITTEN_BOOK,null);put(screen,31,"Continue","Return to current mission",Material.LIME_DYE,()->load(p,"pol",text(row,"branch",""),text(row,"id",""),0));show(p,screen);});}catch(Exception failure){p.sendMessage("Visit the exact named mission contact.");}}
private void cargoMission(Player p,PolQuestNpc.Role role,JsonObject row,String phase){cargoMission(p,role,row,phase,true);}
private void cargoMission(Player p,PolQuestNpc.Role role,JsonObject row,String phase,boolean reopen){try{var input=new JsonObject();input.addProperty("action","prepare_pol_cargo");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("phase",phase);request(p,input,permit->{try{bridge.polCargo(p,permit);if(reopen)load(p,"pol",text(row,"branch",""),text(row,"id",""),0);else p.sendMessage("Cargo step submitted. Use /missions show pol "+text(row,"id","")+" to review progress.");}catch(Exception failure){p.sendMessage(failure.getMessage()==null?"Cargo not confirmed.":failure.getMessage());}});}catch(Exception unavailable){p.sendMessage("Visit the exact assigned cargo contact.");}}
private void cargoPartners(Player p,JsonObject data,PolQuestNpc.Role role,JsonObject row,int page){var cargo=row.getAsJsonObject("cargo");var screen=panel(p,"NPC turn-in · "+role.name());screen.description="";roleAvatar(screen,data,role);var candidates=cargo.has("candidates")?cargo.getAsJsonArray("candidates"):new JsonArray();int offset=page*30,slot=9;for(int i=offset;i<Math.min(offset+30,candidates.size());i++){var candidate=candidates.get(i).getAsJsonObject();String id=text(candidate,"id","");put(screen,slot++,text(candidate,"name","Eligible partner"),"Offer this exact cooperative assignment",Material.PLAYER_HEAD,()->cargoPartner(p,role,row,"offer",id));}if(candidates.size()==0)put(screen,13,"No current eligible partners","A matching active mission and current affiliation are required.",Material.CLOCK,null);if(page>0)put(screen,45,"Previous","More eligible partners",Material.ARROW,()->cargoPartners(p,data,role,row,page-1));if(offset+30<candidates.size())put(screen,53,"Next","More eligible partners",Material.ARROW,()->cargoPartners(p,data,role,row,page+1));put(screen,49,"Back","Selected mission",Material.ARROW,()->details(p,"pol",data,text(row,"branch",""),0,row));show(p,screen);}
private void cargoPartner(Player p,PolQuestNpc.Role role,JsonObject row,String phase,String id){try{var input=new JsonObject();input.addProperty("action","cargo_partner");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("phase",phase);input.addProperty(phase.equals("offer")?"partnerId":"pairId",id);request(p,input,result->load(p,"pol",text(row,"branch",""),text(row,"id",""),0));}catch(Exception unavailable){p.sendMessage("Meet Edric with your current cooperative mission.");}}
private void cargoPartner(Player p,PolQuestNpc.Role role,JsonObject row,String phase,String id){cargoPartner(p,role,row,phase,id,true);}
private void cargoPartner(Player p,PolQuestNpc.Role role,JsonObject row,String phase,String id,boolean reopen){try{var input=new JsonObject();input.addProperty("action","cargo_partner");input.addProperty("kind","pol");input.addProperty("definitionId",text(row,"id",""));input.addProperty("requestId",UUID.randomUUID().toString());input.addProperty("confirmed",true);input.addProperty("npcRole",role.key());input.addProperty("npcUuid",bridge.questCharacterNpc(p,role.key()).toString());input.addProperty("phase",phase);input.addProperty(phase.equals("offer")?"partnerId":"pairId",id);request(p,input,result->{if(reopen)load(p,"pol",text(row,"branch",""),text(row,"id",""),0);else p.sendMessage("Cooperative assignment updated.");});}catch(Exception unavailable){p.sendMessage("Meet Edric with your current cooperative mission.");}}
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("access","journal");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?"Open /start in Survival or Adventure mode.":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");