Add branded MCGUI market presentation across all DuneRealms menus
This commit is contained in:
parent
576fdd17b1
commit
5e8f7bc724
13 changed files with 357 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
plugins { java }
|
||||
group = "com.dunerealms"
|
||||
version = "1.1.16"
|
||||
version = "1.1.17"
|
||||
repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/"); maven("https://repo.opencollab.dev/main/") }
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
|
||||
|
|
|
|||
56
DuneRealmsGUI/fancyui/README.md
Normal file
56
DuneRealmsGUI/fancyui/README.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Fancy UI migration
|
||||
|
||||
Historical comparison only. The selected implementation uses MCGUI; see
|
||||
[the active menu integration](../mcgui/README.md).
|
||||
|
||||
Requested replacement: https://builtbybit.com/resources/fancy-ui.115209/
|
||||
Documentation checked 2026-11-23: https://nusse.dev/docs/fancyui
|
||||
|
||||
## Deployment prerequisite
|
||||
|
||||
The licensed FancyUI JAR has not been supplied. Do not remove or disable the
|
||||
working DuneRealms menus until the replacement has been loaded and its generated
|
||||
pack has been verified. PacketEvents is required by FancyUI. PlaceholderAPI is
|
||||
optional according to the creator's documentation; use it only for actual data
|
||||
bindings that need it.
|
||||
|
||||
## Presentation and authority
|
||||
|
||||
FancyUI supplies the presentation. DunerealmsGUI retains the existing player
|
||||
sessions and actions; JarvisTranslator retains the central key and transaction
|
||||
checks. Buttons must invoke the same current-player action as the existing menu.
|
||||
They must not issue native give, money, claim, membership or teleport commands.
|
||||
|
||||
| Screen | Existing action owner | Required live state |
|
||||
| --- | --- | --- |
|
||||
| Imperial Codex | OrganisationMenus.console | Current player |
|
||||
| House selector | DuneGUI.select / fetch | Current House key, selected House, confirmation |
|
||||
| Mentat | DuneGUI.mentat | Current House and adviser |
|
||||
| Spacing Guild | DuneGUI.openGuild / travelMenu | House, boarding window, central bank quote, reservation |
|
||||
| Exchange | ExchangeMenus | Current catalogue revision, bank quote, durable delivery |
|
||||
| Quests / quartermaster | QuestMenus | Verified journal, prerequisites, physical turn-in |
|
||||
| Clan / company / POL | OrganisationMenus | Current deed, role, home world and claim capacity |
|
||||
|
||||
Preserve the DuneRealms green/gold theme, distinct company/POL colours, and blue
|
||||
for quests that require an ingame interaction. Reuse existing House seals,
|
||||
adviser portraits and item artwork. Dynamic text must be treated as text rather
|
||||
than interpreted MiniMessage supplied by a player.
|
||||
|
||||
## Pack and client migration
|
||||
|
||||
1. Inspect the supplied JAR and exact API signatures; pin its version and digest.
|
||||
2. Load it with PacketEvents in an isolated Paper instance first.
|
||||
3. Generate the pages and run `fui reload`, `fui pack`, then `fui packinfo`.
|
||||
4. Check the generated font/shader namespaces against the current GUI, lorecard
|
||||
and item pack. Preserve current item models, lorecards and entity textures.
|
||||
5. Publish a versioned pack with a new checksum and confirm the loaded-pack
|
||||
acknowledgement before switching the Imperial Codex entry point.
|
||||
6. Test mouse, controller/keyboard, small screens and Geyser/Floodgate. Keep the
|
||||
existing Bedrock forms until FancyUI compatibility is actually established.
|
||||
7. Roll out the verified build and pack together. Keep Jarvis actions unchanged
|
||||
and switch the remaining screens only after their actual interactions pass.
|
||||
|
||||
The creator documents `api.open`, per-player `setText`/`setVisible`/`setItem` and
|
||||
cancellable click events. These support using the existing action callbacks
|
||||
without making the page configuration a second authority or data store. Do not
|
||||
guess the API package names before inspecting the licensed JAR.
|
||||
40
DuneRealmsGUI/mcgui/README.md
Normal file
40
DuneRealmsGUI/mcgui/README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# DuneRealms market menus
|
||||
|
||||
Uses [MC GUI by resourcepack.ai](https://github.com/resourcepack-ai/mcgui),
|
||||
unmodified release 0.8.6 (`ab8df61f0fd754008a4bf5bde37dbaa6d1911be5`).
|
||||
MCGUI remains a separate plugin. Its renderer, shaders and framework are not
|
||||
bundled or renamed as DuneRealms code.
|
||||
|
||||
The shared market presentation covers the Codex, House selector, Mentat, Guild
|
||||
travel, organisation panels, quest cards, Exchange and saved item previews.
|
||||
It follows the bundled market's shelves and large selected-item showcase, with
|
||||
DuneRealms artwork, compact season logo, green/gold borders and buttons. Ingame
|
||||
quests retain their blue accent. All text is escaped; page content cannot
|
||||
introduce commands or permissions.
|
||||
|
||||
Cards select a preview. Only the showcase action button executes the existing
|
||||
menu callback. The original player/world/session gate still enforces one action.
|
||||
Purchases, research samples, quests, House changes and claims keep their existing
|
||||
Jarvis authorization and transactions. Prices are still entered through chat.
|
||||
|
||||
Enable only after installing MCGUI and its current resource pack:
|
||||
|
||||
```yaml
|
||||
# plugins/DunerealmsGUI/config.yml
|
||||
mcgui:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
The adapter is optional. Without MCGUI, a loaded pack, or on Floodgate/Bedrock,
|
||||
the current inventory menus or Bedrock forms remain available. MC GUI requires
|
||||
a 1.21.11+ server. The initial rollout is the lobby only; no world regeneration.
|
||||
|
||||
`art-manifest.json` pins existing DuneRealms PNG artwork for the runtime's
|
||||
`plugins/DunerealmsGUI/mcgui/art/` folder. Vanilla icon PNGs come from the existing
|
||||
Minecraft 1.21.8 client assets; no external browser or second Jarvis connection
|
||||
is introduced.
|
||||
|
||||
Validation uses the actual MCGUI HTML renderer, including its hit testing, plus
|
||||
the normal GUI build/session tests. An isolated Paper probe checked the current
|
||||
network inventory stream through 1.21.8 → 1.21.11 → 1.21.8 with three sample
|
||||
items. This is a compatibility sample, not a claim that every item was tested.
|
||||
92
DuneRealmsGUI/mcgui/art-manifest.json
Normal file
92
DuneRealmsGUI/mcgui/art-manifest.json
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
[
|
||||
{
|
||||
"path": "art/banner.png",
|
||||
"url": "https://www.dunerealms.com/assets/exchange-political-positions-v1.png",
|
||||
"sha256": "25284e507cc352aacc4ff7b4b59c3cb74de1eb4bd4d9e378c5eccae75f0869d6"
|
||||
},
|
||||
{
|
||||
"path": "art/clan.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/order-crysknife-v1.png",
|
||||
"sha256": "527c1b6f566ce423190b90240d6af25a8da76cb2338392d1c0ff161fd968a82c"
|
||||
},
|
||||
{
|
||||
"path": "art/company.png",
|
||||
"url": "https://www.dunerealms.com/assets/items/office_water.png",
|
||||
"sha256": "a11d9404b98834d113f97f657e333fdc92d10020e82366732d660464c609f90c"
|
||||
},
|
||||
{
|
||||
"path": "art/house.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/office-house_leader.png",
|
||||
"sha256": "f1664138efaf925b0cdd3329893cf9ac376b714c98cbe2227ee92338542122ed"
|
||||
},
|
||||
{
|
||||
"path": "art/house_atreides.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/house-aerdrecht-v1.png",
|
||||
"sha256": "6a41b52c1371d54f1b51444333851503b544af663c933110162f6bd5508d1975"
|
||||
},
|
||||
{
|
||||
"path": "art/house_corrino.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/house-korenholt-v1.png",
|
||||
"sha256": "49db2d1c6879f5802fb24dacc7f08621882f5559938434659d782e4fab286d9d"
|
||||
},
|
||||
{
|
||||
"path": "art/house_fremen.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/office-house_leader.png",
|
||||
"sha256": "f1664138efaf925b0cdd3329893cf9ac376b714c98cbe2227ee92338542122ed"
|
||||
},
|
||||
{
|
||||
"path": "art/house_harkonnen.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/house-harkveen-v1.png",
|
||||
"sha256": "cbe223385c57e7b14501f84f5d278cc24a472a833e7dda823bee4c9a02d979da"
|
||||
},
|
||||
{
|
||||
"path": "art/house_ordos.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/house-oordwijk-v1.png",
|
||||
"sha256": "fc34eb0626a9d6b17d21b385158d6c95db8665091335aae7154ba0a0919ef984"
|
||||
},
|
||||
{
|
||||
"path": "art/logo.png",
|
||||
"url": "https://www.dunerealms.com/assets/dunerealms-season-logo-v2.png",
|
||||
"sha256": "267fe0d0b5adb4f2fb657d1d6827d030e7f837c94335d0a3643210b908f47931"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-atreides-v1.png",
|
||||
"sha256": "84015c0c9bb79873e9233312cedf41582ab2e253477e0ea0ff28b5c09351ed1d"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat_atreides.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-atreides-v1.png",
|
||||
"sha256": "84015c0c9bb79873e9233312cedf41582ab2e253477e0ea0ff28b5c09351ed1d"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat_corrino.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-corrino-v1.png",
|
||||
"sha256": "d63d9accbe3d88ccadc11e47eae0611f2abb4953cf113ad45cbc920d0f1ffb0f"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat_fremen.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-fremen-v1.png",
|
||||
"sha256": "3e65c3a14cf8b1a3eb00b19befbd6a7aadf64873ceb15aca9ad104a04bb4ed95"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat_harkonnen.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-harkonnen-v1.png",
|
||||
"sha256": "c3602848e1a5f35ac4eb75eb1be64bf59922e37863d5951e7cd4f1231211c1b3"
|
||||
},
|
||||
{
|
||||
"path": "art/mentat_ordos.png",
|
||||
"url": "https://www.dunerealms.com/assets/gui/mentat-ordos-v1.png",
|
||||
"sha256": "d7db44e2bf2c5547c59deb870f52b9667ca3ba8b755edd1ccdbab77d1480e259"
|
||||
},
|
||||
{
|
||||
"path": "art/politics.png",
|
||||
"url": "https://www.dunerealms.com/assets/seals/office-landsraad.png",
|
||||
"sha256": "b66f41ae47b616bc3e79c7af463c129dedfe2fbfbabffa525be3a6e7b8fbc3c5"
|
||||
},
|
||||
{
|
||||
"path": "art/quests.png",
|
||||
"url": "https://www.dunerealms.com/assets/exchange-quests-v1.png",
|
||||
"sha256": "3c3b03cafdfd37e371fc4791183b20483a4fe9b89832d11ac207fff89c697190"
|
||||
}
|
||||
]
|
||||
|
|
@ -24,6 +24,7 @@ import java.util.function.Consumer;
|
|||
public final class DuneGUI extends JavaPlugin implements Listener,CommandExecutor {
|
||||
private HouseBridge bridge;
|
||||
private OrganisationMenus organisations;
|
||||
private MCGUIMenus modernMenus;
|
||||
private QuestMenus quests;
|
||||
private ExchangeMenus exchange;
|
||||
private ItemPreviewMenu itemPreviews;
|
||||
|
|
@ -63,6 +64,8 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
itemPreviews=new ItemPreviewMenu(this,bridge,p->guiPackLoaded.contains(p.getUniqueId()));
|
||||
organisations=new OrganisationMenus(this,bridge,p->fetch(p,null,0,null,data->mentat(p,data)),p->openGuild(p,null),p->fetch(p,null,0,null,data->select(p,data,null)),p->quests.open(p),p->exchange.open(p),p->guiPackLoaded.contains(p.getUniqueId()));
|
||||
registrar=new NamespacedKey(this,"house_registrar");
|
||||
modernMenus=new MCGUIMenus(this);
|
||||
|
||||
sidebar=new PersonalSidebar(this);nameplates=new PublicNameplates(this);
|
||||
for(String command:List.of("exchange","house","mentat","drgui","drscoreboard","guildtravel","clan","company","polgui"))Objects.requireNonNull(getCommand(command)).setExecutor(this);
|
||||
try{guild=new ExistingGuildService((p,world)->openGuild(p,world),p->exchange.open(p),p->quests.open(p),p->organisations.console(p),p->{if(!sidebar.enabled(p))sidebar.toggle(p);refreshSidebar(p);p.sendMessage("Your central bank balance appears in your personal scoreboard.");});getLogger().info("Spacing Guild lobby entry connected to current House keys and twenty-minute boarding windows.");}catch(RuntimeException unavailable){getLogger().warning("Spacing Guild travel consumer unavailable; no journeys can be booked.");}
|
||||
|
|
@ -74,7 +77,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
Bukkit.getScheduler().runTaskTimer(this,()->{for(Player p:Bukkit.getOnlinePlayers()){removeOldNavigators(p);refreshSidebar(p);}},80L,600L);
|
||||
getLogger().info("House selector and Mentat screens enabled; central J.A.R.V.I.S. bridge; no Core/Lobby replacement.");
|
||||
}
|
||||
@Override public void onDisable(){if(nameplates!=null)nameplates.close();if(exchange!=null)exchange.close();if(itemPreviews!=null)itemPreviews.close();if(quests!=null)quests.close();requests.clear();records.clear();bookings.clear();boarding.clear();if(guild!=null)guild.close();GuiSession.clear();if(sidebar!=null)sidebar.clear();for(var controller:detached.values())try{controller.restore();}catch(ReflectiveOperationException ignored){}detached.clear();if(departure!=null)departure.removeAll();for(Player p:Bukkit.getOnlinePlayers())if(p.getOpenInventory().getTopInventory().getHolder() instanceof Screen)p.closeInventory();}
|
||||
@Override public void onDisable(){if(modernMenus!=null)modernMenus.close();if(nameplates!=null)nameplates.close();if(exchange!=null)exchange.close();if(itemPreviews!=null)itemPreviews.close();if(quests!=null)quests.close();requests.clear();records.clear();bookings.clear();boarding.clear();if(guild!=null)guild.close();GuiSession.clear();if(sidebar!=null)sidebar.clear();for(var controller:detached.values())try{controller.restore();}catch(ReflectiveOperationException ignored){}detached.clear();if(departure!=null)departure.removeAll();for(Player p:Bukkit.getOnlinePlayers())if(p.getOpenInventory().getTopInventory().getHolder() instanceof Screen)p.closeInventory();}
|
||||
private boolean lobby(Player p){return p.getWorld().getName().equals("guild_lobby");}
|
||||
@Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args){
|
||||
if(sender instanceof Player player&&(command.getName().equals("exchange")||command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("exchange"))){exchange.open(player);return true;}
|
||||
|
|
@ -121,6 +124,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
button(screen,p,45,"Your Mentat","Return to your House adviser",Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
|
||||
button(screen,p,49,"Cancel booking","No fare is taken for a cancelled booking",Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
|
||||
if(guild!=null){button(screen,p,53,booked==null?"Book passage":"Review booked passage",detail,Material.EMERALD,()->bookPassage(p,data));screen.actions.put(52,screen.actions.get(53));}
|
||||
if(MCGUIMenus.show(p,"Spacing Guild · Imperial passage","",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
private void cancelBooking(Player p){boolean removed=bookings.cancel(p.getUniqueId());removed=boarding.remove(p.getUniqueId())||removed;p.sendMessage(removed?"Guild passage cancelled. No fare was charged.":"You have no pending Guild booking.");}
|
||||
|
|
@ -194,7 +198,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
}
|
||||
Screen screen=screen(p,"Choose your House",0xE300+(chosen==null?0:Arrays.asList(IDS).indexOf(chosen)+1));
|
||||
for(int i=0;i<IDS.length;i++){String id=IDS[i];int centre=CENTRES[i];boolean selected=id.equals(chosen);
|
||||
var item=icon(p,houseName(data,id),selected?"Selected · confirm below":"Click to select this House","drgui_transparent",Material.PAPER);
|
||||
var item=icon(p,houseName(data,id),selected?"Selected · confirm below":"Click to select this House","drgui_transparent",Material.PAPER);menuArt(item,"house_"+id);
|
||||
for(int row=i<3?-1:0;row<=1;row++)for(int col=-1;col<=1;col++){int slot=centre+row*9+col;screen.inventory.setItem(slot,item.clone());screen.actions.put(slot,()->select(p,data,id));}
|
||||
}
|
||||
button(screen,p,45,"Close","Return to the lobby",Material.ARROW,p::closeInventory);
|
||||
|
|
@ -202,6 +206,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
|
||||
if(chosen!=null)button(screen,p,53,"Confirm "+houseName(data,chosen),"Write your confirmed House key",Material.LIME_DYE,()->confirm(p,data,chosen));
|
||||
screen.actions.put(46,screen.actions.get(45));if(chosen!=null)screen.actions.put(52,screen.actions.get(53));
|
||||
if(MCGUIMenus.show(p,"Choose your House","",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
private void confirmForm(Player p,JsonObject data,String id){BedrockForms.show(this,p,"Confirm House · "+houseName(data,id),"Confirm your allegiance to "+houseName(data,id)+". This initial selection does not grant an elected office.",List.of(new BedrockForms.Choice("Confirm House","Save through J.A.R.V.I.S.",()->confirm(p,data,id)),new BedrockForms.Choice("Back","Review all five Houses",()->select(p,data,id))));}
|
||||
|
|
@ -214,14 +219,16 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
JsonObject mentor=data.getAsJsonObject("mentat");String name=mentor.get("name").getAsString();int index=Arrays.asList(IDS).indexOf(house);
|
||||
if(BedrockForms.isBedrock(p)){BedrockForms.show(this,p,"Your Mentat · "+name,houseName(data,house)+"\nYour House briefing is ready.",List.of(new BedrockForms.Choice("Open Mentat Report","Open your website mission journal",()->quests.open(p),"https://www.dunerealms.com/assets/gui/mentat-"+house+"-v1.png"),new BedrockForms.Choice(sidebar.enabled(p)?"Hide scoreboard":"Show scoreboard","Personal briefing display",()->{toggleSidebar(p);mentat(p,data);}),new BedrockForms.Choice("Spacing Guild travel","Book passage to your House world",()->openGuild(p,null))));return;}
|
||||
Screen screen=screen(p,"Your Mentat · "+name,0xE310+index);
|
||||
screen.inventory.setItem(13,icon(p,name,houseName(data,house),"drgui_transparent",Material.PLAYER_HEAD));
|
||||
var portrait=icon(p,name,houseName(data,house),"drgui_transparent",Material.PLAYER_HEAD);menuArt(portrait,"mentat_"+house);screen.inventory.setItem(13,portrait);
|
||||
button(screen,p,38,"Open Mentat Report","Personal level, Reputation and active quests",Material.WRITABLE_BOOK,()->quests.open(p));
|
||||
button(screen,p,42,"Spacing Guild travel","Book passage to your House world",Material.COMPASS,()->openGuild(p,null));
|
||||
button(screen,p,45,"Your House",houseName(data,house),Material.ARROW,()->select(p,data,house));
|
||||
button(screen,p,49,sidebar.enabled(p)?"Hide scoreboard":"Show scoreboard","Toggle your personal briefing",Material.LEVER,()->{toggleSidebar(p);mentat(p,data);});for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
|
||||
for(int slot:new int[]{37,39})screen.actions.put(slot,screen.actions.get(38));for(int slot:new int[]{41,43})screen.actions.put(slot,screen.actions.get(42));screen.actions.put(46,screen.actions.get(45));
|
||||
if(MCGUIMenus.show(p,"Your Mentat · "+name,"",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
private static void menuArt(ItemStack item,String artwork){var meta=item.getItemMeta();meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","menu_art"),PersistentDataType.STRING,artwork);item.setItemMeta(meta);}
|
||||
private void report(Player p){p.closeInventory();p.sendMessage(Component.text("Open your Mentat Report →",NamedTextColor.GOLD).clickEvent(net.kyori.adventure.text.event.ClickEvent.openUrl("https://clans.dunerealms.com/#quests/quests")));}
|
||||
private Screen screen(Player p,String title,int glyph){Screen s=new Screen(p);Component heading=guiPackLoaded.contains(p.getUniqueId())?Component.text(GuiArtwork.background(glyph),NamedTextColor.WHITE).font(Key.key("dunerealms:house_selector")):Component.text(title,NamedTextColor.GOLD);s.inventory=Bukkit.createInventory(s,54,heading);return s;}
|
||||
private ItemStack icon(Player p,String title,String description,String model,Material fallback){ItemStack item=new ItemStack(guiPackLoaded.contains(p.getUniqueId())?Material.PAPER:fallback);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(List.of(Component.text(description,NamedTextColor.GRAY)));if(guiPackLoaded.contains(p.getUniqueId()))meta.setItemModel(new NamespacedKey("dunerealms",model));item.setItemMeta(meta);return item;}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ final class ExchangeMenus implements Listener,AutoCloseable {
|
|||
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 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{p.openInventory(s.inventory);Bukkit.getScheduler().runTaskLater(plugin,s.gate::expire,2400L);}}
|
||||
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){
|
||||
UUID id=p.getUniqueId(),world=p.getWorld().getUID();if(pending.containsKey(id)){p.sendMessage("J.A.R.V.I.S. is processing your Exchange action.");return;}UUID token=UUID.randomUUID();pending.put(id,token);p.closeInventory();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject result=null;String error=null;try{result=bridge.exchange(id,input);}catch(Exception e){error=e.getMessage();}var response=result;String message=error;if(!plugin.isEnabled())return;Bukkit.getScheduler().runTask(plugin,()->{if(!token.equals(pending.get(id)))return;pending.remove(id);if(!p.isOnline()||!world.equals(p.getWorld().getUID()))return;if(response==null){failure.accept(message==null?"The Exchange is temporarily unavailable.":message);return;}if(response.has("rejectedStatus")){if(Set.of("buy","buy_kit").contains(input.get("action").getAsString()))retries.remove(id);failure.accept(response.has("message")?response.get("message").getAsString():"The Exchange rejected this action.");return;}success.accept(response);});});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ final class ItemPreviewMenu implements Listener {
|
|||
UUID owner=player.getUniqueId(),world=player.getWorld().getUID();if(pending.containsKey(owner))return;UUID token=UUID.randomUUID();pending.put(owner,token);player.closeInventory();player.sendMessage(Component.text("Jarvis executing matrix",NamedTextColor.GOLD));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{com.google.gson.JsonObject data=null;String error=null;try{data=bridge.itemPreview(owner,id,revision);}catch(Exception failure){error=failure instanceof java.io.IOException?failure.getMessage():"The saved item preview is unavailable. Refresh the website editor.";}var received=data;String message=error;if(!plugin.isEnabled())return;
|
||||
Bukkit.getScheduler().runTask(plugin,()->{if(!token.equals(pending.get(owner)))return;pending.remove(owner);if(!player.isOnline()||!world.equals(player.getWorld().getUID()))return;if(message!=null){player.sendMessage(Component.text(message,NamedTextColor.RED));return;}if(player.getOpenInventory().getType()!=InventoryType.CRAFTING)return;
|
||||
try{var item=bridge.buildItemPreview(player,received,panels.test(player)&&!BedrockForms.isBedrock(player));if(BedrockForms.isBedrock(player)){var plain=PlainTextComponentSerializer.plainText();String body=plain.serialize(item.getItemMeta().displayName())+"\n"+String.join("\n",item.getItemMeta().lore().stream().map(plain::serialize).toList());BedrockForms.show(plugin,player,"Saved item preview",body,List.of(new BedrockForms.Choice("Close","Return to the world",()->{})));return;}var panel=new Panel(player);panel.inventory.setItem(13,item);var close=new ItemStack(Material.BARRIER);var meta=close.getItemMeta();meta.displayName(Component.text("Close preview",NamedTextColor.GOLD));meta.lore(List.of(Component.text("This view cannot issue or withdraw items.",NamedTextColor.GRAY)));close.setItemMeta(meta);panel.inventory.setItem(22,close);player.openInventory(panel.inventory);}
|
||||
try{var item=bridge.buildItemPreview(player,received,panels.test(player)&&!BedrockForms.isBedrock(player));if(BedrockForms.isBedrock(player)){var plain=PlainTextComponentSerializer.plainText();String body=plain.serialize(item.getItemMeta().displayName())+"\n"+String.join("\n",item.getItemMeta().lore().stream().map(plain::serialize).toList());BedrockForms.show(plugin,player,"Saved item preview",body,List.of(new BedrockForms.Choice("Close","Return to the world",()->{})));return;}var panel=new Panel(player);panel.inventory.setItem(13,item);var close=new ItemStack(Material.BARRIER);var meta=close.getItemMeta();meta.displayName(Component.text("Close preview",NamedTextColor.GOLD));meta.lore(List.of(Component.text("This view cannot issue or withdraw items.",NamedTextColor.GRAY)));close.setItemMeta(meta);panel.inventory.setItem(22,close);if(MCGUIMenus.show(player,"Saved item preview","Your registered item design",panel.inventory,Map.of(22,()->{}),null))return;player.openInventory(panel.inventory);}
|
||||
catch(Exception invalid){player.sendMessage(Component.text(invalid instanceof IllegalArgumentException&&invalid.getMessage()!=null?invalid.getMessage():"This saved design cannot be previewed in the current world.",NamedTextColor.RED));}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
/** Uses MC GUI's public canvas and HTML renderer APIs; never executes page commands. */
|
||||
final class MCGUIMenus implements AutoCloseable {
|
||||
private static MCGUIMenus active;
|
||||
private final JavaPlugin plugin;
|
||||
private final Map<UUID,Session> sessions=new HashMap<>();
|
||||
private final ExecutorService drawings=Executors.newSingleThreadExecutor(r->{Thread t=new Thread(r,"DuneRealms-menu-render");t.setDaemon(true);return t;});
|
||||
private Plugin engine;private Object framework,loader,none;private Class<?> contentType,optionsType;private Object defaultOptions;
|
||||
private Method makeCanvas,openView,hasPack,pageOf,render,draw,hoverState;
|
||||
private final Path base;
|
||||
MCGUIMenus(JavaPlugin plugin){
|
||||
this.plugin=plugin;base=plugin.getDataFolder().toPath().resolve("mcgui/menu.html");
|
||||
if(!plugin.getConfig().getBoolean("mcgui.enabled",false))return;
|
||||
engine=Bukkit.getPluginManager().getPlugin("MCGUI");if(engine==null||!engine.isEnabled())return;
|
||||
try{
|
||||
ClassLoader cl=engine.getClass().getClassLoader();Class<?> api=Class.forName("ai.resourcepack.ui.framework.api.UIFramework",true,cl);
|
||||
framework=api.getMethod("get").invoke(null);makeCanvas=api.getMethod("canvas",int.class,int.class);hasPack=api.getMethod("hasPack",Player.class);
|
||||
contentType=Class.forName("ai.resourcepack.ui.framework.api.ViewContent",true,cl);optionsType=Class.forName("ai.resourcepack.ui.framework.api.ViewOptions",true,cl);
|
||||
defaultOptions=optionsType.getField("DEFAULT").get(null);openView=api.getMethod("openView",Player.class,contentType,optionsType);
|
||||
Class<?> page=Class.forName("ai.resourcepack.ui.html.Page",true,cl),load=Class.forName("ai.resourcepack.ui.html.Page$Loader",true,cl),state=Class.forName("ai.resourcepack.ui.html.css.Selector$State",true,cl),renderer=Class.forName("ai.resourcepack.ui.html.HtmlRenderer",true,cl);
|
||||
Files.createDirectories(base.getParent());loader=load.getConstructor(boolean.class,Path.class).newInstance(false,base.getParent().resolve("cache"));
|
||||
pageOf=page.getMethod("of",String.class,Path.class,load);none=state.getField("NONE").get(null);render=renderer.getMethod("render",page,int.class,int.class,double.class,double.class,state);
|
||||
for(Method m:renderer.getMethods())if(m.getName().equals("state")&&m.getParameterCount()==2)hoverState=m;
|
||||
Class<?> canvas=Class.forName("ai.resourcepack.ui.framework.api.Canvas",true,cl);draw=canvas.getMethod("draw",java.awt.image.BufferedImage.class,int.class,int.class);
|
||||
active=this;plugin.getLogger().info("MC GUI presentation connected for all DuneRealms menus; Jarvis callbacks retained.");
|
||||
}catch(Exception failure){framework=null;plugin.getLogger().warning("MC GUI adapter unavailable: "+failure.getClass().getSimpleName());}
|
||||
}
|
||||
static boolean show(Player p,String title,String description,Inventory inventory,Map<Integer,Runnable> actions,GuiSession gate){
|
||||
return active!=null&&active.present(p,title,description,inventory,actions,gate);
|
||||
}
|
||||
private boolean present(Player p,String title,String description,Inventory inventory,Map<Integer,Runnable> actions,GuiSession suppliedGate){
|
||||
if(framework==null||!engine.isEnabled()||!p.isOnline()||BedrockForms.isBedrock(p))return false;
|
||||
try{if(!Boolean.TRUE.equals(hasPack.invoke(framework,p)))return false;}catch(Exception e){return false;}
|
||||
List<MenuDocument.Card> cards=new ArrayList<>();Set<Runnable> aliases=Collections.newSetFromMap(new IdentityHashMap<>());Set<String> decorations=new HashSet<>(),transparent=new HashSet<>();
|
||||
var plain=PlainTextComponentSerializer.plainText();
|
||||
for(int slot=0;slot<inventory.getSize();slot++){
|
||||
ItemStack item=inventory.getItem(slot);if(item==null||item.getType().isAir())continue;
|
||||
var meta=item.getItemMeta();String name=MenuDocument.clean(meta!=null&&meta.hasDisplayName()?plain.serialize(meta.displayName()):item.getType().name().replace('_',' '));
|
||||
if(name.isBlank()||!actions.containsKey(slot)&&item.getType().name().endsWith("STAINED_GLASS_PANE"))continue;
|
||||
List<String> lore=meta!=null&&meta.hasLore()?meta.lore().stream().map(plain::serialize).map(MenuDocument::clean).filter(s->!s.isBlank()).toList():List.of();
|
||||
if(meta!=null&&meta.hasItemModel()&&meta.getItemModel().getKey().equals("drgui_transparent")&&!transparent.add(name+lore))continue;Runnable action=actions.get(slot);if(action!=null&&!aliases.add(action)||action==null&&!decorations.add(name+item.getType()+lore))continue;
|
||||
String material=item.getType().name().toLowerCase(Locale.ROOT),quality="";if(meta!=null){String art=meta.getPersistentDataContainer().get(new NamespacedKey("dunerealms","menu_art"),org.bukkit.persistence.PersistentDataType.STRING);if(art!=null&&art.matches("[a-z0-9_]{1,70}"))material=art;}
|
||||
if(meta!=null)for(var key:meta.getPersistentDataContainer().getKeys())if(key.getKey().equals("quality")){String value=meta.getPersistentDataContainer().get(key,org.bukkit.persistence.PersistentDataType.STRING);if(value!=null)quality=value;}
|
||||
cards.add(new MenuDocument.Card(slot,name,lore,material,item.getAmount(),action!=null,quality));
|
||||
}
|
||||
GuiSession gate=suppliedGate==null?new GuiSession(p.getUniqueId()):suppliedGate;
|
||||
Session old=sessions.remove(p.getUniqueId());if(old!=null)old.finish();
|
||||
try{
|
||||
Session s=new Session(p,title,description,cards,Map.copyOf(actions),gate);sessions.put(p.getUniqueId(),s);p.closeInventory();s.schedule();
|
||||
Bukkit.getScheduler().runTaskLater(plugin,()->{if(sessions.get(p.getUniqueId())==s){s.finish();sessions.remove(p.getUniqueId());}},2400L);return true;
|
||||
}catch(Exception failure){gate.expire();plugin.getLogger().warning("MC GUI menu unavailable: "+failure.getClass().getSimpleName());p.sendMessage("This menu is temporarily unavailable. Reopen your Imperial Codex.");return true;}
|
||||
}
|
||||
private final class Session implements InvocationHandler {
|
||||
final Player player;final UUID world;final String title,description;final List<MenuDocument.Card> cards;final Map<Integer,Runnable> actions;final GuiSession gate;final Object canvas;
|
||||
final AtomicBoolean queued=new AtomicBoolean();volatile boolean alive=true;volatile int hovered=-1;volatile int picked=-1;volatile double scroll;volatile Object frame;Object view;
|
||||
Session(Player p,String title,String description,List<MenuDocument.Card> cards,Map<Integer,Runnable> actions,GuiSession gate)throws Exception{player=p;world=p.getWorld().getUID();this.title=title;this.description=description;this.cards=List.copyOf(cards);this.actions=actions;this.gate=gate;canvas=makeCanvas.invoke(framework,12,7);}
|
||||
void schedule(){if(!alive||!queued.compareAndSet(false,true))return;drawings.submit(()->{
|
||||
int expected=hovered,selected=picked;double offset=scroll;
|
||||
try{
|
||||
String html=MenuDocument.html(title,description,player.getName(),cards,selected,base.getParent());Object page=pageOf.invoke(null,html,base,loader);
|
||||
Object paintState=none;Object document=page.getClass().getField("document").get(page);String selector=expected<=-100?"[data-pick=\""+(-100-expected)+"\"]":"[data-slot=\""+expected+"\"]";Object element=document.getClass().getMethod("selectFirst",String.class).invoke(document,selector);if(element!=null)paintState=hoverState.invoke(null,element,null);Object next=render.invoke(null,page,1536,896,1.5,offset,paintState);
|
||||
if(!alive)return;draw.invoke(canvas,next.getClass().getMethod("image").invoke(next),0,0);frame=next;
|
||||
Bukkit.getScheduler().runTask(plugin,()->{if(!current())return;if(view==null)try{Object proxy=Proxy.newProxyInstance(contentType.getClassLoader(),new Class<?>[]{contentType},this);view=openView.invoke(framework,player,proxy,defaultOptions);}catch(Exception e){finish();sessions.remove(player.getUniqueId());player.sendMessage("The menu could not open. Load the menu pack and reopen your Codex.");plugin.getLogger().warning("MC GUI view failed: "+e.getClass().getSimpleName());}});
|
||||
}catch(Exception e){if(alive)plugin.getLogger().warning("MC GUI render failed: "+e.getClass().getSimpleName());}
|
||||
finally{queued.set(false);if(alive&&(expected!=hovered||selected!=picked||offset!=scroll))schedule();}
|
||||
});}
|
||||
boolean current(){return alive&&player.isOnline()&&world.equals(player.getWorld().getUID())&&sessions.get(player.getUniqueId())==this;}
|
||||
int slot(int x,int y){Object f=frame;if(f==null)return -2;try{Object e=f.getClass().getMethod("elementAt",double.class,double.class).invoke(f,x/1.5,y/1.5);if(e==null)return -2;Object button=e.getClass().getMethod("closest",String.class).invoke(e,"[data-slot],[data-pick]");if(button==null)return -2;String action=(String)button.getClass().getMethod("attr",String.class).invoke(button,"data-slot");if(!action.isEmpty())return Integer.parseInt(action);String pick=(String)button.getClass().getMethod("attr",String.class).invoke(button,"data-pick");return -100-Integer.parseInt(pick);}catch(Exception e){return -2;}}
|
||||
public Object invoke(Object proxy,Method method,Object[] args)throws Throwable{
|
||||
switch(method.getName()){
|
||||
case "canvas":return alive?canvas:null;
|
||||
case "pointer":{int next=slot((int)args[1],(int)args[2]);if(next!=hovered){hovered=next;schedule();}return null;}
|
||||
case "click":{int slot=slot((int)args[1],(int)args[2]);if(!current())return null;if(slot<=-100){picked=-100-slot;scroll=0;schedule();return null;}if(slot==-1){finish();sessions.remove(player.getUniqueId());return null;}Runnable action=actions.get(slot);if(action!=null&&gate.claim(player.getUniqueId())){finish();sessions.remove(player.getUniqueId());Bukkit.getScheduler().runTask(plugin,()->{if(player.isOnline()&&world.equals(player.getWorld().getUID()))action.run();});}return null;}
|
||||
case "scroll":{Object f=frame;if(f!=null){double max=((Number)f.getClass().getMethod("maxScroll").invoke(f)).doubleValue();scroll=Math.max(0,Math.min(max,scroll+(int)args[3]*90));schedule();}return null;}
|
||||
case "closed":alive=false;gate.expire();sessions.remove(player.getUniqueId(),this);return null;
|
||||
case "toString":return "DuneRealms menu view";
|
||||
case "hashCode":return System.identityHashCode(proxy);
|
||||
case "equals":return proxy==args[0];
|
||||
default:return null;
|
||||
}
|
||||
}
|
||||
void finish(){alive=false;gate.expire();if(view!=null)try{Class.forName("ai.resourcepack.ui.framework.api.View",true,engine.getClass().getClassLoader()).getMethod("close").invoke(view);}catch(Exception ignored){}}
|
||||
}
|
||||
public void close(){if(active==this)active=null;for(Session s:List.copyOf(sessions.values()))s.finish();sessions.clear();drawings.shutdownNow();}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -18,6 +18,8 @@ final class OrganisationMenus implements Listener {
|
|||
private final JavaPlugin plugin;private final HouseBridge bridge;private final Consumer<Player> mentat,travel,house,quests,exchange;
|
||||
private final java.util.function.Predicate<Player> artwork;
|
||||
private final Set<UUID> busy=new HashSet<>();
|
||||
|
||||
|
||||
private static final class Panel implements InventoryHolder {
|
||||
final UUID owner;final GuiSession gate;final Map<Integer,Runnable> actions=new HashMap<>();final Map<Integer,BedrockForms.Choice> choices=new TreeMap<>();String title;boolean artwork;Inventory inventory;
|
||||
Panel(Player p){owner=p.getUniqueId();gate=new GuiSession(owner);}
|
||||
|
|
@ -89,7 +91,7 @@ final class OrganisationMenus implements Listener {
|
|||
private Panel panel(Player p,String title,int screen){if(!artwork.test(p)||BedrockForms.isBedrock(p))return panel(p,title,screen==2);var panel=new Panel(p);panel.title=title;panel.artwork=true;panel.inventory=Bukkit.createInventory(panel,54,Component.text(GuiArtwork.background(0xE340+screen),NamedTextColor.WHITE).font(net.kyori.adventure.key.Key.key("dunerealms:house_selector")));return panel;}
|
||||
private void put(Panel panel,int slot,String title,String description,Material material,Runnable action){var item=new ItemStack(panel.artwork?Material.PAPER:material);var meta=item.getItemMeta();meta.displayName(Component.text(title,NamedTextColor.GOLD));meta.lore(Arrays.stream(description.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(panel.artwork)meta.setItemModel(new NamespacedKey("dunerealms","drgui_transparent"));item.setItemMeta(meta);panel.inventory.setItem(slot,item);panel.actions.put(slot,action);if(panel.artwork&&Set.of(19,22,25,37,40,43).contains(slot))for(int alias:new int[]{slot-1,slot+1}){panel.inventory.setItem(alias,item.clone());panel.actions.put(alias,action);}panel.choices.put(slot,new BedrockForms.Choice(title,description,action));}
|
||||
private void close(Panel panel,Player p){put(panel,53,"Close","Return to the game",Material.BARRIER,p::closeInventory);}
|
||||
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,"Current organisation keys",List.copyOf(panel.choices.values()));return;}p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
|
||||
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,"Current organisation keys",List.copyOf(panel.choices.values()));return;}if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
|
||||
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!(e.getWhoClicked() instanceof Player p)||!panel.owner.equals(p.getUniqueId())||e.getClickedInventory()!=panel.inventory||e.getClick()!=ClickType.LEFT)return;var action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(p.getUniqueId()))Bukkit.getScheduler().runTask(plugin,()->{if(p.isOnline()&&p.getOpenInventory().getTopInventory()==panel.inventory)action.run();});}
|
||||
@EventHandler public void drag(InventoryDragEvent e){if(e.getView().getTopInventory().getHolder() instanceof Panel)e.setCancelled(true);}
|
||||
@EventHandler public void closed(InventoryCloseEvent e){if(e.getInventory().getHolder() instanceof Panel panel)panel.gate.expire();}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ final class QuestMenus implements Listener {
|
|||
if(action==null)panel.description+="\n\n"+title+"\n"+description;
|
||||
if(action!=null){panel.actions.put(slot,action);panel.choices.add(new BedrockForms.Choice(title,description,action));}
|
||||
}
|
||||
private void show(Player p,Panel screen){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,screen.title,screen.description,List.copyOf(screen.choices));return;}p.openInventory(screen.inventory);Bukkit.getScheduler().runTaskLater(plugin,screen.gate::expire,2400L);}
|
||||
private void show(Player p,Panel screen){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,screen.title,screen.description,List.copyOf(screen.choices));return;}if(MCGUIMenus.show(p,screen.title,screen.description,screen.inventory,screen.actions,screen.gate))return;p.openInventory(screen.inventory);Bukkit.getScheduler().runTaskLater(plugin,screen.gate::expire,2400L);}
|
||||
void close(){pending.clear();for(Player p:Bukkit.getOnlinePlayers())if(p.getOpenInventory().getTopInventory().getHolder() instanceof Panel)p.closeInventory();}
|
||||
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")));}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
name: DunerealmsGUI
|
||||
main: com.dunerealms.gui.DuneGUI
|
||||
version: 1.1.16
|
||||
version: 1.1.17
|
||||
api-version: '1.21.8'
|
||||
depend: [JarvisTranslator]
|
||||
softdepend: [DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]
|
||||
softdepend: [MCGUI, DecentHolograms, DuneLobby, DuneCore, DuneEss, DuneNPC, Vault, floodgate, ViaVersion]
|
||||
commands:
|
||||
exchange:
|
||||
description: Open the central bank Exchange to buy or sell items
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.dunerealms.gui;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class MenuDocumentTest {
|
||||
@Test void itemNamesAndLoreCannotBecomeHtmlOrCommands(){
|
||||
var card=new MenuDocument.Card(13,"<script>bad</script>",List.of("<button data-console=\"op me\">click</button>"),"../../secret",1,true,"legendary");
|
||||
String html=MenuDocument.html("Imperial Codex","<iframe>","<img>",List.of(card),13,Path.of("."));
|
||||
assertFalse(html.contains("<script>"));assertFalse(html.contains("<iframe>"));assertFalse(html.contains("<button data-console="));assertFalse(html.contains("src=\"art/../../"));assertTrue(html.contains("<script>"));assertTrue(html.contains("data-slot=\"13\""));
|
||||
}
|
||||
@Test void displayGlyphsAreRemovedWithoutLosingTextOrRomanMarks(){
|
||||
assertEquals("LEGENDARY · MK XIV",MenuDocument.clean("\uE400§6LEGENDARY · MK XIV\u0000"));
|
||||
assertEquals("First\nSecond",MenuDocument.clean("First\nSecond"));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff