Revalidate specialist authority after confirming refit review
This commit is contained in:
parent
053ed73b81
commit
59636da12e
1 changed files with 6 additions and 1 deletions
|
|
@ -39,7 +39,12 @@ final class QuestMenus implements Listener {
|
|||
void open(Player p){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,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);}
|
||||
private void website(Player p){p.closeInventory();p.sendMessage(Component.text("Open your Mentat Report →",NamedTextColor.GOLD).clickEvent(ClickEvent.openUrl("https://clans.dunerealms.com/#quests/quests")));}
|
||||
private void workshop(Player p,int page){var input=new JsonObject();input.addProperty("action","read_refits");input.addProperty("kind","pol");request(p,input,data->{var screen=panel(p,"Organisation workshop");var owners=data.getAsJsonArray("owners");int offset=page*36;for(int i=offset;i<Math.min(owners.size(),offset+36);i++){var owner=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);});}
|
||||
private void prepareRefit(Player p,JsonObject owner){try{var input=new JsonObject();input.addProperty("action","prepare_refit");input.addProperty("kind","pol");var selected=new JsonObject();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->{var plan=permit.getAsJsonObject("plan");var output=plan.getAsJsonObject("output");var screen=panel(p,"Review equipment refit");StringBuilder cost=new StringBuilder("Surrender the held original and:");for(var token:plan.getAsJsonObject("consume").getAsJsonArray("templates"))cost.append("\n1 ").append(token.getAsJsonObject().get("id").getAsString().replace("dr_","").replace('_',' '));Material material=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,()->{try{p.closeInventory();boolean done=bridge.refitEquipment(p,permit);p.sendMessage(Component.text(done?"Original equipment upgraded. Organisation name and MK are purple.":"This refit was already processed.",NamedTextColor.GREEN));}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Refit not confirmed. Reopen the workshop.":failure.getMessage(),NamedTextColor.RED));}});put(screen,32,"Back","Return without consuming anything",Material.ARROW,()->workshop(p,0));show(p,screen);});}catch(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Hold your original near Gurney’s quartermaster.":failure.getMessage(),NamedTextColor.RED));}}
|
||||
private void prepareRefit(Player p,JsonObject owner){try{var input=new JsonObject();input.addProperty("action","prepare_refit");input.addProperty("kind","pol");var selected=new JsonObject();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->{var plan=permit.getAsJsonObject("plan");var output=plan.getAsJsonObject("output");var screen=panel(p,"Review equipment refit");StringBuilder cost=new StringBuilder("Surrender the held original and:");for(var token:plan.getAsJsonObject("consume").getAsJsonArray("templates"))cost.append("\n1 ").append(token.getAsJsonObject().get("id").getAsString().replace("dr_","").replace('_',' '));Material material=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(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Hold your original near Gurney’s quartermaster.":failure.getMessage(),NamedTextColor.RED));}}
|
||||
private void confirmRefit(Player p,JsonObject input){
|
||||
// Recheck the central deed/research after the player confirms the review.
|
||||
// An appointment or organisation may have changed while that panel was open.
|
||||
request(p,input,verified->{try{boolean done=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(Exception failure){p.sendMessage(Component.text(failure.getMessage()==null?"Refit not confirmed. Reopen the workshop.":failure.getMessage(),NamedTextColor.RED));}});
|
||||
}
|
||||
private void request(Player p,JsonObject input,Consumer<JsonObject> result){
|
||||
UUID owner=p.getUniqueId();if(pending.containsKey(owner))return;UUID operation=UUID.randomUUID(),world=p.getWorld().getUID();pending.put(owner,operation);p.closeInventory();p.sendMessage(Component.text("Jarvis executing matrix",NamedTextColor.GOLD));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject data=null;String error=null;try{data=bridge.quests(owner,input);}catch(Exception failure){error=failure instanceof java.io.IOException?failure.getMessage():"The mission journal is unavailable. Reopen it before retrying.";}JsonObject received=data;String message=error;if(!plugin.isEnabled())return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff