forked from unimatrix/web
Offer opt-in fullscreen Guild travel, spice sales and war reports
This commit is contained in:
parent
4abc909ed4
commit
37dc50d850
5 changed files with 106 additions and 28 deletions
|
|
@ -19,7 +19,7 @@ public interface DecisionsViewTransport {
|
|||
}
|
||||
}
|
||||
|
||||
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE }
|
||||
enum Style { AUTO, ORGANISATION, EXCHANGE, EXCHANGE_CHECKOUT, HOUSE, JOURNAL, CODEX, ITEM_ARCHIVE, GUILD, SPICE }
|
||||
record Identity(String logo, String mentat, int portrait) {}
|
||||
|
||||
record Document(String title, String description, List<Card> cards, Style style, Identity identity) {
|
||||
|
|
|
|||
|
|
@ -184,11 +184,39 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
|
|||
String quote="Guild fare: "+String.format(java.util.Locale.ROOT,"%.2f",data.getAsJsonObject("guildQuote").get("fareMinor").getAsInt()/100.0)+" DM from your central personal bank account. Collected after arrival."+(data.getAsJsonObject("guildQuote").has("subsidyMinor")?" Guild subsidy: "+String.format(java.util.Locale.ROOT,"%.2f",data.getAsJsonObject("guildQuote").get("subsidyMinor").getAsInt()/100.0)+" DM.":"");
|
||||
var booked=bookings.get(p.getUniqueId());String detail=quote+"\nTravel opens at :00, :20 and :40 for five minutes."+(booked==null?"":"\nYour passage is already booked.");
|
||||
if(BedrockForms.isBedrock(p)){List<BedrockForms.Choice> choices=new ArrayList<>();for(var route:GuildRoutes.ALL){boolean allowed=quotedDestinations(data.getAsJsonObject("guildQuote")).contains(route.world());choices.add(new BedrockForms.Choice((allowed?"§6":"§8")+route.name()+(allowed?(route.house().equals(house)?" · Your House":" · Imperial passage"):" · Unavailable"),allowed?detail:"Another House world",allowed?()->bookPassage(p,data,route.world()):()->travelMenu(p,data),"https://www.dunerealms.com/assets/gui/guild-world-"+route.world().replace('_','-')+(allowed?"":"-locked")+"-v1.png"));}choices.add(new BedrockForms.Choice("Cancel booking","No fare has been charged",()->{cancelBooking(p);travelMenu(p,data);}));choices.add(new BedrockForms.Choice("Your Mentat","Return to your House adviser",()->mentat(p,data)));BedrockForms.show(this,p,"Spacing Guild · Imperial passage",detail,choices);return;}
|
||||
int own=Arrays.asList(IDS).indexOf(house);Screen screen=screen(p,"Spacing Guild · Imperial passage",0xE330+own);
|
||||
for(int i=0;i<GuildRoutes.ALL.size();i++){var route=GuildRoutes.ALL.get(i);boolean allowed=quotedDestinations(data.getAsJsonObject("guildQuote")).contains(route.world());var item=icon(p,route.name(),allowed?detail:"Unavailable · another House world","drgui_transparent",allowed?Material.ENDER_PEARL:Material.GRAY_DYE);int centre=CENTRES[i];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());if(allowed)screen.actions.put(slot,()->bookPassage(p,data,route.world()));}}
|
||||
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));}
|
||||
String title="Spacing Guild · Imperial passage";
|
||||
int own=Arrays.asList(IDS).indexOf(house);Screen screen=screen(p,title,0xE330+own);
|
||||
var allowedDestinations=quotedDestinations(data.getAsJsonObject("guildQuote"));
|
||||
var routeCards=new ArrayList<DecisionsViewTransport.Card>();
|
||||
for(int i=0;i<GuildRoutes.ALL.size();i++){
|
||||
var route=GuildRoutes.ALL.get(i);boolean allowed=allowedDestinations.contains(route.world());
|
||||
String unavailable="Unavailable · another House world";
|
||||
var item=icon(p,route.name(),allowed?detail:unavailable,"drgui_transparent",allowed?Material.ENDER_PEARL:Material.GRAY_DYE);
|
||||
int centre=CENTRES[i];
|
||||
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());
|
||||
if(allowed)screen.actions.put(slot,()->bookPassage(p,data,route.world()));
|
||||
}
|
||||
routeCards.add(new DecisionsViewTransport.Card(centre,route.name(),List.of(allowed?
|
||||
(route.house().equals(house)?"Your House":"Imperial passage"):unavailable),allowed,
|
||||
"guild_world_"+route.world()+(allowed?"":"_locked")));
|
||||
}
|
||||
String cancellation="No fare is taken for a cancelled booking";
|
||||
String adviser="Return to your House adviser";
|
||||
button(screen,p,45,"Your Mentat",adviser,Material.ARROW,()->mentat(p,data));screen.actions.put(46,screen.actions.get(45));
|
||||
routeCards.add(new DecisionsViewTransport.Card(45,"Your Mentat",List.of(adviser),true));
|
||||
button(screen,p,49,"Cancel booking",cancellation,Material.BARRIER,()->{cancelBooking(p);travelMenu(p,data);});
|
||||
for(int slot:new int[]{48,50})screen.actions.put(slot,screen.actions.get(49));
|
||||
routeCards.add(new DecisionsViewTransport.Card(49,"Cancel booking",List.of(cancellation),true));
|
||||
if(guild!=null){
|
||||
String bookingLabel=booked==null?"Book passage":"Review booked passage";
|
||||
button(screen,p,53,bookingLabel,detail,Material.EMERALD,()->bookPassage(p,data));screen.actions.put(52,screen.actions.get(53));
|
||||
routeCards.add(new DecisionsViewTransport.Card(53,bookingLabel,List.of(),true));
|
||||
}
|
||||
String nativeDetail=detail;
|
||||
if(booked!=null)nativeDetail+="\nBooked to "+booked.world()+" · "+String.format(Locale.ROOT,"%.2f DM",booked.fare()/100.0);
|
||||
if(NativeMenus.showGuild(this,p,title,nativeDetail,routeCards,screen.actions,screen.gate))return;
|
||||
if(MCGUIMenus.show(p,"Spacing Guild · Imperial passage","",screen.inventory,screen.actions,screen.gate))return;
|
||||
p.openInventory(screen.inventory);expire(screen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.dunerealms.gui;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
|
@ -19,6 +20,20 @@ final class NativeMenus {
|
|||
if (transport == null) return false;
|
||||
var cards = MCGUIMenus.cards(inventory, actions).stream().map(card ->
|
||||
new DecisionsViewTransport.Card(card.slot(), card.title(), card.lore(), card.action(), card.material())).toList();
|
||||
return show(player, plugin, transport, title, description, cards, actions, gate, style, branding);
|
||||
}
|
||||
|
||||
static boolean showGuild(JavaPlugin plugin, Player player, String title, String description,
|
||||
List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions, GuiSession gate) {
|
||||
if (!plugin.getConfig().getStringList("development.fullscreen-guild-viewers").contains(player.getUniqueId().toString())) return false;
|
||||
var transport = Bukkit.getServicesManager().load(DecisionsViewTransport.class);
|
||||
return transport != null && show(player, plugin, transport, title, description, cards, actions, gate,
|
||||
DecisionsViewTransport.Style.GUILD, null);
|
||||
}
|
||||
|
||||
private static boolean show(Player player, JavaPlugin plugin, DecisionsViewTransport transport, String title,
|
||||
String description, List<DecisionsViewTransport.Card> cards, Map<Integer,Runnable> actions,
|
||||
GuiSession gate, DecisionsViewTransport.Style style, MenuDocument.Branding branding) {
|
||||
var identity = branding == null ? null :
|
||||
new DecisionsViewTransport.Identity(branding.logo(), branding.mentat(), branding.portrait());
|
||||
var document = new DecisionsViewTransport.Document(title, description, cards, style, identity);
|
||||
|
|
|
|||
|
|
@ -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;DecisionsViewTransport.Style nativeStyle;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;String nativeSetting;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);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 console(Player p){var panel=panel(p,"Imperial Codex",0);panel.nativeStyle=DecisionsViewTransport.Style.CODEX;panel.nativeSetting="development.fullscreen-codex-viewers";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);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};
|
||||
var panel=panel(p,"Item lore archive · Preview",false);panel.nativeStyle=DecisionsViewTransport.Style.ITEM_ARCHIVE;panel.nativeSetting="development.fullscreen-codex-viewers";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);
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ final class OrganisationMenus implements Listener {
|
|||
});
|
||||
}
|
||||
private void warStatus(Player p,Runnable back){
|
||||
var screen=panel(p,"War report",false);JsonObject result;
|
||||
var screen=panel(p,"War report",false);screen.nativeStyle=DecisionsViewTransport.Style.JOURNAL;screen.nativeSetting="development.fullscreen-organisation-viewers";JsonObject result;
|
||||
try{result=bridge.warReport(p.getUniqueId());}catch(Exception unavailable){p.sendMessage("War reports are temporarily unavailable.");return;}
|
||||
var campaigns=result.getAsJsonArray("campaigns");
|
||||
if(campaigns==null||campaigns.isEmpty())put(screen,22,"No active deployment","No current roster lease.\nArrange wars through your Clan or POL control panel.",Material.MAP,()->warStatus(p,back));
|
||||
|
|
@ -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.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);}
|
||||
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,panel.nativeSetting,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();}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ final class SpiceMenus implements Listener {
|
|||
private void recover(Player p){if(!arrakis(p))return;call(p,action("pending"),data->recoverNext(p,data.getAsJsonArray("pending").asList().stream().map(v->UUID.fromString(v.getAsString())).toList(),0));}
|
||||
private void recoverNext(Player p,List<UUID> ids,int index){if(!arrakis(p))return;if(index>=ids.size()){p.sendMessage(ids.isEmpty()?"No spice payments are waiting.":"Pending spice payments processed.");return;}var q=action("settle");q.addProperty("requestId",ids.get(index).toString());call(p,q,data->recoverNext(p,ids,index+1));}
|
||||
private static void put(Panel panel,int slot,Material material,String name,String lore,Runnable action,String art){var item=new ItemStack(material);var meta=item.getItemMeta();meta.displayName(Component.text(name,NamedTextColor.GOLD));meta.lore(Arrays.stream(lore.split("\n")).map(line->Component.text(line,NamedTextColor.GRAY)).toList());if(art!=null)meta.getPersistentDataContainer().set(new NamespacedKey("dunerealms","menu_art"),org.bukkit.persistence.PersistentDataType.STRING,art);item.setItemMeta(meta);panel.inventory.setItem(slot,item);if(action!=null)panel.actions.put(slot,action);}
|
||||
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){var choices=panel.actions.entrySet().stream().map(entry->new BedrockForms.Choice(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(panel.inventory.getItem(entry.getKey()).getItemMeta().displayName()),"",entry.getValue())).toList();BedrockForms.show(plugin,p,"Arrakis · Spice buyer","P&O pays your personal bank account",choices);return;}if(!MCGUIMenus.show(p,"Arrakis · Spice buyer","Guild trade and quest-authorised smuggling",panel.inventory,panel.actions,panel.gate))p.openInventory(panel.inventory);}
|
||||
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){var choices=panel.actions.entrySet().stream().map(entry->new BedrockForms.Choice(net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(panel.inventory.getItem(entry.getKey()).getItemMeta().displayName()),"",entry.getValue())).toList();BedrockForms.show(plugin,p,"Arrakis · Spice buyer","P&O pays your personal bank account",choices);return;}if(NativeMenus.show(plugin,p,"development.fullscreen-spice-viewers","Arrakis · Spice buyer","",
|
||||
panel.inventory,panel.actions,panel.gate,DecisionsViewTransport.Style.SPICE,null))return;if(!MCGUIMenus.show(p,"Arrakis · Spice buyer","Guild trade and quest-authorised smuggling",panel.inventory,panel.actions,panel.gate))p.openInventory(panel.inventory);}
|
||||
@EventHandler public void click(InventoryClickEvent e){if(!(e.getView().getTopInventory().getHolder() instanceof Panel panel))return;e.setCancelled(true);if(!panel.owner.equals(e.getWhoClicked().getUniqueId()))return;Runnable action=panel.actions.get(e.getRawSlot());if(action!=null&&panel.gate.claim(e.getWhoClicked().getUniqueId()))Bukkit.getScheduler().runTask(plugin,action);}
|
||||
@EventHandler public void drag(InventoryDragEvent e){if(e.getView().getTopInventory().getHolder() instanceof Panel)e.setCancelled(true);}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff