Converge all Exchange menu entry points on the native service
All checks were successful
DuneRealms Resourcepack CI / resourcepack (push) Successful in 3m19s
DuneRealms Plugin CI / plugins (push) Successful in 4m49s

This commit is contained in:
unimatrixgit 2026-11-29 11:31:33 +01:00
commit 313e6c712b
6 changed files with 16 additions and 80 deletions

View file

@ -7,7 +7,7 @@ Objective: preserve the accepted fast full-screen menu design while containing t
- DuneMenus 2.0.2: bounded compact summaries and titles; price/stock/seller stay visible in summaries and an optional Details control opens one selected full-lore panel above the grid without executing the purchase, without adding a confirmation action. Private-use inventory glyphs and legacy formatting codes are removed from display text. House-adviser wording avoids assigning every adviser the Mentat profession. Council actions use a balanced grid; the Your House arrow is an ordinary action rather than a paging control.
- Local illustrated website logo, proportionally contained and centred in the header brand area. Item icons and semantic fallbacks are horizontally centred in small framed wells. Canonical PNG SHA256 267fe0d0b5adb4f2fb657d1d6827d030e7f837c94335d0a3643210b908f47931. Menu item icons resolve the actual ItemStack item_model to an existing central-pack flat texture. No quality/mark is inferred from a name. Ordinary native blocks with a verified same-ID block texture use that flat surface preview, not a native 3D render. Unsupported dynamic/complex models retain a semantic fallback; this is not a general 3D item renderer.
- Artwork is packaged from committed central inputs and unpacked at plugin startup. Model/image lookups are cached. There are no remote artwork requests on menu opening.
- GUI 1.1.36 routes /exchange, namespaced aliases and /drgui exchange to the existing native ExchangeMenus.open path before the supplied-command interceptor. That is the same service used by the working GUI button and remains displayed by the fast ServiceMenu renderer.
- GUI 1.1.36 routes /exchange, namespaced aliases, /drgui exchange and every DuneMenus Exchange entry (including Hub and Company) to the existing native ExchangeMenus.open path before the supplied-command interceptor. That is the same service used by the working GUI button and remains displayed by the fast ServiceMenu renderer.
No economy, bank, purchase reference, retry, payment, delivery, JARVIS, Core, Ess, quest or raider implementation changes. Existing native purchase selection and settlement behaviour remains unchanged. This change does not clear an uncertain earlier purchase or replay a transaction.

View file

@ -75,6 +75,12 @@ public final class DuneMenusPlugin extends JavaPlugin implements TabExecutor {
Backend backend() { return backend; }
void openNativeExchange(Player player) {
var gui=getServer().getPluginManager().getPlugin("DunerealmsGUI");
if(gui!=null&&gui.isEnabled())try{gui.getClass().getMethod("openExchangeMenu",Player.class).invoke(gui,player);return;}catch(ReflectiveOperationException failure){getLogger().warning("Native Exchange entry unavailable: "+failure.getClass().getSimpleName());}
player.sendMessage("The native Exchange service is temporarily unavailable. Please retry later.");
}
public void openMenu(Player player, String menu) {
if (player.hasPermission("dunemenus.use")) create(menu, player, null).open();
}

View file

@ -1,82 +1,9 @@
package com.dunerealms.menus;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
/** 6 rows. Vertical tabs on the left, a 7x4 shelf of goods, toolbar underneath. "Sell" is a price stall. */
/** Every public menu entry uses the already working native Exchange flow. */
final class ExchangeMenu extends Menu {
private static final List<Integer> SHELF = new ArrayList<>();
static { for (int r = 1; r <= 4; r++) for (int c = 2; c <= 8; c++) SHELF.add(r * 9 + c); }
private String tab = "buy";
private int page = 0;
private long price = 10_000;
ExchangeMenu(DuneMenusPlugin plugin, Player p, Menu parent) { super(plugin, p, parent); }
String id() { return "exchange"; }
Skin skin() { return Skin.MARKET; }
String title() { return "Exchange · Merchant Hall"; }
String subtitle() { return "“Coin, cargo and rumour change hands here.”"; }
int rows() { return 6; }
private void tabButton(int slot, Material m, String label, String key) {
var item = Ui.item(m, (tab.equals(key) ? "<gold><b>" : "<gray>") + label);
if (tab.equals(key)) Ui.glow(item);
put(slot, item, t -> { tab = key; page = 0; redraw(); });
}
void draw() {
backdrop(Material.BROWN_STAINED_GLASS_PANE);
tabButton(9, Material.EMERALD, "Goods", "buy");
tabButton(18, Material.NETHERITE_CHESTPLATE, "Kits", "kits");
tabButton(27, Material.ENDER_CHEST, "My listings", "mine");
tabButton(36, Material.GOLD_NUGGET, "Sell", "sell");
back(46);
put(51, Ui.item(Material.CHEST, "<green>Collect purchases", "<gray>Move paid items to your inventory"),
t -> act(backend().collectPurchases(player)));
load(backend().balance(player), b -> put(47, Ui.item(Material.GOLD_INGOT, "<gold>Postbank available", "<white>" + Ui.dm(b))));
if (tab.equals("sell")) drawStall(); else drawShelf();
}
private void drawShelf() {
load(backend().listings(player, tab, page), pg -> {
boolean mine = tab.equals("mine");
for (int i = 0; i < SHELF.size() && i < pg.items().size(); i++) {
var l = pg.items().get(i);
put(SHELF.get(i), Ui.item(l.icon(), l.quantity(), "<white>" + l.title() + " <gray>· <gold>" + Ui.dm(l.priceMinor()),
"<gray>Seller: <white>" + l.seller(), "<gray>In stock: <white>" + l.quantity(), "",
mine ? "<yellow>Click to withdraw this listing"
: "<yellow>Click <gray>buy 1 <dark_gray>· <yellow>Shift-click <gray>buy " + Math.min(16, l.quantity())),
t -> {
if (mine) act(backend().withdraw(player, l));
else if (l.purchasable()) act(backend().buy(player, l, t.isShiftClick() && l.kitVersion() == null ? Math.min(16, l.quantity()) : 1));
});
}
put(49, Ui.item(Material.PAPER, "<gray>Page " + (page + 1)));
if (page > 0) put(45, Ui.item(Material.ARROW, "<gray>◀ Previous"), t -> { page--; redraw(); });
if (pg.hasNext()) put(53, Ui.item(Material.ARROW, "<gray>Next ▶"), t -> { page++; redraw(); });
});
}
private void chip(int slot, long delta) {
boolean up = delta > 0;
put(slot, Ui.item(up ? Material.LIME_DYE : Material.RED_DYE, (up ? "<green>+" : "<red>−") + Ui.dm(Math.abs(delta))),
t -> { price = Math.max(100, price + delta); redraw(); });
}
private void drawStall() {
var held = player.getInventory().getItemInMainHand().clone();
int heldSlot = player.getInventory().getHeldItemSlot();
long shownPrice = price;
boolean has = !held.getType().isAir();
put(13, has ? held.clone() : Ui.item(Material.BARRIER, "<red>Nothing in your hand"));
put(22, Ui.item(Material.OAK_SIGN, "<gray>Hold the item you want to sell", "<gray>in your main hand, set a price,", "<gray>then list it."));
chip(28, -10_000); chip(29, -1_000); chip(30, -100);
chip(32, 100); chip(33, 1_000); chip(34, 10_000);
put(31, Ui.item(Material.GOLD_NUGGET, "<gold><b>" + Ui.dm(price), "<gray>Price per item"));
put(40, Ui.glow(Ui.item(Material.EMERALD, "<green><b>List for " + Ui.dm(price))),
t -> { if (!has) { player.sendMessage(Ui.text("<red>Hold an item first.")); return; } act(backend().sell(player, held, heldSlot, shownPrice)); });
}
ExchangeMenu(DuneMenusPlugin plugin,Player player,Menu parent){super(plugin,player,parent);}
@Override boolean launchNative(){plugin.openNativeExchange(player);return true;}
String id(){return "exchange";}Skin skin(){return Skin.MARKET;}String title(){return "Exchange";}int rows(){return 6;}
void draw(){throw new IllegalStateException("Exchange must use the native service");}
}

View file

@ -43,12 +43,14 @@ abstract class Menu implements InventoryHolder {
abstract int rows();
abstract void draw();
String subtitle() { return ""; }
boolean launchNative() { return false; }
@Override public Inventory getInventory() { return inv; }
protected Backend backend() { return plugin.backend(); }
// ---------------------------------------------------------------- lifecycle
final void open() {
if (launchNative()) return;
if (!available()) return;
active = true;
plugin.opened(player, this);

View file

@ -239,6 +239,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
if(id.equals(selection(data))&&data.has("keyId")&&!data.get("keyId").isJsonNull()){mentat(p,data);return;}
fetch(p,id,data.get("version").getAsInt(),UUID.randomUUID(),saved->{p.sendMessage(Component.text("House allegiance confirmed in J.A.R.V.I.S.",NamedTextColor.GREEN));mentat(p,saved);});
}
public void openExchangeMenu(Player player){if(!Bukkit.isPrimaryThread()||!player.isOnline())throw new IllegalStateException("Exchange entry requires an online player on the server thread");exchange.open(player);}
private void mentat(Player p,JsonObject data){
String house=selection(data);if(house==null){select(p,data,null);return;}
JsonObject mentor=data.getAsJsonObject("mentat");String name=mentor.get("name").getAsString();int index=Arrays.asList(IDS).indexOf(house);

View file

@ -1,6 +1,6 @@
name: DunerealmsGUI
main: com.dunerealms.gui.DuneGUI
version: 1.1.35
version: 1.1.36
api-version: '1.21.8'
depend: [JarvisTranslator]
softdepend: [Citizens, MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]