forked from unimatrix/web
Offer native Exchange listing, price controls and withdrawal
This commit is contained in:
parent
f3686fb5e4
commit
a09b6e107b
1 changed files with 52 additions and 18 deletions
|
|
@ -121,7 +121,8 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
if(BedrockForms.isBedrock(p)){s.gate.expire();BedrockForms.show(plugin,p,s.title,s.description,s.choices);return;}
|
||||
var style=switch(s.title){
|
||||
case "Exchange · Buy","Exchange · Your listings","Exchange · Kits" -> DecisionsViewTransport.Style.EXCHANGE;
|
||||
case "Exchange · Purchase details" -> DecisionsViewTransport.Style.EXCHANGE_CHECKOUT;
|
||||
case "Exchange · Purchase details","Exchange · Add item","Exchange · Price","Exchange · Withdraw listing" ->
|
||||
DecisionsViewTransport.Style.EXCHANGE_CHECKOUT;
|
||||
default -> null;
|
||||
};
|
||||
if(style!=null&&NativeMenus.show(plugin,p,"development.fullscreen-exchange-viewers",s.title,s.description,s.inventory,s.actions,s.gate,style,null))return;
|
||||
|
|
@ -229,7 +230,8 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
if(reopen)kitPurchase(player,purchase);
|
||||
});
|
||||
}
|
||||
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",()->withdrawListing(p,Long.parseLong(row.get("id").getAsString()),true));show(p,s);}
|
||||
private void withdraw(Player p,JsonObject row){var s=panel(p,"Exchange · Withdraw listing");s.description=row.get("title").getAsString()+"\n"+
|
||||
row.get("quantity").getAsInt()+" unsold\n"+money(row.get("priceMinor").getAsLong())+" each";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",()->withdrawListing(p,Long.parseLong(row.get("id").getAsString()),true));show(p,s);}
|
||||
private void withdrawListing(Player player,long listing,boolean reopen){
|
||||
UUID id=UUID.randomUUID();var query=action("prepare_cancel");query.addProperty("requestId",id.toString());
|
||||
request(player,query,permit->{
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff