diff --git a/.forgejo/workflows/arrakis-crysknife.yml b/.forgejo/workflows/arrakis-crysknife.yml new file mode 100644 index 00000000..8d83c123 --- /dev/null +++ b/.forgejo/workflows/arrakis-crysknife.yml @@ -0,0 +1,49 @@ +name: Arrakis Crysknife Build +on: + workflow_dispatch: + push: + branches: ['feat/jarvis-crysknife-*'] + +jobs: + crysknife: + runs-on: dune-ci + steps: + - name: Check out exact revision + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + git init . + git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/plugins.git "$GITHUB_SHA" + git checkout --detach FETCH_HEAD + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: '9.2.1' + - name: Package the Arrakis J.A.R.V.I.S., Terrain and resource pack release + shell: bash + run: | + set -euo pipefail + gradle --no-daemon -p JarvisConnector test jar + gradle --no-daemon -p DuneTerrain test jar + python3 tools/plugin_pillager_abi.py JarvisConnector/build/libs/jarvistranslator.jar + python3 tools/verify-arrakis-terrain.py DuneTerrain/build/libs/DuneRealms-Terrain.jar DuneTerrain/src/test/resources/retained-arrakis-terrain.json + python3 tools/test_plugin_fleet_install.py -v + python3 tools/test_plugin_pack_properties.py -v + mkdir crysknife-artifacts + cp JarvisConnector/build/libs/jarvistranslator.jar DuneTerrain/build/libs/DuneRealms-Terrain.jar crysknife-artifacts/ + printf '%s\n' "$(git rev-parse HEAD)" > crysknife-artifacts/SOURCE_COMMIT + python3 tools/build-unified-resourcepack.py --source "$GITHUB_SHA" --output "crysknife-artifacts/DuneRealms-Resources-${GITHUB_SHA}.zip" + python3 tools/write-plugin-manifest.py crysknife-artifacts "$GITHUB_SHA" + cp tools/install-plugin-fleet.py tools/plugin_menu_pack.py tools/plugin_backend_abi.py tools/plugin_pillager_abi.py tools/plugin_fleet_rollback.py tools/plugin_pack_properties.py tools/publish-plugin-menu.py crysknife-artifacts/ + cp JarvisConnector/src/test/resources/retained-jarvis-public-abi.json JarvisConnector/src/test/resources/medieval-factions-11.1-raid-api.json JarvisConnector/src/test/resources/worldguard-raid-api.json DuneTerrain/src/test/resources/retained-arrakis-terrain.json crysknife-artifacts/ + (cd crysknife-artifacts && sha256sum -- *.jar *.zip *.json *.py SOURCE_COMMIT > SHA256SUMS) + - uses: actions/upload-artifact@v3 + with: + name: DuneRealms-Arrakis-Crysknife + path: crysknife-artifacts/ + if-no-files-found: error diff --git a/DuneMenus/build.gradle.kts b/DuneMenus/build.gradle.kts index d87e5fc5..cd2b422c 100644 --- a/DuneMenus/build.gradle.kts +++ b/DuneMenus/build.gradle.kts @@ -54,5 +54,13 @@ tasks.register("verifyMenuRenderer") { // Reuse committed central artwork. No network requests occur when a menu opens. tasks.processResources { from("../network/resource-pack/vanilla-art/overlay") { into("menu-art/pack") } - from("../network/resource-pack/central/overlay") { into("menu-art/pack"); include("assets/dunerealms/items/**", "assets/dunerealms/models/**", "assets/dunerealms/textures/**") } + from("../network/resource-pack/central/overlay") { + into("menu-art/pack") + include("assets/dunerealms/items/**", "assets/dunerealms/models/**", "assets/dunerealms/textures/**") + // These Arrakis gameplay models are delivered by the server pack. + for (item in listOf("crysknife", "maker_tooth")) { + exclude("assets/dunerealms/items/$item.json", "assets/dunerealms/models/item/$item.json", + "assets/dunerealms/textures/item/$item.png") + } + } } diff --git a/DuneTerrain/README.md b/DuneTerrain/README.md index df546de7..d1ab5bdb 100644 --- a/DuneTerrain/README.md +++ b/DuneTerrain/README.md @@ -8,7 +8,7 @@ DuneRealms terrain runs on Java 21. Build with `gradle build`; install `build/li - **Dense Spice** (`dunerealms:dense-spice`): one 30 × 30 rich patch per 512-block placement region, with seed-dependent positions. This is configurable village-like density, not vanilla village placement. Deep orange terracotta represents finite rich spice sand. Each authentic deposit yields four existing tagged Melange Spice items by default. Silk Touch and Fortune cannot clone or multiply it; creative mining consumes the deposit without a reward. A chunk Persistent Data Container stores each deposit's position and removes it on harvest. Ordinary orange terracotta has no spice value. Pistons and explosions cannot move or duplicate registered deposits. Ledger state persists in normal chunk saves across restarts; restoring a world backup restores its historical deposits too. - A persistent spice seller appears in the centre of each new rich field. Right-click opens the shared native menu and offers 16 tagged spice at **standard DuneEss price × 1.35**. At 15 Solaris each, 16 cost 324 Solaris. Existing spice sales, taxes and CHOAM trading remain unchanged. Confirming purchases checks distance, inventory capacity and successful economy withdrawal. - **Desert villages**: custom four-house sandstone settlements, with cut-sandstone lanes, villagers, beds, non-farming workstations, lanterns and finite shared supply chests. No farmland, crops or hay bales enter the structure palette. Chests use `dunerealms:chests/desert-village`: bread, dried kelp, apples and raw iron. Placement regions default to 768 blocks, with terrain suitability checks. -- **Harkonnen garrison fortress** (pillager-outpost mechanic): a walled black-stone fortress with four searchlight towers, a three-storey keep (barracks, armoury, command room, roof), a landing pad, a cell block, a supply depot and a vault under the keep. Placement copies the vanilla pillager outpost: one attempt per 32x32-chunk region, 8 chunks of separation, 20% frequency (`harkonnen-fortress.spacing-chunks|separation-chunks|frequency`). Harkonnen pillagers (8 guards plus a commander, black dyed armour, no bad-omen banner) are spawned when a player comes near and replaced after `respawn-seconds`. The vault chest is filled on first open with one Harkonnen stillsuit piece plus 3 random valuables (Maker's Tooth when supported by DuneCore, refined spice, spice block, smuggler shovel, etc.; override with `harkonnen-fortress.loot`). Chests from the old temple-style fortress keep their loot rules. +- **Harkonnen garrison fortress** (pillager-outpost mechanic): a walled black-stone fortress with four searchlight towers, a three-storey keep (barracks, armoury, command room, roof), a landing pad, a cell block, a supply depot and a vault under the keep. Placement copies the vanilla pillager outpost: one attempt per 32x32-chunk region, 8 chunks of separation, 20% frequency (`harkonnen-fortress.spacing-chunks|separation-chunks|frequency`). Harkonnen pillagers (8 guards plus a commander, black dyed armour, no bad-omen banner) are spawned when a player comes near and replaced after `respawn-seconds`. The vault chest is filled on first open with one Harkonnen stillsuit piece plus 3 random valuables (Maker's Tooth issued by J.A.R.V.I.S., refined spice, spice block, smuggler shovel, etc.; override with `harkonnen-fortress.loot`). Chests from the old temple-style fortress keep their loot rules. - **Abandoned Fremen village**: always generated beside a Harkonnen outpost (one of eight fixed offsets chosen from the outpost id): a dry cistern, broken windtrap, six sand-drifted sandstone and terracotta houses with faded Fremen-blue cloth, dry qanat channels and two caches. No villagers, no farmland. Arrakis generates small, medium, and large sietches on separate grids with default spacing of 600, 900, and 2,000 blocks. Larger tiers take priority when footprints overlap. Each tier has independent `enabled` and `spacing` settings under `sietches`. Placement applies as chunks generate. diff --git a/DuneTerrain/build.gradle.kts b/DuneTerrain/build.gradle.kts index 63cb05c3..5729900f 100644 --- a/DuneTerrain/build.gradle.kts +++ b/DuneTerrain/build.gradle.kts @@ -1,7 +1,7 @@ plugins { java } group = "com.example" -version = "1.0.17-structures1" +version = "1.0.18-jarvisloot1" repositories { mavenCentral() diff --git a/DuneTerrain/src/main/java/com/example/duneterrain/StructureCaches.java b/DuneTerrain/src/main/java/com/example/duneterrain/StructureCaches.java index db3ef9ec..833e7fd4 100644 --- a/DuneTerrain/src/main/java/com/example/duneterrain/StructureCaches.java +++ b/DuneTerrain/src/main/java/com/example/duneterrain/StructureCaches.java @@ -74,9 +74,11 @@ final class StructureCaches implements Listener { switch (e.source()) { case "ei": { ItemStack i = ArrakisEcology.item(e.id()); i.setAmount(Math.min(i.getMaxStackSize(), p.amount())); return i; } case "tooth": { - var core = Bukkit.getPluginManager().getPlugin("DuneCore"); - if (core == null || !core.isEnabled()) return null; - ItemStack i = (ItemStack) core.getClass().getMethod("createMakerTooth").invoke(core); i.setAmount(p.amount()); return i; + var jarvis = Bukkit.getPluginManager().getPlugin("JarvisTranslator"); + if (jarvis == null || !jarvis.isEnabled()) return null; + ItemStack i = (ItemStack) jarvis.getClass().getMethod("issueMakerTooth").invoke(jarvis); + if (i != null) i.setAmount(Math.min(i.getMaxStackSize(), p.amount())); + return i; } case "kit-shovel": for (ItemStack i : coreKit("Harkonnen")) if (i.getType() == Material.NETHERITE_SHOVEL) return i; return null; default: { Material m = Material.matchMaterial(e.id()); return m == null ? null : new ItemStack(m, Math.min(m.getMaxStackSize(), p.amount())); } diff --git a/DuneTerrain/src/main/resources/plugin.yml b/DuneTerrain/src/main/resources/plugin.yml index 77d887b3..d2c2a62e 100644 --- a/DuneTerrain/src/main/resources/plugin.yml +++ b/DuneTerrain/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: DuneTerrain -version: 1.0.17-structures1 +version: 1.0.18-jarvisloot1 main: com.example.duneterrain.DuneTerrain api-version: '1.21' load: STARTUP diff --git a/JarvisConnector/build.gradle.kts b/JarvisConnector/build.gradle.kts index da360304..16fbd917 100644 --- a/JarvisConnector/build.gradle.kts +++ b/JarvisConnector/build.gradle.kts @@ -1,6 +1,6 @@ plugins { java } group = "com.dunerealms" -version = "0.5.36-pillager1" +version = "0.5.37-crysknife1" repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") } dependencies { compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT") diff --git a/JarvisConnector/src/main/java/com/dunerealms/jarvis/Crysknife.java b/JarvisConnector/src/main/java/com/dunerealms/jarvis/Crysknife.java new file mode 100644 index 00000000..bc097ee7 --- /dev/null +++ b/JarvisConnector/src/main/java/com/dunerealms/jarvis/Crysknife.java @@ -0,0 +1,192 @@ +package com.dunerealms.jarvis; + +import java.util.*; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.inventory.CraftItemEvent; +import org.bukkit.event.block.CrafterCraftEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.EquipmentSlotGroup; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.ShapelessRecipe; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.scheduler.BukkitTask; + +/** + * Sandworm kills can drop a Maker's Tooth; a tooth plus Melange Spice is crafted into a crysknife. + * The knife binds to its crafter and crumbles if someone else holds it for a while, so theft is useless. + * Items use the existing {@code dunerealms:item} tag and J.A.R.V.I.S. item metadata. + */ +final class Crysknife implements Listener { + private static final String TOOTH = "maker_tooth", KNIFE = "crysknife"; + private final JarvisTranslator plugin; + private final NamespacedKey itemKey = new NamespacedKey("dunerealms", "item"); + private final NamespacedKey ownerKey = new NamespacedKey("dunerealms", "crysknife_owner"); + private final NamespacedKey recipeKey = new NamespacedKey("dunerealms", "crysknife_recipe"); + private final NamespacedKey bodyKey, brainKey; + private final Map heldSince = new HashMap<>(); + private final Random random = new Random(); + private final BukkitTask sweep; + + Crysknife(JarvisTranslator plugin) { + this.plugin = plugin; + bodyKey = new NamespacedKey("dunecore", "sandworm_body"); + brainKey = new NamespacedKey("dunecore", "sandworm_brain"); + var recipe = new ShapelessRecipe(recipeKey, knife(null)); + recipe.addIngredient(Material.BONE); + recipe.addIngredient(Material.ORANGE_DYE); + plugin.getServer().addRecipe(recipe); + plugin.getServer().getPluginManager().registerEvents(this, plugin); + sweep = plugin.getServer().getScheduler().runTaskTimer(plugin, this::sweepForeignKnives, 100L, 100L); + } + + void close() { sweep.cancel(); plugin.getServer().removeRecipe(recipeKey); } + + // ---- items ---- + ItemStack tooth() { + var item = new ItemStack(Material.BONE); + ItemMeta meta = item.getItemMeta(); + meta.displayName(Component.text("Maker's Tooth", NamedTextColor.WHITE).decoration(TextDecoration.ITALIC, false)); + meta.lore(List.of(Component.text("Shed by a dying Shai-Hulud.", NamedTextColor.GRAY), + Component.text("Fremen shape it with spice into a crysknife.", NamedTextColor.DARK_GRAY))); + meta.setItemModel(new NamespacedKey("dunerealms", TOOTH)); + meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, TOOTH); + item.setItemMeta(meta); + plugin.markCreatedItem(item); + return item; + } + + /** A knife with no owner (placeholder, admin give) never crumbles; crafting stamps the crafter. */ + ItemStack knife(UUID owner) { + var item = new ItemStack(Material.IRON_SWORD); + ItemMeta meta = item.getItemMeta(); + meta.displayName(Component.text("Crysknife", NamedTextColor.AQUA).decoration(TextDecoration.ITALIC, false)); + meta.lore(List.of(Component.text("A milk-white blade, bound to the one who shaped it.", NamedTextColor.GRAY), + Component.text("It crumbles if another keeps it too long.", NamedTextColor.DARK_GRAY))); + meta.setItemModel(new NamespacedKey("dunerealms", KNIFE)); + meta.setUnbreakable(true); + meta.addAttributeModifier(Attribute.ATTACK_DAMAGE, new AttributeModifier(new NamespacedKey("dunerealms", "crysknife_damage"), + plugin.getConfig().getDouble("crysknife.attack-bonus", 4.0), AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND)); + meta.addAttributeModifier(Attribute.ATTACK_SPEED, new AttributeModifier(new NamespacedKey("dunerealms", "crysknife_speed"), + -1.8, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.MAINHAND)); + var data = meta.getPersistentDataContainer(); + data.set(itemKey, PersistentDataType.STRING, KNIFE); + if (owner != null) data.set(ownerKey, PersistentDataType.STRING, owner.toString()); + item.setItemMeta(meta); + if (owner != null) plugin.markCreatedItem(item); + return item; + } + + private String tag(ItemStack item) { + if (item == null || !item.hasItemMeta()) return null; + var data = item.getItemMeta().getPersistentDataContainer(); + if (data.has(new NamespacedKey("dunerealms", "preview_only"))) return null; + return data.get(itemKey, PersistentDataType.STRING); + } + private boolean isKnife(ItemStack item) { return KNIFE.equals(tag(item)); } + private UUID ownerOf(ItemStack item) { + String raw = item.getItemMeta().getPersistentDataContainer().get(ownerKey, PersistentDataType.STRING); + try { return raw == null ? null : UUID.fromString(raw); } catch (IllegalArgumentException invalid) { return null; } + } + private boolean isWorm(Entity e) { + if (!e.getWorld().getName().equalsIgnoreCase("arrakis")) return false; + var data = e.getPersistentDataContainer(); + String partner = data.get(e instanceof org.bukkit.entity.Sniffer ? brainKey : bodyKey, PersistentDataType.STRING); + return (e instanceof org.bukkit.entity.Sniffer || e instanceof org.bukkit.entity.Husk) + && partner != null && !partner.equals("pending"); + } + + // ---- tooth drop ---- + /** Runs after SandwormMobs has cleared the worm's drops. */ + @EventHandler(priority = EventPriority.HIGH) + public void onWormDeath(EntityDeathEvent event) { + if (!isWorm(event.getEntity())) return; + if (CrysknifeRules.toothDrops(random.nextDouble(), plugin.getConfig().getDouble("crysknife.tooth-chance", 0.15))) + event.getDrops().add(tooth()); + } + + // ---- crafting: one Maker's Tooth and one Melange Spice, nothing else ---- + private boolean isRecipe(Recipe recipe) { + return recipe instanceof ShapelessRecipe shapeless && recipeKey.equals(shapeless.getKey()); + } + + private boolean ingredients(ItemStack[] matrix) { + boolean tooth = false, spice = false; + for (ItemStack ingredient : matrix) { + if (ingredient == null || ingredient.getType().isAir()) continue; + if (!tooth && ingredient.getType() == Material.BONE && TOOTH.equals(tag(ingredient))) tooth = true; + else if (!spice && ExchangeInventory.saleSpice(ingredient, "guild")) spice = true; + else return false; + } + return tooth && spice; + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPrepare(PrepareItemCraftEvent event) { + if (!isRecipe(event.getRecipe())) return; + event.getInventory().setResult(ingredients(event.getInventory().getMatrix()) + ? knife(event.getView().getPlayer().getUniqueId()) : null); + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onCraft(CraftItemEvent event) { + if (isRecipe(event.getRecipe()) && (!ingredients(event.getInventory().getMatrix()) + || !event.getWhoClicked().getUniqueId().equals(ownerOfResult(event.getCurrentItem())))) event.setCancelled(true); + } + + private UUID ownerOfResult(ItemStack item) { + return isKnife(item) ? ownerOf(item) : null; + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onCrafter(CrafterCraftEvent event) { + if (isRecipe(event.getRecipe())) event.setCancelled(true); + } + + // ---- worm bonus ---- + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void onHit(EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Player player) || !isWorm(event.getEntity())) return; + ItemStack held = player.getInventory().getItemInMainHand(); + if (!isKnife(held)) return; + event.setDamage(CrysknifeRules.wormDamage(event.getDamage(), plugin.getConfig().getDouble("crysknife.worm-damage-multiplier", 1.5))); + } + + // ---- binding: foreign knives crumble ---- + private void sweepForeignKnives() { + long now = System.currentTimeMillis(), grace = plugin.getConfig().getLong("crysknife.crumble-seconds", 180) * 1000L; + for (Player player : plugin.getServer().getOnlinePlayers()) { + boolean foreign = false; + ItemStack[] contents = player.getInventory().getContents(); + for (int i = 0; i < contents.length; i++) { + ItemStack item = contents[i]; + if (!isKnife(item)) continue; + UUID owner = ownerOf(item); + if (owner == null || owner.equals(player.getUniqueId())) continue; + foreign = true; + if (CrysknifeRules.crumbleDue(heldSince.get(player.getUniqueId()), now, grace)) { + player.getInventory().setItem(i, null); + player.sendMessage(Component.text("The crysknife crumbles to dust in hands that did not shape it.", NamedTextColor.GRAY)); + } + } + if (foreign) heldSince.putIfAbsent(player.getUniqueId(), now); else heldSince.remove(player.getUniqueId()); + } + } + + @EventHandler public void onQuit(PlayerQuitEvent event) { heldSince.remove(event.getPlayer().getUniqueId()); } +} diff --git a/JarvisConnector/src/main/java/com/dunerealms/jarvis/CrysknifeRules.java b/JarvisConnector/src/main/java/com/dunerealms/jarvis/CrysknifeRules.java new file mode 100644 index 00000000..0ad76e55 --- /dev/null +++ b/JarvisConnector/src/main/java/com/dunerealms/jarvis/CrysknifeRules.java @@ -0,0 +1,17 @@ +package com.dunerealms.jarvis; + +/** Pure crysknife rules, kept free of Bukkit types so they can be unit-tested. */ +final class CrysknifeRules { + private CrysknifeRules() {} + + /** A random roll in [0,1) beats the configured chance. A chance of 0 or less never drops. */ + static boolean toothDrops(double roll, double chance) { return chance > 0 && roll < chance; } + + /** True once a knife has been held by someone other than its owner for the whole grace period. */ + static boolean crumbleDue(Long heldSinceMs, long nowMs, long graceMs) { + return heldSinceMs != null && nowMs - heldSinceMs >= graceMs; + } + + /** Worm damage is only ever raised, never reduced, by the configured multiplier. */ + static double wormDamage(double base, double multiplier) { return base * Math.max(1.0, multiplier); } +} diff --git a/JarvisConnector/src/main/java/com/dunerealms/jarvis/JarvisTranslator.java b/JarvisConnector/src/main/java/com/dunerealms/jarvis/JarvisTranslator.java index f1f3c9b7..cc7ce3bc 100644 --- a/JarvisConnector/src/main/java/com/dunerealms/jarvis/JarvisTranslator.java +++ b/JarvisConnector/src/main/java/com/dunerealms/jarvis/JarvisTranslator.java @@ -42,6 +42,11 @@ public final class JarvisTranslator extends JavaPlugin implements Listener { public void refineSpice(org.bukkit.entity.Player player,JsonObject permit)throws Exception{spiceRefiner.execute(player,permit);} private ItemMetadataOverlay itemMetadata; private SpiceBlocks spiceBlocks; + private Crysknife crysknife; + public org.bukkit.inventory.ItemStack issueMakerTooth(){ + if(!Bukkit.isPrimaryThread())throw new IllegalStateException("Create items on the server thread"); + return crysknife==null?null:crysknife.tooth(); + } public org.bukkit.inventory.ItemStack compressedSpice(org.bukkit.inventory.ItemStack raw){return spiceBlocks.compress(raw);} public void markCreatedItem(org.bukkit.inventory.ItemStack item){if(!Bukkit.isPrimaryThread())throw new IllegalStateException("Create items on the server thread");ItemOrigin.created(item);itemMetadata.stamp(item);} public int spiceCount(org.bukkit.entity.Player p){return exchangeInventory.spiceCount(p);} @@ -122,6 +127,7 @@ public final class JarvisTranslator extends JavaPlugin implements Listener { try { itemMetadata=new ItemMetadataOverlay(this);exchangeInventory=new ExchangeInventory(item->itemMetadata.stamp(item),serverKey);itemPreview=new ItemDesignPreview(new ItemMetadataPolicy(getResource("item-templates.json")),new ItemCardArt(getResource("item-card-glyphs.json"))); } catch (java.io.IOException invalid) { throw new IllegalStateException("Shared item metadata catalogue is unavailable",invalid); } spiceBlocks=new SpiceBlocks(this,item->itemMetadata.stamp(item)); + if ("arrakis".equals(serverKey)) crysknife = new Crysknife(this); var survivalRecipes=new SurvivalFoodRecipes(this,itemMetadata); new ArrakisBrewing(this,itemMetadata,survivalRecipes); new WeirdingModule(this,itemMetadata); @@ -257,6 +263,6 @@ public final class JarvisTranslator extends JavaPlugin implements Listener { if (!isEnabled()) return CompletableFuture.completedFuture(NativeActions.Result.UNAVAILABLE); return actions.execute(actor, action, keyReference); } - @Override public void onDisable() { if(imperialRaids!=null)imperialRaids.close();if(spiceRaiderMining!=null)spiceRaiderMining.close();if(warCampaigns!=null)warCampaigns.close();if(questObservations!=null)questObservations.close();if(nativeKeys!=null)nativeKeys.close();if (actions != null) actions.close(); if (api != null) api.close(); } + @Override public void onDisable() { if(crysknife!=null){crysknife.close();crysknife=null;}if(imperialRaids!=null)imperialRaids.close();if(spiceRaiderMining!=null)spiceRaiderMining.close();if(warCampaigns!=null)warCampaigns.close();if(questObservations!=null)questObservations.close();if(nativeKeys!=null)nativeKeys.close();if (actions != null) actions.close(); if (api != null) api.close(); } } diff --git a/JarvisConnector/src/main/resources/plugin.yml b/JarvisConnector/src/main/resources/plugin.yml index fd1aa3d5..ea2dcdc6 100644 --- a/JarvisConnector/src/main/resources/plugin.yml +++ b/JarvisConnector/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: JarvisTranslator main: com.dunerealms.jarvis.JarvisTranslator -version: 0.5.36-pillager1 +version: 0.5.37-crysknife1 api-version: '1.21.8' description: Shared J.A.R.V.I.S. website API and native server action translator. softdepend: [Citizens, Citizens, CoreProtect, SCore, ExecutableItems, ExecutableCrafting, DuneEss, ImageFrame, DecentHolograms, MedievalFactions, Towny, WorldGuard] diff --git a/JarvisConnector/src/test/java/com/dunerealms/jarvis/CrysknifeRulesTest.java b/JarvisConnector/src/test/java/com/dunerealms/jarvis/CrysknifeRulesTest.java new file mode 100644 index 00000000..579eaec5 --- /dev/null +++ b/JarvisConnector/src/test/java/com/dunerealms/jarvis/CrysknifeRulesTest.java @@ -0,0 +1,23 @@ +package com.dunerealms.jarvis; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class CrysknifeRulesTest { + @Test void toothRollsAgainstTheChance() { + assertTrue(CrysknifeRules.toothDrops(0.10, 0.15)); + assertFalse(CrysknifeRules.toothDrops(0.15, 0.15)); + assertFalse(CrysknifeRules.toothDrops(0.0, 0.0)); + assertFalse(CrysknifeRules.toothDrops(0.0, -1.0)); + } + @Test void crumbleNeedsAForeignHoldForTheWholeGracePeriod() { + assertFalse(CrysknifeRules.crumbleDue(null, 1_000, 180_000)); + assertFalse(CrysknifeRules.crumbleDue(1_000L, 100_000, 180_000)); + assertTrue(CrysknifeRules.crumbleDue(1_000L, 181_000, 180_000)); + } + @Test void wormDamageIsNeverReduced() { + assertEquals(15.0, CrysknifeRules.wormDamage(10.0, 1.5), 1e-9); + assertEquals(10.0, CrysknifeRules.wormDamage(10.0, 0.5), 1e-9); + } +} diff --git a/network/resource-pack/central/overlay/assets/dunerealms/items/crysknife.json b/network/resource-pack/central/overlay/assets/dunerealms/items/crysknife.json new file mode 100644 index 00000000..33214ead --- /dev/null +++ b/network/resource-pack/central/overlay/assets/dunerealms/items/crysknife.json @@ -0,0 +1 @@ +{"model":{"type":"minecraft:model","model":"dunerealms:item/crysknife"}} \ No newline at end of file diff --git a/network/resource-pack/central/overlay/assets/dunerealms/items/maker_tooth.json b/network/resource-pack/central/overlay/assets/dunerealms/items/maker_tooth.json new file mode 100644 index 00000000..4ecea7ce --- /dev/null +++ b/network/resource-pack/central/overlay/assets/dunerealms/items/maker_tooth.json @@ -0,0 +1 @@ +{"model":{"type":"minecraft:model","model":"dunerealms:item/maker_tooth"}} \ No newline at end of file diff --git a/network/resource-pack/central/overlay/assets/dunerealms/models/item/crysknife.json b/network/resource-pack/central/overlay/assets/dunerealms/models/item/crysknife.json new file mode 100644 index 00000000..d901ffba --- /dev/null +++ b/network/resource-pack/central/overlay/assets/dunerealms/models/item/crysknife.json @@ -0,0 +1 @@ +{"parent":"minecraft:item/handheld","textures":{"layer0":"dunerealms:item/crysknife"}} \ No newline at end of file diff --git a/network/resource-pack/central/overlay/assets/dunerealms/models/item/maker_tooth.json b/network/resource-pack/central/overlay/assets/dunerealms/models/item/maker_tooth.json new file mode 100644 index 00000000..23d9d0ca --- /dev/null +++ b/network/resource-pack/central/overlay/assets/dunerealms/models/item/maker_tooth.json @@ -0,0 +1 @@ +{"parent":"minecraft:item/generated","textures":{"layer0":"dunerealms:item/maker_tooth"}} \ No newline at end of file diff --git a/network/resource-pack/central/overlay/assets/dunerealms/textures/item/crysknife.png b/network/resource-pack/central/overlay/assets/dunerealms/textures/item/crysknife.png new file mode 100644 index 00000000..bfec21ed Binary files /dev/null and b/network/resource-pack/central/overlay/assets/dunerealms/textures/item/crysknife.png differ diff --git a/network/resource-pack/central/overlay/assets/dunerealms/textures/item/maker_tooth.png b/network/resource-pack/central/overlay/assets/dunerealms/textures/item/maker_tooth.png new file mode 100644 index 00000000..45704670 Binary files /dev/null and b/network/resource-pack/central/overlay/assets/dunerealms/textures/item/maker_tooth.png differ diff --git a/tools/install-plugin-fleet.py b/tools/install-plugin-fleet.py index 1a57ecb0..902d263d 100644 --- a/tools/install-plugin-fleet.py +++ b/tools/install-plugin-fleet.py @@ -52,9 +52,10 @@ def identity(path): def plan(artifacts, inventory, expected_source): mode=inventory.get('mode') - if mode not in {'gui-preserve-backends','pillager-preserve-economy'}: - raise ValueError("An explicit gui-preserve-backends or pillager-preserve-economy mode is required") + if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife'}: + raise ValueError('An explicit supported rollout mode is required') pillager=mode=='pillager-preserve-economy' + crysknife=mode=='arrakis-crysknife' artifacts = Path(artifacts).resolve(strict=True) manifest = json.loads((artifacts / 'release-manifest.json').read_text()) if not re.fullmatch(r'[0-9a-f]{40}', expected_source) or manifest.get('sourceCommit') != expected_source: @@ -92,8 +93,8 @@ def plan(artifacts, inventory, expected_source): if inventory.get('menuPack') is not None: _, menu = load_menu(artifacts, expected_source) verify_public_menu(inventory['menuPack']['url'], menu) - if pillager and not(menu and menu.get('unified')): - raise ValueError('Pillager rollout requires its verified unified item/skin pack') + if (pillager or crysknife) and not(menu and menu.get('unified')): + raise ValueError('This rollout requires its verified unified item/skin pack') servers, ids, roots, units = [], set(), set(), set() for server in inventory['servers']: sid, unit = server['id'], server['serviceUnit'] @@ -116,11 +117,17 @@ def plan(artifacts, inventory, expected_source): raise ValueError('Server private prerequisites must be explicitly provided and reviewed') chosen = [files[name] for name in selected] + [prerequisites[key] for key in selected_prerequisites] wanted = {entry['name'].casefold() for entry in chosen} - uses_menu='dunemenus' in wanted or bool(menu and menu.get('unified')) - if menu and menu.get('unified') and 'dunerealmsgui' not in wanted: + uses_menu='dunemenus' in wanted or bool(menu and menu.get('unified') and not crysknife) + if menu and menu.get('unified') and not crysknife and 'dunerealmsgui' not in wanted: raise ValueError('Unified pack rollout must select its matching DunerealmsGUI adapter') - if not pillager and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}: + if not (pillager or crysknife) and wanted - {'dunemenus','dunerealmsgui','dunenpc','dunelobby','mcgui'}: raise ValueError('GUI rollout must retain working Ess/JARVIS/Core/Terrain binaries') + if crysknife and ( + sid != 'arrakis' or unit != 'dune-arrakis.service' + or root != Path('/opt/dunerealms/servers/arrakis') + or wanted != {'jarvistranslator','duneterrain'} or selected_prerequisites + ): + raise ValueError('Crysknife rollout is restricted to the Arrakis JARVIS and Terrain pair') if pillager: if sid not in {'lobby','arrakis','caladan','giedi_prime','kaitain','sigma_draconis_iv'}: raise ValueError('Pillager rollout requires a reviewed backend identity') @@ -198,6 +205,23 @@ def plan(artifacts, inventory, expected_source): for path in plugins.glob('*.jar'): if path.name not in {p['filename'] for p in previous} and path.name not in retained_names: retained.append({'filename':path.name,'sha256':digest(path),'metadata':metadata(path)}) + if crysknife: + incoming = {entry['name'].casefold(): entry for entry in chosen} + pins = {'jarvistranslator': '663c28c5fb246b3d5c14b2faeaf0b6c000e38a53b3d45459221e4d3b85f242c3', + 'duneterrain': REVIEWED_TERRAIN_SHA256} + for name, prior_pin in pins.items(): + installed = existing_paths.get(name) + if installed is None or digest(installed) not in {prior_pin, incoming[name]['sha256']}: + raise ValueError('Crysknife rollout runtime differs from the reviewed pin: ' + name) + vendor, worldguard = (existing_paths.get(name) for name in ('medievalfactions', 'worldguard')) + if vendor is None or worldguard is None: + raise ValueError('Crysknife rollout requires the existing vendor runtimes') + abi_result = verify_pillager_abi(incoming['jarvistranslator']['source'], vendor, artifacts, worldguard) + abi_result['terrain'] = verify_pillager_terrain(incoming['duneterrain']['source'], + json.loads((artifacts/'retained-arrakis-terrain.json').read_text())) + replaced = {entry['filename'] for entry in previous} + retained = [{'filename': path.name, 'sha256': digest(path), 'metadata': metadata(path)} + for path in sorted(plugins.glob('*.jar')) if path.name not in replaced] configurations = [] if uses_menu: if menu is None: diff --git a/tools/plugin_pillager_abi.py b/tools/plugin_pillager_abi.py index e37dcb95..0b39ea39 100644 --- a/tools/plugin_pillager_abi.py +++ b/tools/plugin_pillager_abi.py @@ -7,7 +7,7 @@ import sys import zipfile sys.path.insert(0,str(Path(__file__).resolve().parent)) from plugin_backend_abi import jar_classes -REVIEWED_TERRAIN_SHA256='d373aa5e0b83c85c8270f099df46bdb6343565434a20976de2f5ffff6ecf6748' +REVIEWED_TERRAIN_SHA256='30531db30c016f76034b4c488aa690edce69ff79145193b57b381e3b8cdc204c' def verify_contract(path,fixture,require_hash=False): diff --git a/tools/test_plugin_resource_pack.py b/tools/test_plugin_resource_pack.py index c9812073..0825140e 100644 --- a/tools/test_plugin_resource_pack.py +++ b/tools/test_plugin_resource_pack.py @@ -87,7 +87,10 @@ class CompletePackTests(unittest.TestCase): pack.Closure(custom,dict(older,**files)).validate() pack.validate_block_layer(files,older,[r['path'] for r in additions]) - self.assertEqual(set(files),set(baseline)|set(changes)|{'CREDITS-Excalibur.txt'}) + native_items={f'assets/dunerealms/{kind}/{item}.{extension}' + for item in ('crysknife','maker_tooth') + for kind,extension in (('items','json'),('models/item','json'),('textures/item','png'))} + self.assertEqual(set(files),set(baseline)|set(changes)|{'CREDITS-Excalibur.txt'}|native_items) else:self.assertEqual(set(files),set(baseline)) for key,expected in baseline.items(): if key!='pack.mcmeta':self.assertEqual(hashlib.sha256(files[key]).hexdigest(),changes.get(key,expected),key)