Add the Imperial Codex and item archive to the opt-in viewer
This commit is contained in:
parent
f3e6fe29b0
commit
4abc909ed4
4 changed files with 108 additions and 24 deletions
|
|
@ -36,9 +36,13 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
private static final int LAST_ROW = 5, LAST_CARD_HEIGHT = 64;
|
||||
private static final Font CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 17);
|
||||
private static final Font CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 13);
|
||||
private static final int JOURNAL_LORE_LINES = 5;
|
||||
private static final Font JOURNAL_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
|
||||
private static final int FULL_CARD_LORE_LINES = 5;
|
||||
private static final Font FULL_CARD_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
|
||||
private static final Font CHECKOUT_TERMS = new Font(Font.SANS_SERIF, Font.BOLD, 15);
|
||||
private static final Font CODEX_CARD_TITLE = new Font(Font.SANS_SERIF, Font.BOLD, 13);
|
||||
private static final Font ARCHIVE_LORE = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
|
||||
private static final int ARCHIVE_COLUMN_LINES = 7;
|
||||
private static final int ARCHIVE_COLUMN_WIDTH = 177;
|
||||
private static final int PREVIOUS = -1, NEXT = -2, EMPTY = -3;
|
||||
private static final int CHECKOUT_BACK = 45, CHECKOUT_BUY = 49, CHECKOUT_CONTROLS = 2;
|
||||
private final Map<UUID, Scene> scenes = new HashMap<>();
|
||||
|
|
@ -203,6 +207,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static Page page(Document document, int index) {
|
||||
if (document.style() == Style.EXCHANGE_CHECKOUT) return checkoutPage(document, index);
|
||||
if (document.style() == Style.ITEM_ARCHIVE) return archivePage(document, index);
|
||||
var cards = document.cards();
|
||||
int capacity = capacity(document.style());
|
||||
if (cards.size() <= capacity) return new Page(0, document.style(), cards);
|
||||
|
|
@ -216,6 +221,23 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
return new Page(index, document.style(), List.copyOf(visible));
|
||||
}
|
||||
|
||||
private static Page archivePage(Document document, int index) {
|
||||
var entries = document.cards().stream().filter(card -> !card.actionable()).toList();
|
||||
var actions = document.cards().stream().filter(Card::actionable).toList();
|
||||
var visible = new ArrayList<Card>();
|
||||
var blank = new Card(EMPTY, "", List.of(), false);
|
||||
visible.add(entries.get(index)); // The reading pane is drawn separately from the interactive tiles.
|
||||
visible.add(blank);
|
||||
visible.addAll(actions);
|
||||
while (visible.size() < STANDARD_PAGE) visible.add(blank);
|
||||
if (entries.size() > 1) {
|
||||
String number = "Page " + (index + 1) + " / " + entries.size();
|
||||
visible.add(new Card(PREVIOUS, "Previous", List.of(number), index > 0));
|
||||
visible.add(new Card(NEXT, "Next", List.of(number), index + 1 < entries.size()));
|
||||
}
|
||||
return new Page(index, document.style(), List.copyOf(visible));
|
||||
}
|
||||
|
||||
private static Page checkoutPage(Document document, int index) {
|
||||
var controls = document.cards().stream()
|
||||
.filter(card -> card.slot() != CHECKOUT_BACK && card.slot() != CHECKOUT_BUY)
|
||||
|
|
@ -246,7 +268,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
scene.focus = null;
|
||||
for (int row = 0; row < ROWS; row++) {
|
||||
for (int col = 0; col < COLS; col++) {
|
||||
if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE))) continue;
|
||||
if (!initial && (row < 3 || row > 5 || col < 4 || col > 6 || (col == 5 && capacity(scene.page.style) == STANDARD_PAGE && scene.page.style != Style.ITEM_ARCHIVE))) continue;
|
||||
var map = new MapId(FIRST_SCENE_MAP + row * COLS + col);
|
||||
var image = art.getSubimage(col * 128, row * 128, 128, 128);
|
||||
var card = cardAt(scene.page, row, col);
|
||||
|
|
@ -317,6 +339,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
|
||||
private static Card cardAt(Page page, int row, int col) {
|
||||
if (row < 3 || row > LAST_ROW || col < 4 || col > 6) return null;
|
||||
if (page.style == Style.ITEM_ARCHIVE && row == 3) return null;
|
||||
if (col == 5 && (capacity(page.style) == STANDARD_PAGE || row == LAST_ROW)) return null;
|
||||
int cap = capacity(page.style);
|
||||
int index = row == LAST_ROW ? cap + (col == 4 ? 0 : 1) :
|
||||
|
|
@ -416,12 +439,13 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
draw.setColor(palette.accent);
|
||||
draw.setStroke(new BasicStroke(7));
|
||||
draw.drawRect(445, 335, 518, 374);
|
||||
draw.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 38));
|
||||
draw.setFont(styledHeadingFont(scene.document.style()));
|
||||
String heading = scene.roleplay != null ? scene.roleplay.heading :
|
||||
scene.document.style() == Style.AUTO ? "YOUR DECISIONS" : styledTitle(scene.document);
|
||||
int headlineWidth = draw.getFontMetrics().stringWidth(heading);
|
||||
draw.drawString(heading, (image.getWidth() - headlineWidth) / 2, 372);
|
||||
if (scene.roleplay != null) drawRoleplay(draw, scene);
|
||||
else if (scene.document.style() == Style.ITEM_ARCHIVE) drawArchive(draw, scene, palette);
|
||||
else if (scene.document.style() != Style.AUTO) drawStyledIdentity(draw, scene, palette);
|
||||
for (int row = 3; row <= LAST_ROW; row++) for (int col = 4; col <= 6; col++) {
|
||||
Card card = cardAt(scene.page, row, col);
|
||||
|
|
@ -453,6 +477,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
return switch (scene.document.style()) {
|
||||
case ORGANISATION -> new Palette(new Color(16, 31, 37), new Color(29, 75, 79), new Color(142, 228, 211));
|
||||
case EXCHANGE, EXCHANGE_CHECKOUT -> new Palette(new Color(42, 28, 18), new Color(91, 62, 36), new Color(245, 208, 139));
|
||||
case CODEX, ITEM_ARCHIVE -> new Palette(new Color(40, 33, 24), new Color(90, 63, 37), new Color(246, 221, 158));
|
||||
case JOURNAL -> new Palette(new Color(30, 40, 31), new Color(61, 80, 51), new Color(235, 212, 154));
|
||||
case HOUSE -> new Palette(new Color(34, 26, 39), new Color(72, 52, 79), new Color(244, 211, 152));
|
||||
case AUTO -> scene.roleplay == null
|
||||
|
|
@ -464,7 +489,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
private static boolean fitsStyled(Document document) {
|
||||
var graphics = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics();
|
||||
try {
|
||||
graphics.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 38));
|
||||
graphics.setFont(styledHeadingFont(document.style()));
|
||||
if (!wrap(graphics, styledTitle(document), 500, 1).complete) return false;
|
||||
if (document.style() == Style.EXCHANGE_CHECKOUT) {
|
||||
if (document.description().isBlank() || !hasCheckoutAction(document, CHECKOUT_BACK) ||
|
||||
|
|
@ -473,15 +498,25 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
var terms = checkoutTerms(graphics, document.description());
|
||||
if (terms.isEmpty() || terms.size() > 9) return false;
|
||||
}
|
||||
if (document.style() == Style.ITEM_ARCHIVE) {
|
||||
long actionCount = document.cards().stream().filter(Card::actionable).count();
|
||||
if (actionCount < 1 || actionCount > 2 || actionCount == document.cards().size()) return false;
|
||||
}
|
||||
graphics.setFont(CARD_TITLE);
|
||||
if (document.identity() != null && !wrap(graphics, document.identity().mentat(), 112, 2).complete) return false;
|
||||
for (Card card : document.cards()) {
|
||||
boolean seal = document.style() == Style.HOUSE && nativeArt(card.material()) != null;
|
||||
graphics.setFont(CARD_TITLE);
|
||||
if (document.style() == Style.JOURNAL) {
|
||||
if (!wrap(graphics, card.title(), 114, 2).complete) return false;
|
||||
graphics.setFont(JOURNAL_LORE);
|
||||
if (!journalLore(graphics, card).complete) return false;
|
||||
if (document.style() == Style.ITEM_ARCHIVE && !card.actionable()) {
|
||||
if (!wrap(graphics, card.title(), 368, 1).complete) return false;
|
||||
graphics.setFont(ARCHIVE_LORE);
|
||||
if (!archiveLore(graphics, card).complete) return false;
|
||||
continue;
|
||||
}
|
||||
if (usesFullCardLore(document.style())) {
|
||||
if (!fitsFullCardTitle(graphics, document.style(), card)) return false;
|
||||
graphics.setFont(FULL_CARD_LORE);
|
||||
if (!fullCardLore(graphics, card).complete) return false;
|
||||
continue;
|
||||
}
|
||||
if (!wrap(graphics, card.title(), 114, seal ? 2 : 3).complete) return false;
|
||||
|
|
@ -494,6 +529,43 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
}
|
||||
}
|
||||
|
||||
private static Font styledHeadingFont(Style style) {
|
||||
return new Font(Font.SANS_SERIF, Font.BOLD, style == Style.ITEM_ARCHIVE ? 30 : 38);
|
||||
}
|
||||
|
||||
private static boolean usesFullCardLore(Style style) {
|
||||
return style == Style.JOURNAL || style == Style.CODEX || style == Style.ITEM_ARCHIVE;
|
||||
}
|
||||
|
||||
private static boolean fitsFullCardTitle(java.awt.Graphics2D draw, Style style, Card card) {
|
||||
boolean codex = style == Style.CODEX;
|
||||
draw.setFont(codex ? CODEX_CARD_TITLE : CARD_TITLE);
|
||||
return wrap(draw, card.title(), 114, codex ? 3 : 2).complete();
|
||||
}
|
||||
|
||||
private static Wrapped archiveLore(java.awt.Graphics2D draw, Card card) {
|
||||
var entries = card.lore().stream().filter(line -> !line.matches("─+")).toList();
|
||||
return wrapLore(draw, entries, ARCHIVE_COLUMN_WIDTH, 2 * ARCHIVE_COLUMN_LINES);
|
||||
}
|
||||
|
||||
private void drawArchive(java.awt.Graphics2D draw, Scene scene, Palette palette) {
|
||||
var card = scene.page.cards.getFirst();
|
||||
draw.setColor(palette.tile);
|
||||
draw.fillRect(512, 386, 384, 123);
|
||||
draw.setColor(Color.WHITE);
|
||||
draw.setFont(CARD_TITLE);
|
||||
draw.drawString(card.title(), 520, 404);
|
||||
draw.setColor(palette.accent);
|
||||
draw.drawLine(520, 407, 888, 407);
|
||||
draw.setFont(ARCHIVE_LORE);
|
||||
var lines = archiveLore(draw, card).lines();
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
int x = 520 + i / ARCHIVE_COLUMN_LINES * 184;
|
||||
int y = 416 + i % ARCHIVE_COLUMN_LINES * draw.getFontMetrics().getHeight();
|
||||
draw.drawString(lines.get(i), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private static String styledTitle(Document document) {
|
||||
return document.style() == Style.EXCHANGE_CHECKOUT ? "Exchange checkout" : document.title();
|
||||
}
|
||||
|
|
@ -512,10 +584,14 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
return lines;
|
||||
}
|
||||
|
||||
private static Wrapped journalLore(java.awt.Graphics2D draw, Card card) {
|
||||
private static Wrapped fullCardLore(java.awt.Graphics2D draw, Card card) {
|
||||
return wrapLore(draw, card.lore(), 114, FULL_CARD_LORE_LINES);
|
||||
}
|
||||
|
||||
private static Wrapped wrapLore(java.awt.Graphics2D draw, List<String> entries, int width, int limit) {
|
||||
var lines = new ArrayList<String>();
|
||||
for (String entry : card.lore()) {
|
||||
var wrapped = wrap(draw, entry, 114, JOURNAL_LORE_LINES - lines.size());
|
||||
for (String entry : entries) {
|
||||
var wrapped = wrap(draw, entry, width, limit - lines.size());
|
||||
lines.addAll(wrapped.lines());
|
||||
if (!wrapped.complete()) return new Wrapped(lines, false);
|
||||
}
|
||||
|
|
@ -553,7 +629,7 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
draw.setColor(palette.background.darker());
|
||||
draw.fillRect(644, 389, 120, 232);
|
||||
switch (document.style()) {
|
||||
case JOURNAL -> {
|
||||
case JOURNAL, CODEX -> {
|
||||
drawResource(draw, "/mcgui/dunerealms-season-logo-v2.png", 650, 449, 108, 96);
|
||||
draw.setColor(palette.accent);
|
||||
draw.drawLine(650, 446, 758, 446);
|
||||
|
|
@ -590,15 +666,16 @@ final class PaperDecisionsScene implements DecisionsViewTransport, Listener, Aut
|
|||
if (style == Style.AUTO) return false;
|
||||
String art = nativeArt(card.material());
|
||||
draw.setColor(palette.accent);
|
||||
if (style == Style.JOURNAL) {
|
||||
if (usesFullCardLore(style)) {
|
||||
draw.drawLine(x + 7, y + 48, x + 121, y + 48);
|
||||
draw.setColor(Color.WHITE);
|
||||
draw.setFont(CARD_TITLE);
|
||||
writeWrapped(draw, card.title(), x + 7, y + 21, 114, 2);
|
||||
boolean codex = style == Style.CODEX;
|
||||
draw.setFont(codex ? CODEX_CARD_TITLE : CARD_TITLE);
|
||||
writeWrapped(draw, card.title(), x + 7, y + (codex ? 15 : 21), 114, codex ? 3 : 2);
|
||||
draw.setColor(palette.accent);
|
||||
draw.setFont(JOURNAL_LORE);
|
||||
draw.setFont(FULL_CARD_LORE);
|
||||
int lineY = y + 64;
|
||||
for (String line : journalLore(draw, card).lines()) {
|
||||
for (String line : fullCardLore(draw, card).lines()) {
|
||||
draw.drawString(line, x + 7, lineY);
|
||||
lineY += draw.getFontMetrics().getHeight();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public interface DecisionsViewTransport {
|
|||
}
|
||||
}
|
||||
|
||||
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL }
|
||||
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE }
|
||||
record Identity(String logo, String mentat, int portrait) {}
|
||||
|
||||
record Document(String title, String description, List<Card> cards, Style style, Identity identity) {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,18 @@ 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);if(MCGUIMenus.show(player,"Saved item preview","Your registered item design",panel.inventory,Map.of(22,()->{}),null))return;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);Map<Integer,Runnable> actions=Map.of(22,()->{});if(showNative(player,panel,item,actions))return;if(MCGUIMenus.show(player,"Saved item preview","Your registered item design",panel.inventory,actions,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));}
|
||||
});
|
||||
});
|
||||
}
|
||||
private boolean showNative(Player player,Panel panel,ItemStack item,Map<Integer,Runnable> actions){
|
||||
var meta=item.getItemMeta();
|
||||
if(meta.hasItemModel()||meta instanceof org.bukkit.inventory.meta.ArmorMeta armor&&armor.hasTrim())return false;
|
||||
return NativeMenus.show(plugin,player,"development.fullscreen-codex-viewers","Saved item preview",
|
||||
"Your registered item design",panel.inventory,actions,new GuiSession(panel.owner),
|
||||
DecisionsViewTransport.Style.ITEM_ARCHIVE,null);
|
||||
}
|
||||
@EventHandler(priority=EventPriority.HIGHEST) public void click(InventoryClickEvent event){if(!(event.getView().getTopInventory().getHolder() instanceof Panel panel))return;event.setCancelled(true);if(event.getWhoClicked() instanceof Player player&&panel.owner.equals(player.getUniqueId())&&event.getRawSlot()==22)Bukkit.getScheduler().runTask(plugin,()->{if(player.isOnline()&&player.getOpenInventory().getTopInventory()==panel.inventory)player.closeInventory();});}
|
||||
@EventHandler(priority=EventPriority.HIGHEST) public void drag(InventoryDragEvent event){if(event.getView().getTopInventory().getHolder() instanceof Panel)event.setCancelled(true);}
|
||||
@EventHandler public void quit(PlayerQuitEvent event){pending.remove(event.getPlayer().getUniqueId());}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ final class OrganisationMenus implements Listener {
|
|||
|
||||
|
||||
private static final class Panel implements DuneMenuInventory {
|
||||
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;MenuDocument.Branding branding;
|
||||
final UUID owner;final GuiSession gate;final Map<Integer,Runnable> actions=new HashMap<>();final Map<Integer,BedrockForms.Choice> choices=new TreeMap<>();String title;DecisionsViewTransport.Style nativeStyle;boolean artwork;Inventory inventory;MenuDocument.Branding branding;
|
||||
Panel(Player p){owner=p.getUniqueId();gate=new GuiSession(owner);}
|
||||
public Inventory getInventory(){return inventory;}
|
||||
}
|
||||
OrganisationMenus(JavaPlugin plugin,HouseBridge bridge,Consumer<Player> mentat,Consumer<Player> travel,Consumer<Player> house,Consumer<Player> quests,Consumer<Player> decisions,Consumer<Player> exchange,Consumer<Player> spice,java.util.function.Predicate<Player> artwork){this.plugin=plugin;this.bridge=bridge;this.mentat=mentat;this.travel=travel;this.house=house;this.quests=quests;this.decisions=decisions;this.exchange=exchange;this.spice=spice;this.artwork=artwork;Bukkit.getPluginManager().registerEvents(this,plugin);}
|
||||
void console(Player p){var panel=panel(p,"Imperial Codex",0);put(panel,8,"Emergency rescue · 1,000 DM","Teleport to safety and heal · 24-hour cooldown",Material.TOTEM_OF_UNDYING,()->p.performCommand("duneess:rescue"));if(p.getWorld().getName().equals("arrakis"))put(panel,28,"Spice buyers","Spacing Guild · Smuggler · P&O payout",Material.ORANGE_DYE,()->spice.accept(p));put(panel,34,"Exchange","Buy, sell and collect your purchases",Material.CHEST,()->exchange.accept(p));var exchangeIcon=new ItemStack(Material.CHEST);var exchangeMeta=exchangeIcon.getItemMeta();exchangeMeta.displayName(Component.text("Exchange",NamedTextColor.GOLD));exchangeMeta.lore(List.of(Component.text("Buy · Sell · Add held item",NamedTextColor.GRAY)));exchangeIcon.setItemMeta(exchangeMeta);panel.inventory.setItem(34,exchangeIcon);put(panel,31,"Mission journal","Personal Experience and Reputation",Material.WRITABLE_BOOK,()->quests.accept(p));put(panel,32,"Decisions","Your current J.A.R.V.I.S. decisions",Material.ENCHANTED_BOOK,()->decisions.accept(p));put(panel,4,"Item lore archive","Preview the shared item lore cards",Material.WRITABLE_BOOK,()->lore(p));put(panel,19,"Clan","Your clan and Home Block",Material.GREEN_BANNER,()->open(p,"clans"));put(panel,22,"Company","Your companies and Home Blocks",Material.CYAN_BANNER,()->open(p,"companies"));put(panel,25,"POL","Your current political offices",Material.PURPLE_BANNER,()->open(p,"offices"));put(panel,37,"Your Mentat","Your personal briefing",Material.BOOK,()->mentat.accept(p));put(panel,40,"Spacing Guild","Transport and boarding windows",Material.COMPASS,()->travel.accept(p));put(panel,43,"Your House","Your allegiance and adviser",Material.NETHER_STAR,()->house.accept(p));close(panel,p);show(p,panel);}
|
||||
void console(Player p){var panel=panel(p,"Imperial Codex",0);panel.nativeStyle=DecisionsViewTransport.Style.CODEX;put(panel,8,"Emergency rescue · 1,000 DM","Teleport to safety and heal · 24-hour cooldown",Material.TOTEM_OF_UNDYING,()->p.performCommand("duneess:rescue"));if(p.getWorld().getName().equals("arrakis"))put(panel,28,"Spice buyers","Spacing Guild · Smuggler · P&O payout",Material.ORANGE_DYE,()->spice.accept(p));put(panel,34,"Exchange","Buy, sell and collect your purchases",Material.CHEST,()->exchange.accept(p));var exchangeIcon=new ItemStack(Material.CHEST);var exchangeMeta=exchangeIcon.getItemMeta();exchangeMeta.displayName(Component.text("Exchange",NamedTextColor.GOLD));exchangeMeta.lore(List.of(Component.text("Buy · Sell · Add held item",NamedTextColor.GRAY)));exchangeIcon.setItemMeta(exchangeMeta);panel.inventory.setItem(34,exchangeIcon);put(panel,31,"Mission journal","Personal Experience and Reputation",Material.WRITABLE_BOOK,()->quests.accept(p));put(panel,32,"Decisions","Your current J.A.R.V.I.S. decisions",Material.ENCHANTED_BOOK,()->decisions.accept(p));put(panel,4,"Item lore archive","Preview the shared item lore cards",Material.WRITABLE_BOOK,()->lore(p));put(panel,19,"Clan","Your clan and Home Block",Material.GREEN_BANNER,()->open(p,"clans"));put(panel,22,"Company","Your companies and Home Blocks",Material.CYAN_BANNER,()->open(p,"companies"));put(panel,25,"POL","Your current political offices",Material.PURPLE_BANNER,()->open(p,"offices"));put(panel,37,"Your Mentat","Your personal briefing",Material.BOOK,()->mentat.accept(p));put(panel,40,"Spacing Guild","Transport and boarding windows",Material.COMPASS,()->travel.accept(p));put(panel,43,"Your House","Your allegiance and adviser",Material.NETHER_STAR,()->house.accept(p));close(panel,p);show(p,panel);}
|
||||
void open(Player p,String kind){
|
||||
if(!busy.add(p.getUniqueId()))return;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,()->{JsonObject data=null;try{data=bridge.organisations(p.getUniqueId());}catch(Exception ignored){}JsonObject result=data;if(!plugin.isEnabled())return;
|
||||
|
|
@ -96,7 +96,7 @@ final class OrganisationMenus implements Listener {
|
|||
});
|
||||
}
|
||||
void lore(Player p){
|
||||
var panel=panel(p,"Item lore archive · Preview",false);String[] kinds={"MENU","EQUIPMENT","KIT","COMPONENT","TICKET","CASH","RIHLA","DEED","QUEST"};Material[] materials={Material.COMPASS,Material.IRON_SWORD,Material.CHEST,Material.AMETHYST_SHARD,Material.PAPER,Material.GOLD_NUGGET,Material.WRITABLE_BOOK,Material.MAP,Material.BOOK};
|
||||
var panel=panel(p,"Item lore archive · Preview",false);panel.nativeStyle=DecisionsViewTransport.Style.ITEM_ARCHIVE;String[] kinds={"MENU","EQUIPMENT","KIT","COMPONENT","TICKET","CASH","RIHLA","DEED","QUEST"};Material[] materials={Material.COMPASS,Material.IRON_SWORD,Material.CHEST,Material.AMETHYST_SHARD,Material.PAPER,Material.GOLD_NUGGET,Material.WRITABLE_BOOK,Material.MAP,Material.BOOK};
|
||||
for(int i=0;i<kinds.length;i++){String kind=kinds[i];Map<String,String> facts=switch(kind){case "EQUIPMENT"->Map.of("Grade","From issued equipment key","House","From House key","Durability","From actual item");case "KIT"->Map.of("Contents","From kit definition","State","Design preview");case "COMPONENT"->Map.of("Recipe","From crafting definition");case "TICKET"->Map.of("Route","From passage key","Departure",":00 / :20 / :40");case "CASH"->Map.of("Value","From bank withdrawal","State","Design preview");case "RIHLA"->Map.of("Recipient","From RIA key","Amount","From transfer record");case "DEED"->Map.of("Organisation","From registered deed","Holder","From current authority");case "QUEST"->Map.of("Objective","From mission key","Progress","From verified events");default->Map.of("Service","DuneRealms","Access","Current JARVIS keys");};try{panel.inventory.setItem(18+i,bridge.lorePreview(kind,materials[i],kind.replace('_',' '),facts));}catch(Exception unavailable){p.sendMessage("The lore renderer is temporarily unavailable.");return;}}
|
||||
put(panel,45,"Back","Imperial Codex",Material.ARROW,()->console(p));close(panel,p);show(p,panel);
|
||||
}
|
||||
|
|
@ -223,7 +223,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){brandingRequests.remove(p.getUniqueId());if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.branding==null||panel.branding.mentat().isEmpty()?"Current organisation keys":"Mentat · "+panel.branding.mentat(),List.copyOf(panel.choices.values()));return;}if(panel.branding!=null&&NativeMenus.show(plugin,p,"development.fullscreen-organisation-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.ORGANISATION,panel.branding))return;if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate,panel.branding))return;p.openInventory(panel.inventory);Bukkit.getScheduler().runTaskLater(plugin,panel.gate::expire,2400L);}
|
||||
private void show(Player p,Panel panel){brandingRequests.remove(p.getUniqueId());if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.branding==null||panel.branding.mentat().isEmpty()?"Current organisation keys":"Mentat · "+panel.branding.mentat(),List.copyOf(panel.choices.values()));return;}if(panel.nativeStyle!=null&&NativeMenus.show(plugin,p,"development.fullscreen-codex-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,panel.nativeStyle,null))return;if(panel.branding!=null&&NativeMenus.show(plugin,p,"development.fullscreen-organisation-viewers",panel.title,"",panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.ORGANISATION,panel.branding))return;if(MCGUIMenus.show(p,panel.title,"Current organisation keys",panel.inventory,panel.actions,panel.gate,panel.branding))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();}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff