Grade spice recipes and expose the in-game Cookbook
Some checks failed
DuneRealms Plugin CI / plugins (push) Has been cancelled
Spice Cookers and Rails Build / spice-cookers-rails (push) Has been cancelled

This commit is contained in:
unimatrixgit 2026-12-03 22:18:04 +01:00
commit ac8ac24584
12 changed files with 252 additions and 34 deletions

View file

@ -36,10 +36,12 @@ jobs:
git -C "$build/rails" apply "$PWD/vendor/minecart-trains/spice-coal.patch"
curl --fail --location --retry 2 https://cdn.modrinth.com/data/PSN4XhQK/versions/G2YwbBLw/PuddingAPI-2611162255.jar -o "$build/PuddingAPI-2611162255.jar"
(cd "$build" && printf '%s PuddingAPI-2611162255.jar\n' 8c6504f09e6d7b384a4a2651ed33a1b28c7b41a4e42aff89f0e459524697e304 | sha256sum --check)
gradle --no-daemon -p JarvisConnector test jar
for module in JarvisConnector DuneRealmsGUI DuneMenus; do
gradle --no-daemon -p "$module" test jar
done
gradle --no-daemon -p vendor/minecart-trains jar "-PrailsSource=$build/rails" "-PpuddingJar=$build/PuddingAPI-2611162255.jar"
python3 tools/build-unified-resourcepack.py --source "$GITHUB_SHA" --output "$build/resource-validation.zip"
python3 tools/plugin_spice_cookers.py extract network/resource-pack/central/overlay JarvisConnector/build/libs/jarvistranslator.jar spice-rail-artifacts
python3 tools/plugin_spice_cookers.py extract network/resource-pack/central/overlay JarvisConnector/build/libs/jarvistranslator.jar DuneRealmsGUI/build/libs/DunerealmsGUI.jar DuneMenus/build/libs/DuneMenus.jar spice-rail-artifacts
cp vendor/minecart-trains/build/libs/MinecartTrains-1.4.3-dune1.jar "$build/PuddingAPI-2611162255.jar" spice-rail-artifacts/
cp vendor/minecart-trains/{build.gradle.kts,settings.gradle.kts,spice-coal.patch} "$build/rails/"
tar -czf spice-rail-artifacts/MinecartTrains-1.4.3-dune1-source.tar.gz -C "$build/rails" LICENSE README.md pom.xml build.gradle.kts settings.gradle.kts spice-coal.patch src

View file

@ -35,7 +35,7 @@ final class HubMenu extends Menu {
door(25, Material.BLAZE_POWDER, "<#e07b2e><b>Spice", "Sell and collect", "spice");
door(28, Material.PLAYER_HEAD, "<#eed49a><b>Your Mentat", "House briefing and missions", "mentat");
door(29, Material.GOLD_BLOCK, "<#f2c94c><b>Imperial Postbank", "Your account", "bank");
door(31, Material.BOOK, "<#eed49a><b>Item lore archive", "Preview issued item cards", "lore");
door(31, Material.BOOK, "<#eed49a><b>Cookbook", "Crafting recipes and grades", "cookbook");
door(33, Material.LIGHTNING_ROD, "<#7fd6e8><b>ATM", "Quick deposit and withdrawal", "atm");
}
}

View file

