forked from unimatrix/web
Run existing POL NPC turn-ins from chat
This commit is contained in:
parent
a733b9f260
commit
718dd93946
1 changed files with 25 additions and 6 deletions
|
|
@ -42,9 +42,10 @@ final class QuestMenus implements Listener {
|
|||
if(args.length==0){open(player);return;}
|
||||
String verb=args[0].toLowerCase(Locale.ROOT);
|
||||
boolean list=verb.equals("list");
|
||||
if(args.length!=(list?2:3)||!Set.of("list","show","start","claim").contains(verb)||
|
||||
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)||
|
||||
!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>.");
|
||||
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;
|
||||
}
|
||||
String kind=args[1].toLowerCase(Locale.ROOT);
|
||||
|
|
@ -58,6 +59,7 @@ final class QuestMenus implements Listener {
|
|||
if(!id.equalsIgnoreCase(args[2]))continue;
|
||||
if(website(row)){website(player);return;}
|
||||
String state=text(row,"state","");
|
||||
if(nativeStep){nativeMissionStep(player,kind,row,verb);return;}
|
||||
if(verb.equals("show")){
|
||||
player.sendMessage(id+" · "+text(row,"title","Mission")+" · "+state);
|
||||
player.sendMessage(text(row,"objective","Complete the verified objective."));
|
||||
|
|
@ -72,6 +74,19 @@ final class QuestMenus implements Listener {
|
|||
if(!list)player.sendMessage("That mission is not available to you.");
|
||||
});
|
||||
}
|
||||
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");
|
||||
if(kind.equals("pol")){
|
||||
switch(operation){
|
||||
case "research"->{if(row.has("research")&&!state.equals("claimed")&&(available||state.equals("completed"))){research(player,kind,branch,0,row,false);return;}}
|
||||
case "meat"->{if(Set.of("pol-jerboa-meat-25","pol-jerboa-meat-50").contains(text(row,"metric",""))&&!state.equals("claimed")&&!yes(row,"canClaim")&&available){meatTurnin(player,kind,branch,0,row,false);return;}}
|
||||
case "supply"->{if(row.has("supply")&&!row.get("supply").isJsonNull()&&!state.equals("claimed")&&!yes(row,"canClaim")&&available){supplyTurnin(player,kind,branch,0,row,false);return;}}
|
||||
case "refine"->{if(Set.of("POL-ELYTRA-REFINE","POL-ELYTRA-CONTAMINATE","POL-SPICE-UPGRADE-REFINE","POL-SPICE-UPGRADE-CONTAMINATE").contains(text(row,"id",""))&&(available||Set.of("completed","claimed").contains(state))){refine(player,kind,branch,0,row,false);return;}}
|
||||
}
|
||||
}
|
||||
player.sendMessage("That NPC step is unavailable for this mission.");
|
||||
}
|
||||
void open(Player p){roleScope.remove(p.getUniqueId());var screen=panel(p,"Mission journal");put(screen,20,"Personal Experience","Your personal mission branches",Material.BOOK,()->load(p,"personal",null,null,0));put(screen,24,"Reputation","Your Reputation mission branches",Material.ENCHANTED_BOOK,()->load(p,"pol",null,null,0));put(screen,31,"Political decisions","Decisions available to your current offices",Material.WRITABLE_BOOK,()->openDecisions(p,0));put(screen,45,"Website Mentat Report","Open your full online journal",Material.MAP,()->website(p));put(screen,49,"Back","Imperial Codex",Material.ARROW,()->back.accept(p));show(p,screen);}
|
||||
void starterJournal(Player p){roleScope.remove(p.getUniqueId());load(p,"personal","h",null,0);}
|
||||
void openRole(Player p,PolQuestNpc.Role role){roleScope.put(p.getUniqueId(),role);if(role.branches().contains("prologue")){housePrologue(p,role);return;}load(p,"pol",null,null,0);}
|
||||
|
|
@ -213,10 +228,14 @@ final class QuestMenus implements Listener {
|
|||
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 selection",Material.ARROW,()->{var currentRole=roleScope.get(p.getUniqueId());if(currentRole!=null&&kind.equals("pol"))roleJournal(p,data,currentRole,null);else 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 research(Player p,String kind,String branch,int page,JsonObject row){try{var input=new JsonObject();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(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Research receipt pending. Refresh your quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit Gurney Halleck.":failure.getMessage(),NamedTextColor.RED));}}
|
||||
private void meatTurnin(Player p,String kind,String branch,int page,JsonObject row){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);load(p,kind,branch,text(row,"id",""),page);}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){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);load(p,kind,branch,text(row,"id",""),page);}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 refine(Player p,String kind,JsonObject data,String branch,int page,JsonObject row){refine(p,kind,branch,page,row,true);}
|
||||
private void refine(Player p,String kind,String branch,int page,JsonObject row,boolean reopen){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));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(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 research(Player p,String kind,String branch,int page,JsonObject row){research(p,kind,branch,page,row,true);}
|
||||
private void research(Player p,String kind,String branch,int page,JsonObject row,boolean reopen){try{var input=new JsonObject();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);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(Component.text(failure.getMessage()==null?"Research receipt pending. Refresh your quest.":failure.getMessage(),NamedTextColor.RED));}});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Visit Gurney Halleck.":failure.getMessage(),NamedTextColor.RED));}}
|
||||
private void meatTurnin(Player p,String kind,String branch,int page,JsonObject row){meatTurnin(p,kind,branch,page,row,true);}
|
||||
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 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);}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff