From 718dd939467b3d12f75413f9845b8410d8f06d21 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sat, 28 Nov 2026 07:50:48 +0100 Subject: [PATCH] Run existing POL NPC turn-ins from chat --- .../java/com/dunerealms/gui/QuestMenus.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java index 1e48031d..2ec8ac27 100644 --- a/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java +++ b/DuneRealmsGUI/src/main/java/com/dunerealms/gui/QuestMenus.java @@ -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 or /missions ."); + player.sendMessage("Use /missions list or /missions . POL steps: /missions pol ."); 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;icargoPartner(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+30cargoPartners(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);}