@ -2,7 +2,7 @@ package com.dunerealms.menus;
import java.util.Set;import org.bukkit.entity.Player;
/** Only the presentation changes; original JARVIS/native service callbacks own behaviour. */
final class NativeServiceMenu extends Menu {
static final Set<String> IDS=Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","lore","mentat","house","equipment");
static final Set<String> IDS=Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","lore","cookbook","mentat","house","equipment");
private final String target;
NativeServiceMenu(DuneMenusPlugin plugin,Player player,Menu parent,String target){super(plugin,player,parent);this.target=target;}
@Override boolean launchNative(){plugin.openNativeService(player,target);return true;}

View file

@ -9,5 +9,5 @@ class RetainedNativeMenusAbiTest {
@Test void retainedCurrentCloseAndChoiceFacadeArePresent()throws Exception{
assertEquals(boolean.class,DuneMenusPlugin.class.getMethod("isCurrent",Player.class,Inventory.class).getReturnType());assertEquals(void.class,DuneMenusPlugin.class.getMethod("close",Player.class,Inventory.class).getReturnType());assertEquals(boolean.class,DuneMenusPlugin.class.getMethod("showChoices",JavaPlugin.class,Player.class,String.class,String.class,List.class).getReturnType());
}
@Test void allPublicServiceRoutesHaveNativeEntriesInsteadOfPartialAlternateBackends(){assertEquals(Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","lore","mentat","house","equipment"),NativeServiceMenu.IDS);}
@Test void allPublicServiceRoutesHaveNativeEntriesInsteadOfPartialAlternateBackends(){assertEquals(Set.of("hub","travel","exchange","clan","company","missions","spice","war","politics","lore","cookbook","mentat","house","equipment"),NativeServiceMenu.IDS);}
}

View file

@ -15,3 +15,6 @@ tasks.test { useJUnitPlatform() }
tasks.jar { archiveFileName.set("DunerealmsGUI.jar") }
sourceSets.main { java.srcDir("../citizens-common/src/main/java") }
tasks.processResources {
from(rootProject.file("../network/content-assets/cookbook/spice-crafting.json"))
}

View file

@ -0,0 +1,42 @@
package com.dunerealms.gui;
import com.google.gson.JsonParser;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.plugin.java.JavaPlugin;
final class CookbookCatalog {
private static final List<String> ROMAN = List.of("0", "I", "II", "III", "IV", "V");
record Recipe(String id, String name, Material material, int mark, String quality, String ingredients, String details) {
String grade() { return quality + " · MK " + ROMAN.get(mark); }
}
private CookbookCatalog() {}
static List<Recipe> load(JavaPlugin plugin) {
try (var source = plugin.getResource("spice-crafting.json")) {
if (source == null) throw new IllegalStateException("Cookbook resource missing");
var records = JsonParser.parseReader(new InputStreamReader(source, StandardCharsets.UTF_8)).getAsJsonArray();
List<Recipe> recipes = new ArrayList<>();
for (var entry : records) {
var row = entry.getAsJsonObject();
String quality = row.get("quality").getAsString();
quality = quality.substring(0, 1).toUpperCase(Locale.ROOT) + quality.substring(1);
int mark = row.get("mark").getAsInt();
if (mark < 0 || mark >= ROMAN.size()) throw new IllegalStateException("Unsupported Cookbook mark");
recipes.add(new Recipe(row.get("id").getAsString(), row.get("name").getAsString(),
Material.valueOf(row.get("material").getAsString()), mark, quality.replace('_', ' '),
row.get("ingredients").getAsString(), row.get("details").getAsString()));
}
return List.copyOf(recipes);
} catch (Exception failure) {
plugin.getLogger().warning("Spice Cookbook could not load: " + failure.getClass().getSimpleName());
return List.of();
}
}
}

View file

@ -101,7 +101,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length>0&&args[0].equalsIgnoreCase("previewitem")){try{if(args.length!=3)throw new IllegalArgumentException();int revision=Integer.parseInt(args[2]);if(revision<1||revision>999999)throw new IllegalArgumentException();itemPreviews.open(player,UUID.fromString(args[1]),revision);}catch(IllegalArgumentException invalid){player.sendMessage("Use /drgui previewitem <saved-design-id> <revision>");}return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("quests")){quests.open(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==2&&args[0].equalsIgnoreCase("movenpc")){polQuestNpcs.move(player,args[1]);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("lore")){organisations.lore(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&(args[0].equalsIgnoreCase("lore")||args[0].equalsIgnoreCase("cookbook"))){organisations.cookbook(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==0){organisations.console(player);return true;}
if(sender instanceof Player player&&command.getName().equals("drgui")&&args.length==1&&args[0].equalsIgnoreCase("item")){giveCodex(player,true);return true;}
if(sender instanceof Player member&&List.of("clan","company","polgui").contains(command.getName())){organisations.open(member,command.getName().equals("clan")?"clans":command.getName().equals("company")?"companies":"offices");return true;}
@ -311,7 +311,7 @@ public final class DuneGUI extends JavaPlugin implements Listener,CommandExecuto
}
public void openNativeMenu(Player player,String id){
if(!Bukkit.isPrimaryThread()||!player.isOnline())throw new IllegalStateException("Native menus require an online player on the server thread");
switch(id){case "hub"->organisations.console(player);case "exchange"->exchange.open(player);case "spice"->spice.open(player);case "travel"->openGuild(player,null);case "clan"->organisations.open(player,"clans");case "company"->organisations.open(player,"companies");case "politics"->organisations.open(player,"offices");case "missions"->quests.open(player);case "war"->warMenus.open(player);case "lore"->organisations.lore(player);case "mentat"->fetch(player,null,0,null,data->mentat(player,data));case "house"->fetch(player,null,0,null,data->select(player,data,selection(data)));case "equipment"->quests.quartermaster(player,()->exchange.open(player),()->exchange.openKits(player));default->throw new IllegalArgumentException("Unknown native menu");}
switch(id){case "hub"->organisations.console(player);case "exchange"->exchange.open(player);case "spice"->spice.open(player);case "travel"->openGuild(player,null);case "clan"->organisations.open(player,"clans");case "company"->organisations.open(player,"companies");case "politics"->organisations.open(player,"offices");case "missions"->quests.open(player);case "war"->warMenus.open(player);case "lore","cookbook"->organisations.cookbook(player);case "mentat"->fetch(player,null,0,null,data->mentat(player,data));case "house"->fetch(player,null,0,null,data->select(player,data,selection(data)));case "equipment"->quests.quartermaster(player,()->exchange.open(player),()->exchange.openKits(player));default->throw new IllegalArgumentException("Unknown native menu");}
}
public void closeSuppliedMenu(Player player){MCGUIMenus.dismiss(player);}
public void openExchangeMenu(Player player){if(!Bukkit.isPrimaryThread()||!player.isOnline())throw new IllegalStateException("Exchange entry requires an online player on the server thread");exchange.open(player);}

View file

@ -18,15 +18,16 @@ final class OrganisationMenus implements Listener {
private final JavaPlugin plugin;private final HouseBridge bridge;private final Consumer<Player> mentat,travel,house,quests,exchange,spice;
private final java.util.function.Predicate<Player> artwork;
private final Set<UUID> busy=new HashSet<>();
private final List<CookbookCatalog.Recipe> recipes;
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;
final UUID owner;final GuiSession gate;final Map<Integer,Runnable> actions=new HashMap<>();final Map<Integer,BedrockForms.Choice> choices=new TreeMap<>();String title;String description="Current organisation keys";boolean artwork;Inventory inventory;
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> 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.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,7,"Rihla ATM","Deposit cash · Redeem RIA ID · Withdraw cash",Material.GOLD_INGOT,()->{if(!SuppliedMenus.open(p,"atm"))p.sendMessage("The Rihla ATM is temporarily unavailable.");});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,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. Indeed.",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);}
OrganisationMenus(JavaPlugin plugin,HouseBridge bridge,Consumer<Player> mentat,Consumer<Player> travel,Consumer<Player> house,Consumer<Player> quests,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.exchange=exchange;this.spice=spice;this.artwork=artwork;this.recipes=CookbookCatalog.load(plugin);Bukkit.getPluginManager().registerEvents(this,plugin);}
void console(Player p){var panel=panel(p,"Imperial Codex",0);put(panel,7,"Rihla ATM","Deposit cash · Redeem RIA ID · Withdraw cash",Material.GOLD_INGOT,()->{if(!SuppliedMenus.open(p,"atm"))p.sendMessage("The Rihla ATM is temporarily unavailable.");});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,4,"Cookbook","Crafting recipes and grades",Material.WRITABLE_BOOK,()->cookbook(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. Indeed.",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;
@ -42,10 +43,38 @@ final class OrganisationMenus implements Listener {
Bukkit.getScheduler().runTask(plugin,()->{busy.remove(p.getUniqueId());if(!p.isOnline()||!world.equals(p.getWorld().getUID()))return;if(result!=null&&result.has(kind))for(var item:result.getAsJsonArray(kind)){var row=item.getAsJsonObject();if(row.has("id")&&id.equals(row.get("id").getAsString())){organisation(p,result,kind,row,contact);return;}}p.sendMessage("This organisation contact is available to current authorised members.");});
});
}
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};
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);
void cookbook(Player player){
var panel=panel(player,"Cookbook",false);
panel.description=recipes.isEmpty()?"The spice recipes are temporarily unavailable.":"Spice cookers, fuel and rails";
int slot=19;
for(var recipe:recipes){
int card=slot++;
put(panel,card,recipe.name(),recipe.grade()+"\n"+recipe.ingredients(),recipe.material(),
()->cookbookRecipe(player,recipe));
var icon=panel.inventory.getItem(card);
var meta=icon.getItemMeta();
meta.setItemModel(new NamespacedKey("dunerealms","crafting/"+recipe.id()));
icon.setItemMeta(meta);
panel.inventory.setItem(card,icon);
}
put(panel,45,"Back","Imperial Codex",Material.ARROW,()->console(player));
put(panel,49,"Web Cookbook","Browse all DuneRealms recipes",Material.BOOK,()->{
player.closeInventory();
player.sendMessage(Component.text("Open the full Cookbook",NamedTextColor.GOLD)
.clickEvent(ClickEvent.openUrl("https://www.dunerealms.com/imperial-recipe-book.html")));
});
close(panel,player);show(player,panel);
}
private void cookbookRecipe(Player player,CookbookCatalog.Recipe recipe){
var panel=panel(player,"Cookbook · "+recipe.name(),false);
panel.description=recipe.grade()+"\n"+recipe.ingredients()+"\n"+recipe.details();
put(panel,22,recipe.name(),panel.description,recipe.material(),null);
var icon=panel.inventory.getItem(22);
var meta=icon.getItemMeta();
meta.setItemModel(new NamespacedKey("dunerealms","crafting/"+recipe.id()));
icon.setItemMeta(meta);
panel.inventory.setItem(22,icon);
put(panel,45,"Back","Cookbook",Material.ARROW,()->cookbook(player));close(panel,player);show(player,panel);
}
private void start(Player p,JsonObject data){
var panel=panel(p,"Your organisations",false);put(panel,19,"Clan","Your clan and Home Block",Material.GREEN_BANNER,()->choose(p,data,"clans"));put(panel,22,"Company","Your companies and Home Blocks",Material.CYAN_BANNER,()->choose(p,data,"companies"));put(panel,25,"POL","Your current political offices",Material.PURPLE_BANNER,()->choose(p,data,"offices"));close(panel,p);show(p,panel);
@ -249,7 +278,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);if(action==null)return;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;}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);}
private void show(Player p,Panel panel){if(BedrockForms.isBedrock(p)){BedrockForms.show(plugin,p,panel.title,panel.description,List.copyOf(panel.choices.values()));return;}if(MCGUIMenus.show(p,panel.title,panel.description,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();}

View file

@ -1456,46 +1456,53 @@
},
"spice_furnace": {
"itemClass": "resource",
"quality": "rare",
"equipmentMark": 3,
"quality": "common",
"equipmentMark": 2,
"material": "FURNACE",
"policy": "s1-item-metadata-v1"
},
"spice_smoker": {
"itemClass": "resource",
"quality": "rare",
"quality": "uncommon",
"equipmentMark": 3,
"material": "SMOKER",
"policy": "s1-item-metadata-v1"
},
"spice_blast_furnace": {
"itemClass": "resource",
"quality": "rare",
"quality": "uncommon",
"equipmentMark": 3,
"material": "BLAST_FURNACE",
"policy": "s1-item-metadata-v1"
},
"spice_campfire": {
"itemClass": "resource",
"quality": "rare",
"equipmentMark": 3,
"quality": "uncommon",
"equipmentMark": 5,
"material": "CAMPFIRE",
"policy": "s1-item-metadata-v1"
},
"spice_soul_campfire": {
"itemClass": "resource",
"quality": "rare",
"equipmentMark": 3,
"quality": "uncommon",
"equipmentMark": 5,
"material": "SOUL_CAMPFIRE",
"policy": "s1-item-metadata-v1"
},
"spice_coal": {
"itemClass": "resource",
"quality": "rare",
"equipmentMark": 3,
"quality": "uncommon",
"equipmentMark": 4,
"material": "COAL",
"policy": "s1-item-metadata-v1"
},
"spice_tender": {
"itemClass": "resource",
"quality": "uncommon",
"equipmentMark": 5,
"material": "CHEST_MINECART",
"policy": "s1-item-metadata-v1"
},
"smuggled_spice_block": {
"itemClass": "resource",
"quality": "uncommon",

View file

@ -0,0 +1,72 @@
[
{
"id": "spice_furnace",
"name": "Spice-Infused Furnace",
"material": "FURNACE",
"baseMark": 1,
"mark": 2,
"quality": "common",
"ingredients": "4 Iron Ingots · 4 raw Melange Spice · 1 Furnace",
"details": "Put the vanilla cooker in the centre, spice on the four sides, and iron in the corners. Cooks twice as fast."
},
{
"id": "spice_smoker",
"name": "Spice-Infused Smoker",
"material": "SMOKER",
"baseMark": 2,
"mark": 3,
"quality": "uncommon",
"ingredients": "4 Iron Ingots · 4 raw Melange Spice · 1 Smoker",
"details": "Put the vanilla cooker in the centre, spice on the four sides, and iron in the corners. Cooks twice as fast."
},
{
"id": "spice_blast_furnace",
"name": "Spice-Infused Blast Furnace",
"material": "BLAST_FURNACE",
"baseMark": 2,
"mark": 3,
"quality": "uncommon",
"ingredients": "4 Iron Ingots · 4 raw Melange Spice · 1 Blast Furnace",
"details": "Put the vanilla cooker in the centre, spice on the four sides, and iron in the corners. Cooks twice as fast."
},
{
"id": "spice_campfire",
"name": "Spice-Infused Campfire",
"material": "CAMPFIRE",
"baseMark": 4,
"mark": 5,
"quality": "uncommon",
"ingredients": "4 Iron Ingots · 4 raw Melange Spice · 1 Campfire",
"details": "Put the vanilla cooker in the centre, spice on the four sides, and iron in the corners. Cooks twice as fast."
},
{
"id": "spice_soul_campfire",
"name": "Spice-Infused Soul Campfire",
"material": "SOUL_CAMPFIRE",
"baseMark": 4,
"mark": 5,
"quality": "uncommon",
"ingredients": "4 Iron Ingots · 4 raw Melange Spice · 1 Soul Campfire",
"details": "Put the vanilla cooker in the centre, spice on the four sides, and iron in the corners. Cooks twice as fast."
},
{
"id": "spice_coal",
"name": "Spice Coal",
"material": "COAL",
"baseMark": 3,
"mark": 4,
"quality": "uncommon",
"ingredients": "1 raw Melange Spice · 1 Coal or Charcoal",
"details": "Shapeless recipe. Fuels cookers and furnace minecarts."
},
{
"id": "spice_tender",
"name": "Spice Fuel Cart",
"material": "CHEST_MINECART",
"baseMark": 4,
"mark": 5,
"quality": "uncommon",
"ingredients": "1 Minecart · 1 Spice Coal",
"details": "Shapeless recipe. A fuel cart for Spice Coal."
}
]

View file

@ -14,29 +14,69 @@ PREFIX = "com/dunerealms/jarvis/"
CLASSES = {PREFIX + name + ".class" for name in
("QuestObservations", "CookSpeed", "SpiceFurnaces", "SpiceFurnaces$1")}
META = "item-templates.json"
CATALOG = "spice-crafting.json"
GUI = "com/dunerealms/gui/"
MENUS = "com/dunerealms/menus/"
FRONTENDS = {
"gui": (("DuneGUI", "OrganisationMenus", "CookbookCatalog"), GUI, CATALOG),
"menus": (("HubMenu", "NativeServiceMenu"), MENUS, None),
}
def frontend_entries(kind, entries):
families, prefix, resource = FRONTENDS[kind]
roots = [prefix + family for family in families]
selected = {name: data for name, data in entries.items() if name == resource or any(
name == root + ".class" or name.startswith(root + "$") and name.endswith(".class") for root in roots)}
expected = {root + ".class" for root in roots} | ({resource} if resource else set())
if not expected <= selected.keys():
raise ValueError(f"{kind} has incomplete Cookbook entry points")
return selected
def catalog_grades(catalog, policy):
if len(catalog) != len(ITEMS) or {row["id"] for row in catalog} != set(ITEMS):
raise ValueError("Unexpected spice Cookbook entries")
for row in catalog:
grade = policy[row["id"]]
mark = row["mark"]
if (mark != row["baseMark"] + 1 or grade["equipmentMark"] != mark
or grade["material"] != row["material"] or grade["quality"] != row["quality"]
or row["quality"] != ("common", "uncommon", "rare", "very_rare", "legendary")[mark // 3]):
raise ValueError("Cookbook grade differs from the issued item: " + row["id"])
def encoded(value):
return json.dumps(value, ensure_ascii=False, indent=2).encode("utf-8") + b"\n"
def staged(source, compiled, output):
def staged(source, compiled, gui, menus, output):
jars = read_archive(compiled.read_bytes())
policy = json.loads(jars[META])["templates"]
overlay = {name: jars[name] for name in CLASSES}
overlay[META] = encoded({item: policy[item] for item in DEVICES})
overlay[META] = encoded({item: policy[item] for item in ITEMS})
gui_archive = read_archive(gui.read_bytes())
catalog_grades(json.loads(gui_archive[CATALOG]), policy)
(output / "cookbook-gui.overlay.zip").write_bytes(write_archive(frontend_entries("gui", gui_archive)))
(output / "cookbook-menus.overlay.zip").write_bytes(
write_archive(frontend_entries("menus", read_archive(menus.read_bytes()))))
(output / "spice-cookers.overlay.zip").write_bytes(write_archive(overlay))
(output / "spice-cookers.art.zip").write_bytes(write_archive({
name: (source / name).read_bytes() for name in ASSETS}))
def assemble(kind, baseline, overlay):
if kind in FRONTENDS:
if frontend_entries(kind, overlay).keys() != overlay.keys():
raise ValueError("Unexpected entry in Cookbook frontend overlay")
return baseline | overlay
if kind == "jarvis":
if set(overlay) != CLASSES | {META} or PREFIX + "ItemOriginRemainders.class" not in baseline:
raise ValueError("Unexpected cooker classes or retained provenance layer")
additions = json.loads(overlay[META])
policy = json.loads(baseline[META])
if set(additions) != set(DEVICES) or set(additions) & policy["templates"].keys():
if set(additions) != set(ITEMS) or set(additions) & policy["templates"].keys():
raise ValueError("Expected new cooker item templates only")
policy["templates"].update(additions)
return baseline | overlay | {META: encoded(policy)}
@ -49,17 +89,17 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
commands = parser.add_subparsers(dest="action", required=True)
pack = commands.add_parser("extract")
for field in ("source", "compiled", "output"):
for field in ("source", "compiled", "gui", "menus", "output"):
pack.add_argument(field, type=Path)
install = commands.add_parser("assemble")
install.add_argument("kind", choices=("jarvis", "pack"))
install.add_argument("kind", choices=("jarvis", "pack", *FRONTENDS))
for field in ("baseline", "overlay", "output"):
install.add_argument(field, type=Path)
install.add_argument("baseline_sha")
install.add_argument("overlay_sha")
args = parser.parse_args()
if args.action == "extract":
staged(args.source, args.compiled, args.output)
staged(args.source, args.compiled, args.gui, args.menus, args.output)
return
baseline, overlay = args.baseline.read_bytes(), args.overlay.read_bytes()
if digest(baseline) != args.baseline_sha or digest(overlay) != args.overlay_sha:

View file

@ -291,18 +291,31 @@ index 8665c66..a94823d 100644
}
diff --git a/src/main/java/me/fridtjof/minecarttrains/managers/RecipeManager.java b/src/main/java/me/fridtjof/minecarttrains/managers/RecipeManager.java
index eafe74b..0b4cf54 100644
index eafe74b..9249aa2 100644
--- a/src/main/java/me/fridtjof/minecarttrains/managers/RecipeManager.java
+++ b/src/main/java/me/fridtjof/minecarttrains/managers/RecipeManager.java
@@ -24,6 +24,7 @@ public class RecipeManager
@@ -24,7 +24,20 @@ public class RecipeManager
ItemStack tenderItemStack = new ItemStack(Material.CHEST_MINECART);
ItemMeta tenderItemMeta = tenderItemStack.getItemMeta();
tenderItemMeta.setDisplayName(FUEL_CART_NAME);
+ tenderItemMeta.setItemModel(new NamespacedKey("dunerealms", "crafting/spice_tender"));
+ tenderItemMeta.getPersistentDataContainer().set(
+ new NamespacedKey("executableitems", "ei-id"),
+ org.bukkit.persistence.PersistentDataType.STRING, "spice_tender");
tenderItemStack.setItemMeta(tenderItemMeta);
+ var jarvis = Bukkit.getPluginManager().getPlugin("JarvisTranslator");
+ if (jarvis == null || !jarvis.isEnabled()) {
+ throw new IllegalStateException("JARVIS item provisioning is required for Spice Fuel Cart");
+ }
+ try {
+ jarvis.getClass().getMethod("markCreatedItem", ItemStack.class).invoke(jarvis, tenderItemStack);
+ } catch (ReflectiveOperationException failed) {
+ throw new IllegalStateException("JARVIS could not grade the Spice Fuel Cart recipe", failed);
+ }
NamespacedKey tenderKey = new NamespacedKey(plugin, "fuel_cart");
@@ -35,7 +36,7 @@ public class RecipeManager
@@ -35,7 +48,7 @@ public class RecipeManager
//tenderRecipe.shape("#B#", "#M#");
tenderRecipe.addIngredient(Material.MINECART);
@ -311,3 +324,13 @@ index eafe74b..0b4cf54 100644
Bukkit.addRecipe(tenderRecipe);
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index aa470e8..2bb5627 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -4,4 +4,4 @@ main: me.fridtjof.minecarttrains.MinecartTrains
api-version: '1.21'
authors: [ Fridtjof_DE ]
website: https://www.fridtjof.me
-depend: [PuddingAPI]
+depend: [PuddingAPI, JarvisTranslator]