Bind Rihla receipts to settled facts when recovering pending cash
All checks were successful
DuneRealms Resourcepack CI / resourcepack (push) Successful in 1m54s
DuneRealms Plugin CI / plugins (push) Successful in 2m58s

This commit is contained in:
unimatrixgit 2026-11-29 13:25:39 +01:00
commit 146a5c46ae

View file

@ -24,7 +24,7 @@ final class AtmMenu extends Menu {
private final List<DunemarkDenomination> selected = new ArrayList<>();
private String entered; // RIA ID typed on the Redeem tab
private String receiptOperation,receiptReference,receiptMessage;
private long receiptAmount;
private Long receiptAmount;
AtmMenu(DuneMenusPlugin plugin, Player p, Menu parent, Tab tab) { super(plugin, p, parent); this.tab = tab; }
String id() { return switch(tab){case WITHDRAW->"withdraw";case DEPOSIT->"deposit";case REDEEM->"redeem";case RECEIPT->"receipt";default->"atm";}; }
@ -66,7 +66,7 @@ final class AtmMenu extends Menu {
put(36,Ui.item(Material.ARROW,"<gray>Back"),c->{tab=Tab.HOME;selected.clear();redraw();});
if(tab==Tab.RECEIPT){
put(13,Ui.item(Material.PAPER,"<gold>"+receiptOperation,
"<gray>Amount: <white>"+Ui.dm(receiptAmount),"<gray>"+receiptMessage));
receiptAmount==null?"<gray>"+receiptMessage:"<gray>Amount: <white>"+Ui.dm(receiptAmount),"<gray>"+receiptMessage));
if(receiptReference!=null&&!receiptReference.isBlank())put(29,Ui.item(Material.NAME_TAG,"<gold>RIA ID","<white>"+receiptReference));
return;
}
@ -91,20 +91,21 @@ final class AtmMenu extends Menu {
if (dep) load(backend().atmCreateRia(player, pieces), r -> {
say(new Backend.Result(r.ok(), r.message()));
if (r.ok()) { receipt("Cash deposit",minor,r.riaId(),r.message()); }
if (r.ok()) { receipt("Cash deposit",r.receipt(),r.message()); }
else redraw();
});
else load(backend().bankWithdraw(player, pieces), r -> {
say(r);
if (r.ok()) receipt("Cash withdrawal",minor,null,r.message());
if (r.ok()) receipt("Cash withdrawal",r.receipt(),r.message());
else redraw();
});
});
}
private void receipt(String operation,long amount,String reference,String message){
receiptOperation=operation;receiptAmount=amount;receiptReference=reference;receiptMessage=message;
private void receipt(String operation,Backend.CashReceipt facts,String message){
receiptOperation=facts!=null&&facts.recovered()?"Recovered Rihla transaction":operation;
receiptAmount=facts==null?null:facts.amountMinor();receiptReference=facts==null?null:facts.riaId();receiptMessage=message;
selected.clear();tab=Tab.RECEIPT;redraw();
}
@ -123,9 +124,9 @@ final class AtmMenu extends Menu {
if (v == null) { put(22, Ui.item(Material.BARRIER, "<red>RIA ID not found")); return; }
put(22, Ui.glow(Ui.item(Material.GOLD_BLOCK, "<gold><b>" + Ui.dm(v.amountMinor()), "<gray>From: <white>" + v.fromName())));
put(24, Ui.glow(Ui.item(Material.GOLD_INGOT, "<green><b>Take as cash", "<gray>Bills and coins in your inventory")),
c -> load(backend().atmRedeem(player, v, false), r -> { say(r); if (r.ok()) {entered = null;receipt("RIA payout · Cash",v.amountMinor(),id,r.message());} else redraw(); }));
c -> load(backend().atmRedeem(player, v, false), r -> { say(r); if (r.ok()) {entered = null;receipt("RIA payout · Cash",r.receipt(),r.message());} else redraw(); }));
put(26, Ui.glow(Ui.item(Material.ENDER_CHEST, "<aqua><b>Send to my bank", "<gray>Credited to your account")),
c -> load(backend().atmRedeem(player, v, true), r -> { say(r); if (r.ok()) {entered = null;receipt("RIA payout · Bank",v.amountMinor(),id,r.message());} else redraw(); }));
c -> load(backend().atmRedeem(player, v, true), r -> { say(r); if (r.ok()) {entered = null;receipt("RIA payout · Bank",r.receipt(),r.message());} else redraw(); }));
});
}
}