forked from unimatrix/web
Use direct organisation and spice actions with functional commands
This commit is contained in:
parent
81dd062f3c
commit
84d562e904
6 changed files with 72 additions and 25 deletions
|
|
@ -100,7 +100,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("lore")){organisations.lore(player);return true;}
|
||||
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==0){organisations.console(player);return true;}
|
||||
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("item")){giveCodex(player,true);return true;}
|
||||
if(sender instanceof Player member&&List.of("clan","company","polgui").contains(command.getName())){organisations.open(member,command.getName().equals("clan")?"clans":command.getName().equals("company")?"companies":"offices");return true;}
|
||||
if(sender instanceof Player member&&List.of("clan","company","politics","polgui").contains(command.getName())){organisations.command(member,command.getName().equals("clan")?"clans":command.getName().equals("company")?"companies":"offices",args);return true;}
|
||||
if(!(sender instanceof Player p))return true;
|
||||
if(command.getName().equals("house")&&args.length>0){
|
||||
String id=args[0].toLowerCase(Locale.ROOT);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
private static String money(long value){return BigDecimal.valueOf(value,2).toPlainString()+" DM";}
|
||||
static long price(String text){return ExchangePrice.parse(text);}
|
||||
private static ItemStack icon(Material material,String title,String... lore){var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(lore).map(s->Component.text(s,NamedTextColor.GRAY)).toList());item.setItemMeta(meta);return item;}
|
||||
private Panel panel(Player p,String title){int screen=title.endsWith("Your listings")?1:title.endsWith("Add item")?2:title.endsWith("Confirm purchase")?3:title.endsWith("Withdraw listing")?4:0;var s=new Panel(p,title,artwork.test(p)&&!BedrockForms.isBedrock(p),screen);if(!s.artwork){var pane=icon(Material.GREEN_STAINED_GLASS_PANE," ");for(int i=0;i<54;i++)s.inventory.setItem(i,pane);}return s;}
|
||||
private Panel panel(Player p,String title){int screen=title.endsWith("Your listings")?1:title.endsWith("Add item")?2:title.endsWith("Purchase details")?3:title.endsWith("Withdraw listing")?4:0;var s=new Panel(p,title,artwork.test(p)&&!BedrockForms.isBedrock(p),screen);if(!s.artwork){var pane=icon(Material.GREEN_STAINED_GLASS_PANE," ");for(int i=0;i<54;i++)s.inventory.setItem(i,pane);}return s;}
|
||||
private void button(Panel s,int slot,Material material,String title,String description,Runnable action){s.inventory.setItem(slot,icon(material,title,description));s.actions.put(slot,action);s.choices.add(new BedrockForms.Choice(title,description,action));}
|
||||
private void show(Player p,Panel s){if(BedrockForms.isBedrock(p)){s.gate.expire();BedrockForms.show(plugin,p,s.title,s.description,s.choices);}else{if(MCGUIMenus.show(p,s.title,s.description,s.inventory,s.actions,s.gate))return;p.openInventory(s.inventory);Bukkit.getScheduler().runTaskLater(plugin,s.gate::expire,2400L);}}
|
||||
private void request(Player p,JsonObject input,Consumer<JsonObject> success,Consumer<String> failure){
|
||||
|
|
@ -46,7 +46,7 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
if(page>0)button(s,45,Material.ARROW,"Previous","Page "+page,()->list(p,mine,page-1));if(data.get("hasNext").getAsBoolean())button(s,53,Material.ARROW,"Next","More listings",()->list(p,mine,page+1));button(s,48,Material.BOOK,"Imperial Codex","Return to your services",()->back.accept(p));button(s,49,Material.HOPPER,"Add held item","List an item from your main hand",()->draft(p));button(s,50,Material.CHEST_MINECART,"Collect purchases","Deliver paid items waiting for inventory space",()->{deliver(p,true);list(p,mine,page);});show(p,s);
|
||||
});}
|
||||
private void draft(Player p){var item=p.getInventory().getItemInMainHand();if(item.isEmpty()){p.sendMessage("Hold the item you want to sell first.");return;}sell(p,new Draft(item.clone(),p.getInventory().getHeldItemSlot(),Math.min(64,item.getAmount()),100));}
|
||||
private void sell(Player p,Draft draft){var s=panel(p,"Exchange · Add item");s.description=draft.item.getType().name()+" · "+draft.amount+" items\n"+money(draft.price)+" per item\nTotal: "+money(draft.price*draft.amount);s.inventory.setItem(13,draft.item.clone());quantityPresets(s,Math.min(64,draft.item.getAmount()),amount->sell(p,draft.quantity(amount)));button(s,30,Material.RED_DYE,"− Quantity","Sell "+draft.amount+" items",()->sell(p,draft.quantity(Math.max(1,draft.amount-1))));button(s,31,Material.PAPER,"Quantity: "+draft.amount,"Maximum "+Math.min(64,draft.item.getAmount()),()->sell(p,draft));button(s,32,Material.LIME_DYE,"+ Quantity","Add one item",()->sell(p,draft.quantity(Math.min(Math.min(64,draft.item.getAmount()),draft.amount+1))));button(s,40,Material.GOLD_INGOT,"Price: "+money(draft.price),"Price per item · total "+money(draft.price*draft.amount),()->editPrice(p,draft));button(s,45,Material.ARROW,"Back","Return to your listings",()->list(p,true,0));button(s,49,Material.EMERALD,"Confirm listing","Move "+draft.amount+" items into the Exchange",()->{UUID id=UUID.randomUUID();var q=action("prepare_sale");q.addProperty("requestId",id.toString());q.addProperty("amount",draft.amount);q.addProperty("priceMinor",draft.price);request(p,q,permit->{try{bridge.exchangePublish(p,permit,id,draft.item,draft.slot,draft.amount,draft.price);p.sendMessage("Listing published. Items are held by the Exchange until sold or withdrawn.");list(p,true,0);}catch(Exception e){p.sendMessage(e.getMessage()==null?"The listing was not confirmed.":e.getMessage());}});});show(p,s);}
|
||||
private void sell(Player p,Draft draft){var s=panel(p,"Exchange · Add item");s.description=draft.item.getType().name()+" · "+draft.amount+" items\n"+money(draft.price)+" per item\nTotal: "+money(draft.price*draft.amount);s.inventory.setItem(13,draft.item.clone());quantityPresets(s,Math.min(64,draft.item.getAmount()),amount->sell(p,draft.quantity(amount)));button(s,30,Material.RED_DYE,"− Quantity","Sell "+draft.amount+" items",()->sell(p,draft.quantity(Math.max(1,draft.amount-1))));button(s,31,Material.PAPER,"Quantity: "+draft.amount,"Maximum "+Math.min(64,draft.item.getAmount()),()->sell(p,draft));button(s,32,Material.LIME_DYE,"+ Quantity","Add one item",()->sell(p,draft.quantity(Math.min(Math.min(64,draft.item.getAmount()),draft.amount+1))));button(s,40,Material.GOLD_INGOT,"Price: "+money(draft.price),"Price per item · total "+money(draft.price*draft.amount),()->editPrice(p,draft));button(s,45,Material.ARROW,"Back","Return to your listings",()->list(p,true,0));button(s,49,Material.EMERALD,"Publish listing","Move "+draft.amount+" items into the Exchange",()->{UUID id=UUID.randomUUID();var q=action("prepare_sale");q.addProperty("requestId",id.toString());q.addProperty("amount",draft.amount);q.addProperty("priceMinor",draft.price);request(p,q,permit->{try{bridge.exchangePublish(p,permit,id,draft.item,draft.slot,draft.amount,draft.price);p.sendMessage("Listing published. Items are held by the Exchange until sold or withdrawn.");list(p,true,0);}catch(Exception e){p.sendMessage(e.getMessage()==null?"The listing was not confirmed.":e.getMessage());}});});show(p,s);}
|
||||
private void editPrice(Player p,Draft draft){
|
||||
var s=panel(p,"Exchange · Price");s.description=money(draft.price)+" per item · "+draft.amount+" items\nTotal: "+money(draft.price*draft.amount);s.inventory.setItem(13,icon(Material.GOLD_INGOT,"Price: "+money(draft.price),"Per item · total "+money(draft.price*draft.amount)));
|
||||
long[] steps={1,100,1000,10000};for(int i=0;i<steps.length;i++){long step=steps[i];button(s,27+i,Material.RED_DYE,"− "+money(step),"Decrease the price per item",()->editPrice(p,draft.price(Math.max(1,draft.price-step))));button(s,32+i,Material.LIME_DYE,"+ "+money(step),"Increase the price per item",()->editPrice(p,draft.price(Math.min(100000000,draft.price+step))));}
|
||||
|
|
@ -70,9 +70,9 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
}).buildConversation(p);
|
||||
priceInputs.put(owner,conversation);conversation.begin();
|
||||
}
|
||||
private void purchase(Player p,Purchase purchase){if(purchase.row.has("kitsetId")){kitPurchase(p,purchase);return;}var row=purchase.row;var s=panel(p,"Exchange · Confirm purchase");s.description=row.get("title").getAsString()+"\nSeller: "+row.get("seller").getAsString()+"\nQuantity: "+purchase.amount+" · Total: "+money(row.get("priceMinor").getAsLong()*purchase.amount);try{s.inventory.setItem(13,bridge.exchangeIcon(row));}catch(Exception bad){p.sendMessage("This item cannot be delivered by your current version.");return;}quantityPresets(s,Math.min(64,row.get("quantity").getAsInt()),amount->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(amount)));button(s,30,Material.RED_DYE,"− Quantity","Buy "+purchase.amount,()->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(Math.max(1,purchase.amount-1))));button(s,31,Material.PAPER,"Quantity: "+purchase.amount,money(row.get("priceMinor").getAsLong())+" per item",()->purchase(p,purchase));button(s,32,Material.LIME_DYE,"+ Quantity","Maximum "+Math.min(64,row.get("quantity").getAsInt()),()->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(Math.min(Math.min(64,row.get("quantity").getAsInt()),purchase.amount+1))));button(s,45,Material.ARROW,"Back","Return to the Exchange",()->{if(retries.containsKey(p.getUniqueId())){p.sendMessage("Resolve the previous purchase by retrying the same confirmation first.");purchase(p,purchase);}else list(p,false,0);});button(s,49,Material.EMERALD,(retries.containsKey(p.getUniqueId())?"Retry purchase · ":"Buy · ")+money(row.get("priceMinor").getAsLong()*purchase.amount),"Pay from your central personal bank account",()->{retries.put(p.getUniqueId(),purchase);var q=action("buy");q.addProperty("requestId",purchase.request.toString());q.addProperty("listingId",row.get("id").getAsString());q.addProperty("amount",purchase.amount);q.addProperty("priceMinor",row.get("priceMinor").getAsLong());q.addProperty("confirmed",true);request(p,q,receipt->{retries.remove(p.getUniqueId());p.sendMessage("Purchase confirmed: "+money(receipt.get("totalMinor").getAsLong())+". Your items are ready for delivery.");if(receipt.has("rebateMinor")&&receipt.get("rebateMinor").getAsLong()>0)p.sendMessage("Ordos trade incentive credited: "+money(receipt.get("rebateMinor").getAsLong())+".");deliver(p,true);list(p,false,0);},error->{p.sendMessage(error+" Retry this confirmation with the same purchase reference.");purchase(p,purchase);});});show(p,s);}
|
||||
private void purchase(Player p,Purchase purchase){if(purchase.row.has("kitsetId")){kitPurchase(p,purchase);return;}var row=purchase.row;var s=panel(p,"Exchange · Purchase details");s.description=row.get("title").getAsString()+"\nSeller: "+row.get("seller").getAsString()+"\nQuantity: "+purchase.amount+" · Total: "+money(row.get("priceMinor").getAsLong()*purchase.amount);try{s.inventory.setItem(13,bridge.exchangeIcon(row));}catch(Exception bad){p.sendMessage("This item cannot be delivered by your current version.");return;}quantityPresets(s,Math.min(64,row.get("quantity").getAsInt()),amount->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(amount)));button(s,30,Material.RED_DYE,"− Quantity","Buy "+purchase.amount,()->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(Math.max(1,purchase.amount-1))));button(s,31,Material.PAPER,"Quantity: "+purchase.amount,money(row.get("priceMinor").getAsLong())+" per item",()->purchase(p,purchase));button(s,32,Material.LIME_DYE,"+ Quantity","Maximum "+Math.min(64,row.get("quantity").getAsInt()),()->purchase(p,retries.containsKey(p.getUniqueId())?purchase:purchase.quantity(Math.min(Math.min(64,row.get("quantity").getAsInt()),purchase.amount+1))));button(s,45,Material.ARROW,"Back","Return to the Exchange",()->{if(retries.containsKey(p.getUniqueId())){p.sendMessage("Retry the previous purchase first.");purchase(p,purchase);}else list(p,false,0);});button(s,49,Material.EMERALD,(retries.containsKey(p.getUniqueId())?"Retry purchase · ":"Buy · ")+money(row.get("priceMinor").getAsLong()*purchase.amount),"Pay from your central personal bank account",()->{retries.put(p.getUniqueId(),purchase);var q=action("buy");q.addProperty("requestId",purchase.request.toString());q.addProperty("listingId",row.get("id").getAsString());q.addProperty("amount",purchase.amount);q.addProperty("priceMinor",row.get("priceMinor").getAsLong());q.addProperty("confirmed",true);request(p,q,receipt->{retries.remove(p.getUniqueId());p.sendMessage("Purchase confirmed: "+money(receipt.get("totalMinor").getAsLong())+". Your items are ready for delivery.");if(receipt.has("rebateMinor")&&receipt.get("rebateMinor").getAsLong()>0)p.sendMessage("Ordos trade incentive credited: "+money(receipt.get("rebateMinor").getAsLong())+".");deliver(p,true);list(p,false,0);},error->{p.sendMessage(error+" Retry with the same purchase reference.");purchase(p,purchase);});});show(p,s);}
|
||||
private void kits(Player p,int page){var q=action("read_kits");q.addProperty("page",page);request(p,q,data->{var s=panel(p,"Exchange · Kits");button(s,1,Material.EMERALD,"Buy items","Browse loose goods",()->list(p,false,0));button(s,4,Material.NETHERITE_CHESTPLATE,"Kits","Published organisation designs",()->kits(p,0));button(s,7,Material.CHEST,"Sell","Your listings",()->list(p,true,0));int index=0;for(var value:data.getAsJsonArray("listings")){var row=value.getAsJsonObject();int slot=10+(index/6)*9+index%6;index++;String title=row.get("title").getAsString(),description=row.get("seller").getAsString()+" · "+row.get("items").getAsInt()+" items · "+money(row.get("priceMinor").getAsLong());if(row.get("purchaseAvailable").getAsBoolean())button(s,slot,Material.NETHERITE_CHESTPLATE,title,description,()->kitPurchase(p,new Purchase(row.deepCopy(),1,UUID.randomUUID())));else{s.inventory.setItem(slot,icon(Material.GRAY_DYE,title,description,"Organisation banking is unavailable"));s.description+="\n"+title+" · unavailable";}}if(page>0)button(s,45,Material.ARROW,"Previous","Previous kits",()->kits(p,page-1));button(s,49,Material.ARROW,"Back","Imperial Codex",()->back.accept(p));if(data.get("hasNext").getAsBoolean())button(s,53,Material.ARROW,"Next","More kits",()->kits(p,page+1));show(p,s);});}
|
||||
private void kitPurchase(Player p,Purchase purchase){var row=purchase.row;var s=panel(p,"Exchange · Confirm purchase");s.description=row.get("title").getAsString()+"\nOrganisation: "+row.get("seller").getAsString()+"\n"+row.get("items").getAsInt()+" items · "+money(row.get("priceMinor").getAsLong());s.inventory.setItem(13,icon(Material.NETHERITE_CHESTPLATE,row.get("title").getAsString(),row.get("seller").getAsString(),row.get("items").getAsInt()+" items"));button(s,45,Material.ARROW,"Back","Kit catalogue",()->{if(retries.containsKey(p.getUniqueId())){p.sendMessage("Resolve the previous purchase with the same reference first.");kitPurchase(p,purchase);}else kits(p,0);});button(s,49,Material.EMERALD,(retries.containsKey(p.getUniqueId())?"Retry kit · ":"Buy kit · ")+money(row.get("priceMinor").getAsLong()),"Pay personally; proceeds go to the organisation",()->{retries.put(p.getUniqueId(),purchase);var q=action("buy_kit");q.addProperty("requestId",purchase.request.toString());q.addProperty("kitsetId",row.get("kitsetId").getAsString());q.add("listingVersion",row.get("listingVersion"));q.add("priceMinor",row.get("priceMinor"));q.addProperty("confirmed",true);request(p,q,receipt->{retries.remove(p.getUniqueId());p.sendMessage("Kit purchased: "+money(receipt.get("totalMinor").getAsLong())+". Delivery follows automatically; make room for the complete kit.");try{bridge.refreshKits(p);}catch(Exception unavailable){p.sendMessage("Your kit remains owed until the next inventory sync.");}kits(p,0);},error->{p.sendMessage(error+" Retry this confirmation with the same reference.");kitPurchase(p,purchase);});});show(p,s);}
|
||||
private void kitPurchase(Player p,Purchase purchase){var row=purchase.row;var s=panel(p,"Exchange · Purchase details");s.description=row.get("title").getAsString()+"\nOrganisation: "+row.get("seller").getAsString()+"\n"+row.get("items").getAsInt()+" items · "+money(row.get("priceMinor").getAsLong());s.inventory.setItem(13,icon(Material.NETHERITE_CHESTPLATE,row.get("title").getAsString(),row.get("seller").getAsString(),row.get("items").getAsInt()+" items"));button(s,45,Material.ARROW,"Back","Kit catalogue",()->{if(retries.containsKey(p.getUniqueId())){p.sendMessage("Resolve the previous purchase with the same reference first.");kitPurchase(p,purchase);}else kits(p,0);});button(s,49,Material.EMERALD,(retries.containsKey(p.getUniqueId())?"Retry kit · ":"Buy kit · ")+money(row.get("priceMinor").getAsLong()),"Pay personally; proceeds go to the organisation",()->{retries.put(p.getUniqueId(),purchase);var q=action("buy_kit");q.addProperty("requestId",purchase.request.toString());q.addProperty("kitsetId",row.get("kitsetId").getAsString());q.add("listingVersion",row.get("listingVersion"));q.add("priceMinor",row.get("priceMinor"));q.addProperty("confirmed",true);request(p,q,receipt->{retries.remove(p.getUniqueId());p.sendMessage("Kit purchased: "+money(receipt.get("totalMinor").getAsLong())+". Delivery follows automatically; make room for the complete kit.");try{bridge.refreshKits(p);}catch(Exception unavailable){p.sendMessage("Your kit remains owed until the next inventory sync.");}kits(p,0);},error->{p.sendMessage(error+" Retry this confirmation with the same reference.");kitPurchase(p,purchase);});});show(p,s);}
|
||||
private void withdraw(Player p,JsonObject row){var s=panel(p,"Exchange · Withdraw listing");try{s.inventory.setItem(13,bridge.exchangeIcon(row));}catch(Exception bad){p.sendMessage("This stored item cannot be decoded.");return;}button(s,45,Material.ARROW,"Back","Your listings",()->list(p,true,0));button(s,49,Material.CHEST,"Withdraw "+row.get("quantity").getAsInt()+" items","Return all unsold stock to your inventory",()->{UUID id=UUID.randomUUID();var q=action("prepare_cancel");q.addProperty("requestId",id.toString());request(p,q,permit->{try{int quantity=bridge.exchangeCancel(p,permit,id,Long.parseLong(row.get("id").getAsString()));p.sendMessage("Listing withdrawn. Returned "+quantity+" items.");list(p,true,0);}catch(Exception e){p.sendMessage(e.getMessage()==null?"The listing was not withdrawn.":e.getMessage());}});});show(p,s);}
|
||||
private void deliver(Player p,boolean explain){if(!p.isOnline()||!delivering.add(p.getUniqueId()))return;UUID id=p.getUniqueId();var q=action("pending");Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject response=null;try{response=bridge.exchange(id,q);}catch(Exception ignored){}var data=response;if(!plugin.isEnabled())return;Bukkit.getScheduler().runTask(plugin,()->{delivering.remove(id);if(!p.isOnline())return;if(data==null||!data.has("pending")){if(explain)p.sendMessage("Paid deliveries remain queued. Reopen the Exchange to try again.");return;}if(data.getAsJsonArray("pending").isEmpty()){if(explain)p.sendMessage("No paid items are waiting for delivery.");return;}try{int count=bridge.exchangeDeliver(p);if(explain||count>0)p.sendMessage(count>0?"J.A.R.V.I.S. delivered "+count+" purchased items.":"Make inventory space. Your paid items remain queued.");}catch(Exception unavailable){if(explain)p.sendMessage("Paid items remain queued until your shared inventory is ready.");}});});}
|
||||
@EventHandler public void join(PlayerJoinEvent e){Bukkit.getScheduler().runTaskLater(plugin,()->deliver(e.getPlayer(),false),60L);}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,58 @@ 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);else choose(p,result,kind);});
|
||||
});
|
||||
}
|
||||
void command(Player player,String kind,String[] args){
|
||||
if(args.length==0){open(player,kind);return;}
|
||||
String action=args[0].toLowerCase(Locale.ROOT);
|
||||
if(!Set.of("list","members","motd","home","sethome","claim","expand").contains(action)||
|
||||
args.length>(action.equals("expand")?3:action.equals("list")?1:2)||
|
||||
action.equals("expand")&&(args.length<2||!Set.of("north","east","south","west","all").contains(args[1].toLowerCase(Locale.ROOT)))){
|
||||
player.sendMessage("Use list, members, motd, home, sethome, claim, or expand <direction>. Add the organisation ID when you belong to several.");
|
||||
return;
|
||||
}
|
||||
if(!busy.add(player.getUniqueId()))return;
|
||||
UUID world=player.getWorld().getUID();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{
|
||||
JsonObject data=null;
|
||||
try{data=bridge.organisations(player.getUniqueId());}catch(Exception ignored){}
|
||||
JsonObject result=data;
|
||||
if(!plugin.isEnabled())return;
|
||||
Bukkit.getScheduler().runTask(plugin,()->{
|
||||
busy.remove(player.getUniqueId());
|
||||
if(!player.isOnline()||!world.equals(player.getWorld().getUID()))return;
|
||||
if(result==null){player.sendMessage("Your organisation keys are temporarily unavailable.");return;}
|
||||
var rows=result.getAsJsonArray(kind);
|
||||
if(action.equals("list")){
|
||||
if(rows.isEmpty())player.sendMessage("You have no current organisations in this section.");
|
||||
for(var value:rows){var row=value.getAsJsonObject();player.sendMessage(name(row)+" · "+row.get("id").getAsString());}
|
||||
return;
|
||||
}
|
||||
int idIndex=action.equals("expand")?2:1;
|
||||
JsonObject row=null;
|
||||
if(args.length>idIndex){
|
||||
for(var value:rows){var candidate=value.getAsJsonObject();if(candidate.get("id").getAsString().equalsIgnoreCase(args[idIndex])){row=candidate;break;}}
|
||||
}else if(rows.size()==1)row=rows.get(0).getAsJsonObject();
|
||||
if(row==null){player.sendMessage("Use the list command to get an organisation ID.");return;}
|
||||
switch(action){
|
||||
case "members"->{
|
||||
if(row.has("members"))for(var value:row.getAsJsonArray("members")){
|
||||
var member=value.getAsJsonObject();player.sendMessage(member.get("name").getAsString()+" · "+member.get("role").getAsString());
|
||||
}
|
||||
}
|
||||
case "motd"->player.sendMessage(row.has("motd")?row.get("motd").getAsString():"No message has been published.");
|
||||
case "claim"->player.sendMessage("Claimed chunks: "+(row.has("usedChunks")?row.get("usedChunks").getAsString():"Unavailable"));
|
||||
case "home"->perform(player,kind,row,"travel-home",null,false);
|
||||
case "sethome","expand"->{
|
||||
if(!row.get("canManage").getAsBoolean()||!row.has("claimRevision")||row.get("claimRevision").isJsonNull()){
|
||||
player.sendMessage("A current management deed and claim revision are required.");return;
|
||||
}
|
||||
boolean expand=action.equals("expand");
|
||||
perform(player,kind,row,expand?"expand-claim":"set-home",expand?args[1].toLowerCase(Locale.ROOT):null,false);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
void openHomeNpc(Player p,String kind,String id){
|
||||
if(!Set.of("clans","companies").contains(kind)||!busy.add(p.getUniqueId()))return;UUID world=p.getWorld().getUID();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject data=null;try{data=bridge.organisations(p.getUniqueId());}catch(Exception ignored){}JsonObject result=data;if(!plugin.isEnabled())return;
|
||||
|
|
@ -62,7 +114,7 @@ final class OrganisationMenus implements Listener {
|
|||
put(panel,31,"Manage claims",row.has("usedChunks")?row.get("usedChunks").getAsInt()+" / "+(row.has("claimCapacity")&&!row.get("claimCapacity").isJsonNull()?row.get("claimCapacity").getAsInt():"?")+" chunks · Expand your estate":"View estate and unlocked claim capacity",Material.MAP,()->claims(p,data,kind,row));
|
||||
var claimIcon=new ItemStack(Material.MAP);var claimMeta=claimIcon.getItemMeta();claimMeta.displayName(Component.text("Manage claims",NamedTextColor.GOLD));claimMeta.lore(List.of(Component.text("North · East · South · West · All",NamedTextColor.GRAY)));claimIcon.setItemMeta(claimMeta);panel.inventory.setItem(31,claimIcon);
|
||||
put(panel,4,title,"Role: "+role+"\nMembers: "+count+"\nHome Block: "+homeText+"",company?Material.CYAN_BANNER:Material.GREEN_BANNER,()->organisation(p,data,kind,row));
|
||||
put(panel,19,"Set Home Block",manage?"Register your current planet position\nExisting deed and claim revision are rechecked":"Current organisation management required",manage?Material.GOLD_BLOCK:Material.GRAY_DYE,()->{if(manage)confirmHome(p,data,kind,row);else{p.sendMessage("Current organisation management is required.");organisation(p,data,kind,row);}});
|
||||
put(panel,19,"Set Home Block",manage?"Register your current planet position\nExisting deed and claim revision are rechecked":"Current organisation management required",manage?Material.GOLD_BLOCK:Material.GRAY_DYE,()->{if(manage)perform(p,kind,row,"set-home",null);else{p.sendMessage("Current organisation management is required.");organisation(p,data,kind,row);}});
|
||||
put(panel,22,"Travel Home",home==null?"Unavailable · no registered game Home Block":"Registered game Home Block\nBoarding :00–:05, :20–:25, :40–:45\nOrganisation passage · no fare charged",home==null?Material.GRAY_DYE:Material.ENDER_PEARL,()->{if(home!=null)perform(p,kind,row,"travel-home",null);else organisation(p,data,kind,row);});
|
||||
put(panel,25,"Members","View current key-linked roster",Material.PLAYER_HEAD,()->members(p,data,kind,row));
|
||||
put(panel,37,"MOTD","Read your organisation message",Material.WRITABLE_BOOK,()->motd(p,data,kind,row));
|
||||
|
|
@ -92,17 +144,17 @@ final class OrganisationMenus implements Listener {
|
|||
String[] directions={"north","east","south","west","all"};int[] slots={13,23,31,21,22};int[] additions={width,height,width,height,2*width+2*height+4};
|
||||
boolean manage=row.get("canManage").getAsBoolean(),home=row.has("homeBlock")&&!row.get("homeBlock").isJsonNull();
|
||||
for(int i=0;i<directions.length;i++){String direction=directions[i];int addition=additions[i],next=used+addition;boolean allowed=manage&&home&&capacity>0&&next<=capacity;
|
||||
put(screen,slots[i],"Expand "+direction,allowed?"Add "+addition+" adjacent chunks\nResult: "+next+" / "+capacity+"\nReview before applying":!manage?"Current organisation management required":!home?"Set your Home Block first":capacity==0?"Claim entitlement unavailable":"Needs "+next+" chunks; unlocked limit "+capacity,allowed?Material.LIME_DYE:Material.GRAY_DYE,()->{if(!allowed)return;var confirm=panel(p,"Confirm claim expansion",!kind.equals("clans"));put(confirm,13,"Expand "+direction,"Add "+addition+" chunks around the current estate\nResult: "+next+" / "+capacity+" chunks\nExisting Home Block stays in place\nForeign claims and active wars are checked",Material.MAP,()->claims(p,data,kind,row));put(confirm,30,"Confirm expansion","Use unlocked capacity; no new tier purchase",Material.LIME_DYE,()->perform(p,kind,row,"expand-claim",direction));put(confirm,32,"Cancel","Leave the estate unchanged",Material.ARROW,()->claims(p,data,kind,row));show(p,confirm);});
|
||||
put(screen,slots[i],"Expand "+direction,allowed?"Add "+addition+" adjacent chunks\nResult: "+next+" / "+capacity+"\nUses unlocked capacity":!manage?"Current organisation management required":!home?"Set your Home Block first":capacity==0?"Claim entitlement unavailable":"Needs "+next+" chunks; unlocked limit "+capacity,allowed?Material.LIME_DYE:Material.GRAY_DYE,()->{if(allowed)perform(p,kind,row,"expand-claim",direction);});
|
||||
}
|
||||
put(screen,45,"Back","Organisation",Material.ARROW,()->organisation(p,data,kind,row));show(p,screen);
|
||||
}
|
||||
private void confirmHome(Player p,JsonObject data,String kind,JsonObject row){var panel=panel(p,"Confirm Home Block",!kind.equals("clans"));var at=p.getLocation();put(panel,13,"Set Home Block here",at.getWorld().getName()+" · "+at.getBlockX()+", "+at.getBlockY()+", "+at.getBlockZ()+"\nOne Home Block chunk\nYour deed is checked on confirmation",Material.GOLD_BLOCK,()->confirmHome(p,data,kind,row));put(panel,30,"Confirm current position","Record this location through JARVIS",Material.LIME_DYE,()->perform(p,kind,row,"set-home",null));put(panel,32,"Cancel","Preserve the registered location",Material.RED_DYE,()->organisation(p,data,kind,row));close(panel,p);show(p,panel);}
|
||||
private void wars(Player p,JsonObject data,String kind,JsonObject row){var panel=panel(p,"War deployments",false);int slot=9;for(var value:row.getAsJsonArray("wars")){var war=value.getAsJsonObject();if(slot>=45)break;put(panel,slot++,war.get("targetName").getAsString(),"Active war · deploy during boarding",Material.CROSSBOW,()->perform(p,kind,row,"war-transport",war.get("keyId").getAsString()));}put(panel,45,"Back","Organisation",Material.ARROW,()->organisation(p,data,kind,row));close(panel,p);show(p,panel);}
|
||||
private void perform(Player p,String kind,JsonObject row,String action,String war){
|
||||
private void perform(Player p,String kind,JsonObject row,String action,String war){perform(p,kind,row,action,war,true);}
|
||||
private void perform(Player p,String kind,JsonObject row,String action,String war,boolean reopen){
|
||||
if(!busy.add(p.getUniqueId()))return;var input=new JsonObject();input.addProperty("action",action);input.addProperty("kind",kind.equals("clans")?"clan":kind.equals("companies")?"company":"protected");input.addProperty("id",row.get("id").getAsString());input.add("authorityVersion",row.get("authorityVersion"));input.addProperty("requestId",UUID.randomUUID().toString());
|
||||
if(Set.of("set-home","expand-claim").contains(action)){input.addProperty("confirmed",true);input.addProperty("expectedRevision",row.get("claimRevision").getAsInt());}if(war!=null)input.addProperty(action.equals("expand-claim")?"direction":"warKeyId",war);
|
||||
p.closeInventory();p.sendMessage("Jarvis executing matrix");
|
||||
try{bridge.action(p,input).whenComplete((result,error)->{if(!plugin.isEnabled())return;Bukkit.getScheduler().runTask(plugin,()->{busy.remove(p.getUniqueId());if(!p.isOnline())return;if(error!=null){Throwable failure=error;while(failure.getCause()!=null)failure=failure.getCause();p.sendMessage(failure instanceof java.io.IOException?failure.getMessage():"Your organisation action could not be confirmed. Reopen the menu.");return;}if(result.has("message"))p.sendMessage(result.get("message").getAsString());if(Set.of("set-home","expand-claim").contains(action))open(p,kind);});});}catch(Exception error){busy.remove(p.getUniqueId());p.sendMessage("The organisation connector is temporarily unavailable.");}
|
||||
try{bridge.action(p,input).whenComplete((result,error)->{if(!plugin.isEnabled())return;Bukkit.getScheduler().runTask(plugin,()->{busy.remove(p.getUniqueId());if(!p.isOnline())return;if(error!=null){Throwable failure=error;while(failure.getCause()!=null)failure=failure.getCause();p.sendMessage(failure instanceof java.io.IOException?failure.getMessage():"Your organisation action could not be confirmed. Reopen the menu.");return;}if(result.has("message"))p.sendMessage(result.get("message").getAsString());if(reopen&&Set.of("set-home","expand-claim").contains(action))open(p,kind);});});}catch(Exception error){busy.remove(p.getUniqueId());p.sendMessage("The organisation connector is temporarily unavailable.");}
|
||||
}
|
||||
private void members(Player p,JsonObject data,String kind,JsonObject row){var panel=panel(p,"Members · "+name(row),!kind.equals("clans"));if(row.has("members")){int slot=0;for(var value:row.getAsJsonArray("members")){if(slot>=45)break;var person=value.getAsJsonObject();put(panel,slot++,person.get("name").getAsString(),person.get("role").getAsString(),Material.PLAYER_HEAD,()->members(p,data,kind,row));}}put(panel,45,"Back","Organisation",Material.ARROW,()->organisation(p,data,kind,row));close(panel,p);show(p,panel);}
|
||||
private void motd(Player p,JsonObject data,String kind,JsonObject row){String message=row.has("motd")?row.get("motd").getAsString():"";var panel=panel(p,"MOTD · "+name(row),!kind.equals("clans"));put(panel,22,name(row),message.isBlank()?"No message has been published.":message,Material.WRITABLE_BOOK,()->motd(p,data,kind,row));put(panel,45,"Back","Organisation",Material.ARROW,()->organisation(p,data,kind,row));close(panel,p);show(p,panel);}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ final class QuestMenus implements Listener {
|
|||
if(Set.of("thufir_hawat","piter_de_vries","hasimir_fenring","roma_atani","imperial_attendant","stilgar","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,()->openDecisions(p,0));put(screen,49,"Website journal","Full mission choices and history",Material.MAP,()->website(p));show(p,screen);
|
||||
}
|
||||
private void smugglerRequest(Player p,JsonObject input,Consumer<JsonObject> callback){try{bridge.questCharacterNpc(p,"esmar_tuek");}catch(Exception unavailable){p.sendMessage("Meet Esmar Tuek first.");return;}UUID id=p.getUniqueId(),world=p.getWorld().getUID(),operation=UUID.randomUUID();if(pending.putIfAbsent(id,operation)!=null)return;p.closeInventory();Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject result=null;String error=null;try{if(text(input,"action","").equals("smuggler_board")&&!bridge.worldOnline("arrakis"))throw new IllegalStateException("Arrakis is currently unavailable.");result=bridge.guild(id,input);}catch(Exception failure){error=failure.getMessage();}var response=result;String message=error;Bukkit.getScheduler().runTask(plugin,()->{if(!pending.remove(id,operation)||!p.isOnline()||!p.getWorld().getUID().equals(world))return;if(response==null){p.sendMessage(message==null?"The smuggler passage is unavailable.":message);return;}callback.accept(response);});});}
|
||||
private void smugglerMenu(Player p,JsonObject data,PolQuestNpc.Role role){var input=new JsonObject();input.addProperty("action","smuggler_quote");smugglerRequest(p,input,quote->{var screen=panel(p,"NPC turn-in · "+role.name());screen.description="A personal smuggler passage is distinct from sanctioned Guild travel. Unsanctioned arrival may carry the existing in-game bounty.";roleAvatar(screen,data,role);if(!yes(quote,"eligible")){put(screen,13,"Ordinary Guild passage","Your current lawful route is available. Use the normal Guild Navigator.",Material.COMPASS,null);}else if(!yes(quote,"allowed")){put(screen,13,"Personal passage","Opt in with Esmar if ordinary Arrakis passage is unavailable. One hour from the verified introduction.",Material.COMPASS,null);put(screen,31,"Opt in to smuggling","Register the existing smuggler introduction and personal permission.",Material.LIME_DYE,()->{var introduction=data.getAsJsonArray("quests").asList().stream().map(JsonElement::getAsJsonObject).filter(q->text(q,"id","").equals("POL-SMUGGLERS-01")).findFirst().orElse(null);if(introduction==null){p.sendMessage("The current smuggler mission is unavailable.");return;}Runnable emit=()->{try{bridge.smugglerIntroduction(p);p.sendMessage("Introduction recorded. Reopen personal passage after J.A.R.V.I.S. verifies it.");}catch(Exception error){p.sendMessage("Meet Esmar Tuek in the Guild lobby.");}};if(yes(introduction,"canStart")&&!Set.of("active","completed","claimed").contains(text(introduction,"state",""))){var start=new JsonObject();start.addProperty("action","start");start.addProperty("kind","pol");start.addProperty("definitionId","POL-SMUGGLERS-01");start.addProperty("requestId",UUID.randomUUID().toString());start.addProperty("confirmed",true);request(p,start,ignored->emit.run());}else emit.run();});}else{long expiry=quote.get("permitExpiresAt").getAsLong();int price=quote.get("fareMinor").getAsInt();put(screen,13,"Personal passage to Arrakis","Fare: "+String.format(Locale.ROOT,"%.2f DM",price/100.0)+"\nPermission expires: "+java.time.Instant.ofEpochMilli(expiry)+"\nExisting unsanctioned-arrival rules apply.",Material.COMPASS,null);if(yes(quote,"affordable"))put(screen,31,"Confirm paid passage","Reserve this exact fare; payment settles only after arrival.",Material.LIME_DYE,()->{var board=new JsonObject();board.addProperty("action","smuggler_board");board.addProperty("requestId",UUID.randomUUID().toString());board.add("keyId",quote.get("keyId"));board.add("version",quote.get("version"));board.add("fareMinor",quote.get("fareMinor"));board.addProperty("destination","arrakis");smugglerRequest(p,board,ticket->{try{bridge.dispatchGuild(p,ticket);}catch(Exception error){p.sendMessage("The transfer was not dispatched; unused reservation expires.");}});});else put(screen,31,"Insufficient funds","Your personal central bank account must cover the fare.",Material.CLOCK,null);}put(screen,33,"Starter spice shovel","Open the existing starter objective for your original shovel; no duplicate issue.",Material.WOODEN_SHOVEL,()->{p.closeInventory();p.performCommand("start");});put(screen,49,"Back","Return to Esmar's missions",Material.ARROW,()->load(p,"pol",null,null,0));show(p,screen);});}
|
||||
private void smugglerMenu(Player p,JsonObject data,PolQuestNpc.Role role){var input=new JsonObject();input.addProperty("action","smuggler_quote");smugglerRequest(p,input,quote->{var screen=panel(p,"NPC turn-in · "+role.name());screen.description="A personal smuggler passage is distinct from sanctioned Guild travel. Unsanctioned arrival may carry the existing in-game bounty.";roleAvatar(screen,data,role);if(!yes(quote,"eligible")){put(screen,13,"Ordinary Guild passage","Your current lawful route is available. Use the normal Guild Navigator.",Material.COMPASS,null);}else if(!yes(quote,"allowed")){put(screen,13,"Personal passage","Opt in with Esmar if ordinary Arrakis passage is unavailable. One hour from the verified introduction.",Material.COMPASS,null);put(screen,31,"Opt in to smuggling","Register the existing smuggler introduction and personal permission.",Material.LIME_DYE,()->{var introduction=data.getAsJsonArray("quests").asList().stream().map(JsonElement::getAsJsonObject).filter(q->text(q,"id","").equals("POL-SMUGGLERS-01")).findFirst().orElse(null);if(introduction==null){p.sendMessage("The current smuggler mission is unavailable.");return;}Runnable emit=()->{try{bridge.smugglerIntroduction(p);p.sendMessage("Introduction recorded. Reopen personal passage after J.A.R.V.I.S. verifies it.");}catch(Exception error){p.sendMessage("Meet Esmar Tuek in the Guild lobby.");}};if(yes(introduction,"canStart")&&!Set.of("active","completed","claimed").contains(text(introduction,"state",""))){var start=new JsonObject();start.addProperty("action","start");start.addProperty("kind","pol");start.addProperty("definitionId","POL-SMUGGLERS-01");start.addProperty("requestId",UUID.randomUUID().toString());start.addProperty("confirmed",true);request(p,start,ignored->emit.run());}else emit.run();});}else{long expiry=quote.get("permitExpiresAt").getAsLong();int price=quote.get("fareMinor").getAsInt();put(screen,13,"Personal passage to Arrakis","Fare: "+String.format(Locale.ROOT,"%.2f DM",price/100.0)+"\nPermission expires: "+java.time.Instant.ofEpochMilli(expiry)+"\nExisting unsanctioned-arrival rules apply.",Material.COMPASS,null);if(yes(quote,"affordable"))put(screen,31,"Book passage","Reserve this exact fare; payment settles only after arrival.",Material.LIME_DYE,()->{var board=new JsonObject();board.addProperty("action","smuggler_board");board.addProperty("requestId",UUID.randomUUID().toString());board.add("keyId",quote.get("keyId"));board.add("version",quote.get("version"));board.add("fareMinor",quote.get("fareMinor"));board.addProperty("destination","arrakis");smugglerRequest(p,board,ticket->{try{bridge.dispatchGuild(p,ticket);}catch(Exception error){p.sendMessage("The transfer was not dispatched; unused reservation expires.");}});});else put(screen,31,"Insufficient funds","Your personal central bank account must cover the fare.",Material.CLOCK,null);}put(screen,33,"Starter spice shovel","Open the existing starter objective for your original shovel; no duplicate issue.",Material.WOODEN_SHOVEL,()->{p.closeInventory();p.performCommand("start");});put(screen,49,"Back","Return to Esmar's missions",Material.ARROW,()->load(p,"pol",null,null,0));show(p,screen);});}
|
||||
void openDecisions(Player p,int page){
|
||||
var input=new JsonObject();input.addProperty("action","read");
|
||||
request(p,input,data->{
|
||||
|
|
@ -82,7 +82,7 @@ final class QuestMenus implements Listener {
|
|||
if(kind.equals("website")){put(screen,31,"Open website workflow","This decision requires the existing website controls.",Material.MAP,()->decisionWebsite(p,text(row,"id","")));}
|
||||
else if(account==null&&(!row.has("fundingRequired")||yes(row,"fundingRequired"))){int slot=18;for(var e:row.getAsJsonArray("accounts")){var a=e.getAsJsonObject();if(slot>=35)break;String id=text(a,"id","");try{if(new java.math.BigInteger(text(a,"availableMinor","0")).compareTo(new java.math.BigInteger(fee))<0)continue;}catch(NumberFormatException invalid){continue;}put(screen,slot++,text(a,"name","Funding account"),"Account "+text(a,"number","")+" · available "+new java.math.BigDecimal(text(a,"availableMinor","0")).movePointLeft(2).toPlainString()+" DM",Material.GOLD_INGOT,()->roleDecisionDetails(p,contact,role,row,id,parameter));}}
|
||||
else if(row.has("parameters")&¶meter==null){int slot=18;for(var item:row.getAsJsonArray("parameters")){var value=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{String parameterLabel=parameter;if(parameter!=null&&row.has("parameters"))for(var entry:row.getAsJsonArray("parameters")){var option=entry.getAsJsonObject();if(parameter.equals(text(option,"value",""))){parameterLabel=text(option,"label",parameter);break;}}put(screen,22,"Confirmed selection",(account==null?"No separate funding required":"Funding account "+account)+(parameter==null?"":"\nParameter: "+parameterLabel),Material.GOLD_INGOT,null);UUID requestId=UUID.randomUUID();put(screen,31,"Enact decision","Record this decision through J.A.R.V.I.S. at "+role.name(),Material.LIME_DYE,()->{var input=new JsonObject();input.addProperty("action","execute");input.addProperty("npcRole",role.key());input.addProperty("decisionId",text(row,"id",""));input.addProperty("requestId",requestId.toString());if(account!=null)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));});}
|
||||
else{String parameterLabel=parameter;if(parameter!=null&&row.has("parameters"))for(var entry:row.getAsJsonArray("parameters")){var option=entry.getAsJsonObject();if(parameter.equals(text(option,"value",""))){parameterLabel=text(option,"label",parameter);break;}}put(screen,22,"Decision terms",(account==null?"No separate funding required":"Funding account "+account)+(parameter==null?"":"\nParameter: "+parameterLabel),Material.GOLD_INGOT,null);UUID requestId=UUID.randomUUID();put(screen,31,"Enact decision","Record this decision through J.A.R.V.I.S. at "+role.name(),Material.LIME_DYE,()->{var input=new JsonObject();input.addProperty("action","execute");input.addProperty("npcRole",role.key());input.addProperty("decisionId",text(row,"id",""));input.addProperty("requestId",requestId.toString());if(account!=null)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));});}
|
||||
put(screen,49,"Back","Current executable decisions",Material.ARROW,()->openDecisions(p,0));show(p,screen);
|
||||
}
|
||||
private void roleDecisionResult(Player p,JsonObject contact,PolQuestNpc.Role role,JsonObject row,JsonObject result){var screen=panel(p,"NPC next quest decision · "+role.name());screen.description=dialogue(row,"turnIn","");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,()->openDecisions(p,0));put(screen,49,"Later","Return to the contact dashboard",Material.ARROW,()->load(p,"pol",null,null,0));show(p,screen);}
|
||||
|
|
|
|||
|
|
@ -34,25 +34,19 @@ final class SpiceMenus implements Listener {
|
|||
void open(Player p){open(p,null);}
|
||||
void open(Player p,String selected){
|
||||
if(!arrakis(p)){p.sendMessage("Spice buyers are available on Arrakis only.");return;}
|
||||
var panel=new Panel(p);int guildCount;
|
||||
try{guildCount=bridge.spiceCount(p,"guild");}catch(Exception e){p.sendMessage("Spice inventory unavailable.");return;}
|
||||
var panel=new Panel(p);int guildCount,smugglerCount;
|
||||
try{guildCount=bridge.spiceCount(p,"guild");smugglerCount=bridge.spiceCount(p,"smuggler");}catch(Exception e){p.sendMessage("Spice inventory unavailable.");return;}
|
||||
put(panel,4,Material.ORANGE_DYE,"Melange Spice",guildCount+" raw-spice units (1 block = 9)\nP&O pays your personal bank account",null,null);
|
||||
put(panel,11,Material.PLAYER_HEAD,"Spacing Guild · Navigator","Sell eligible guild spice at the current authorised rate\nReview your sale",()->review(p,"guild"),"spice_guild");
|
||||
put(panel,15,Material.PLAYER_HEAD,"Smuggler · Esmar Tuek","Contraband spice only\nAn active Smuggler quest is required and checked at sale",()->review(p,"smuggler"),"spice_smuggler");
|
||||
put(panel,11,Material.PLAYER_HEAD,"Sell "+guildCount+" to the Guild","Sell eligible spice at the current authorised rate",()->sellAll(p,"guild",guildCount),"spice_guild");
|
||||
put(panel,15,Material.PLAYER_HEAD,"Sell "+smugglerCount+" to Esmar Tuek","Contraband only · Requires an active Smuggler quest",()->sellAll(p,"smuggler",smugglerCount),"spice_smuggler");
|
||||
put(panel,26,Material.GOLD_INGOT,"Collect pending payments","Retry committed P&O spice payments",()->recover(p),null);
|
||||
put(panel,22,Material.ARROW,"Back","Imperial Codex",()->back.accept(p),null);show(p,panel);
|
||||
}
|
||||
private void review(Player p,String channel){
|
||||
if(!arrakis(p))return;int count;try{count=bridge.spiceCount(p,channel);}catch(Exception e){p.sendMessage("Spice inventory unavailable.");return;}
|
||||
if(count==0){p.sendMessage("You have no matching spice for this buyer.");return;}var panel=new Panel(p);
|
||||
put(panel,13,Material.ORANGE_DYE,"Sell "+count+" spice",(channel.equals("guild")?"Spacing Guild":"Esmar Tuek")+"\nCurrent authorised price and Trust levy applied at confirmation.\nP&O pays your personal bank account.",null,null);
|
||||
put(panel,11,Material.ARROW,"Back","Choose buyer",()->open(p),null);put(panel,15,Material.EMERALD,"Confirm sale","Sell all "+count+" eligible spice",()->sellAll(p,channel,count),null);show(p,panel);
|
||||
}
|
||||
void sellAll(Player p,String channel){sellAll(p,channel,null);}
|
||||
private void sellAll(Player p,String channel,Integer expectedCount){
|
||||
if(!Set.of("guild","smuggler").contains(channel)){p.sendMessage("/sellall [guild|smuggler]");return;}if(!arrakis(p)){p.sendMessage("Spice buyers are available on Arrakis only.");return;}
|
||||
int count;try{count=bridge.spiceCount(p,channel);}catch(Exception e){p.sendMessage("Spice inventory unavailable.");return;}
|
||||
if(expectedCount!=null&&count!=expectedCount){p.sendMessage("Your spice inventory changed. Review the sale again.");review(p,channel);return;}
|
||||
if(expectedCount!=null&&count!=expectedCount){p.sendMessage("Your spice inventory changed. Choose a buyer again.");open(p);return;}
|
||||
sell(p,channel,count);
|
||||
}
|
||||
private void sell(Player p,String channel,int count){if(count<1){p.sendMessage("You have no matching spice for this buyer.");return;}p.closeInventory();var q=action("prepare");UUID request=UUID.randomUUID();q.addProperty("requestId",request.toString());q.addProperty("channel",channel);q.addProperty("amount",count);q.addProperty("confirmed",true);
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ commands:
|
|||
description: Open your key-linked clan panel
|
||||
company:
|
||||
description: Open your key-linked company panel
|
||||
polgui:
|
||||
description: Open your current political office panel
|
||||
politics:
|
||||
aliases: [polgui]
|
||||
description: Open your political office or run an office operation
|
||||
guildtravel:
|
||||
description: Book or cancel twenty-minute Imperial passage to your House world
|
||||
drscoreboard:
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff