Rename the DuneChest devices to their Ixian labels #40

Merged
unimatrix merged 2 commits from feat/dunechest-planets-ixian-labels into main 2026-11-30 19:50:14 +01:00
9 changed files with 135 additions and 29 deletions

View file

@ -1,6 +1,6 @@
plugins { java }
group = "com.example"
version = "1.0.6"
version = "1.0.7"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")

View file

@ -13,6 +13,13 @@ import org.bukkit.plugin.Plugin;
/** The three custom items, their recipes, and how to recognise them. */
public final class StorageItems {
public static final String ENDER = "ender_chest", HOPPER = "speed_hopper", CRAFTER = "auto_crafter", WRENCH = "wrench", BEACON = "dune_beacon";
static final String POWERCORE_NAME = "Ixian Powercore MK XIV";
static final String REPLICATOR_NAME = "Ixian Replicator MK XIV";
static String hopperName(int tier) {
return "Ixian sorting devices MK " + (StorageRules.Tier.of(tier).ordinal() + 1);
}
private final Plugin plugin; final NamespacedKey type, tier, colors, owner, priv, filter, whitelist, primary, secondary;
StorageItems(Plugin plugin) {
@ -33,13 +40,13 @@ public final class StorageItems {
lore.add(gray("Chests with the same three colours share one inventory."));
lore.add(gray("Right-click a dye on a pad, or use the colour menu.")); lore.add(gray("Right-click a diamond to make it private.")); lore.add(gray("Sneak + empty hand: colour menu.")); m.setItemModel(new NamespacedKey("dunerealms", "ender_chest")); }
case HOPPER -> { int t = Math.max(1, Math.min(3, tierNumber)); var tr = StorageRules.Tier.of(t); pdc.set(tier, PersistentDataType.INTEGER, t);
m.displayName(name("Speed Hopper Mk " + "I".repeat(t), t == 1 ? NamedTextColor.GOLD : t == 2 ? NamedTextColor.AQUA : NamedTextColor.LIGHT_PURPLE));
m.displayName(name(hopperName(t), hopperColour(t)));
lore.add(gray(String.format(Locale.ROOT, "%.0f items/s (vanilla 2.5)", tr.itemsPerSecond()))); lore.add(gray("Sneak + empty hand: item filter.")); lore.add(gray("Or left-click with a Wrench.")); m.setItemModel(new NamespacedKey("dunerealms", "speed_hopper_" + t)); }
case BEACON -> { m.displayName(name("Dune Beacon", NamedTextColor.AQUA));
case BEACON -> { m.displayName(name(POWERCORE_NAME, NamedTextColor.AQUA));
lore.add(gray("Works like a vanilla beacon, but with no beam")); lore.add(gray("and no need for open sky.")); lore.add(gray("Right-click to choose its effects."));
m.setItemModel(new NamespacedKey("dunerealms", "dune_beacon")); }
case WRENCH -> { m.displayName(name("Wrench", NamedTextColor.GOLD)); lore.add(gray("Left-click an Ender Chest, Speed Hopper or Auto Crafter")); lore.add(gray("to open its panel. Works on Bedrock too.")); m.setItemModel(new NamespacedKey("dunerealms", "wrench")); m.setMaxStackSize(1); }
default -> { m.displayName(name("Auto Crafter", NamedTextColor.GREEN)); lore.add(gray("Crafts from the container above into the container below.")); lore.add(gray("Right-click to set the recipe.")); }
case WRENCH -> { m.displayName(name("Wrench", NamedTextColor.GOLD)); lore.add(gray("Left-click a DuneChest device to open its panel.")); lore.add(gray("Works on Bedrock too.")); m.setItemModel(new NamespacedKey("dunerealms", "wrench")); m.setMaxStackSize(1); }
default -> { m.displayName(name(REPLICATOR_NAME, NamedTextColor.GREEN)); lore.add(gray("Crafts from the container above into the container below.")); lore.add(gray("Right-click to set the recipe.")); }
}
m.lore(lore); m.setEnchantmentGlintOverride(true);
item.setItemMeta(m); return item;
@ -52,6 +59,41 @@ public final class StorageItems {
it.setItemMeta(m); return it;
}
private static NamedTextColor hopperColour(int tier) {
return tier == 1 ? NamedTextColor.GOLD : tier == 2 ? NamedTextColor.AQUA : NamedTextColor.LIGHT_PURPLE;
}
private static Component legacyHopperName(int tier) {
return name("Speed Hopper Mk " + "I".repeat(tier), hopperColour(tier));
}
private static ItemStack withDisplayName(ItemStack original, Component label) {
ItemStack copy = original.asOne();
ItemMeta meta = copy.getItemMeta();
meta.displayName(label);
copy.setItemMeta(meta);
return copy;
}
private static RecipeChoice.ExactChoice hopperChoice(ItemStack current, int tier) {
return new RecipeChoice.ExactChoice(current, withDisplayName(current, legacyHopperName(tier)));
}
boolean matchesCraftingIngredient(ItemStack template, ItemStack source) {
if (template.isSimilar(source)) return true;
if (template.getType() != Material.HOPPER || source.getType() != Material.HOPPER
|| !HOPPER.equals(typeOf(template)) || !HOPPER.equals(typeOf(source))) return false;
int tier = tierOf(template);
if (tier < 1 || tier > 3 || tierOf(source) != tier) return false;
Component oldName = legacyHopperName(tier);
Component currentName = name(hopperName(tier), hopperColour(tier));
Component templateName = template.getItemMeta().displayName();
Component sourceName = source.getItemMeta().displayName();
boolean sameTierRename = oldName.equals(templateName) && currentName.equals(sourceName)
|| currentName.equals(templateName) && oldName.equals(sourceName);
return sameTierRename && withDisplayName(template, sourceName).isSimilar(source);
}
private static Component name(String s, NamedTextColor c) { return Component.text(s, c).decoration(TextDecoration.ITALIC, false); }
private static Component gray(String s) { return Component.text(s, NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false); }
@ -93,8 +135,8 @@ public final class StorageItems {
ItemStack ender = create(ENDER, 1), mk1 = create(HOPPER, 1), mk2 = create(HOPPER, 2), mk3 = create(HOPPER, 3), crafter = create(CRAFTER, 1);
shaped("ender_chest", ender, new String[]{"OEO", "OBO", "OOO"}, 'O', Material.OBSIDIAN, 'E', Material.ENDER_EYE, 'B', Material.BARREL);
shaped("speed_hopper_1", mk1, new String[]{"GRG", "RHR", "GRG"}, 'G', Material.GOLD_INGOT, 'R', Material.REDSTONE, 'H', Material.HOPPER);
shaped("speed_hopper_2", mk2, new String[]{"DRD", "RIR", "DRD"}, 'D', Material.DIAMOND, 'R', Material.REDSTONE_BLOCK, 'I', new RecipeChoice.ExactChoice(mk1));
shaped("speed_hopper_3", mk3, new String[]{"NRN", "RIR", "NRN"}, 'N', Material.NETHERITE_INGOT, 'R', Material.REDSTONE_BLOCK, 'I', new RecipeChoice.ExactChoice(mk2));
shaped("speed_hopper_2", mk2, new String[]{"DRD", "RIR", "DRD"}, 'D', Material.DIAMOND, 'R', Material.REDSTONE_BLOCK, 'I', hopperChoice(mk1, 1));
shaped("speed_hopper_3", mk3, new String[]{"NRN", "RIR", "NRN"}, 'N', Material.NETHERITE_INGOT, 'R', Material.REDSTONE_BLOCK, 'I', hopperChoice(mk2, 2));
var bk = new NamespacedKey(plugin, "dune_beacon"); Bukkit.removeRecipe(bk);
var br = new org.bukkit.inventory.ShapelessRecipe(bk, create(BEACON, 1)); br.addIngredient(Material.BEACON); br.addIngredient(Material.ENDER_EYE); Bukkit.addRecipe(br);
shaped("wrench", create(WRENCH, 1), new String[]{"I I", " I ", " S "}, 'I', Material.IRON_INGOT, 'S', Material.STICK);

View file

@ -243,7 +243,7 @@ public final class StorageModule implements Listener, CommandExecutor {
}
private void openFilter(Player pl, String key, StorageData.Placed p) {
Inventory inv = menu("filter", key, 9, "Hopper Filter");
Inventory inv = menu("filter", key, 9, StorageItems.hopperName(p.tier));
for (int i = 0; i < 5 && i < p.filter.size(); i++) inv.setItem(i, new ItemStack(p.filter.get(i)));
inv.setItem(6, icon(p.whitelist ? Material.LIME_DYE : Material.RED_DYE, p.whitelist ? "Whitelist" : "Blacklist", "Click to switch", "Empty filter accepts everything."));
inv.setItem(8, icon(Material.PAPER, "Click a slot with an item to set it", "Click with an empty cursor to clear"));
@ -261,7 +261,7 @@ public final class StorageModule implements Listener, CommandExecutor {
private Inventory recipePreview(Menu holder, World world) {
StorageData.Placed placed = holder.recipeBlock;
Inventory preview = Bukkit.createInventory(holder, InventoryType.WORKBENCH, Component.text("Auto Crafter Recipe"));
Inventory preview = Bukkit.createInventory(holder, InventoryType.WORKBENCH, Component.text(StorageItems.REPLICATOR_NAME));
holder.inventory = preview;
for (int g = 0; g < placed.recipe.length; g++) {
ItemStack item = placed.recipe[g];
@ -437,7 +437,7 @@ public final class StorageModule implements Listener, CommandExecutor {
Recipe r = Bukkit.getCraftingRecipe(p.recipe.clone(), b.getWorld()); if (r == null) return;
ItemStack[] ingredients = src.getStorageContents();
ItemStack[] actualGrid = new ItemStack[p.recipe.length];
int[] consumption = StorageRules.matchIngredients(p.recipe, ingredients, actualGrid);
int[] consumption = StorageRules.matchIngredients(p.recipe, ingredients, actualGrid, items::matchesCraftingIngredient);
if (consumption == null) return;
Recipe actual = Bukkit.getCraftingRecipe(actualGrid, b.getWorld());
if (!(r instanceof Keyed expected) || !(actual instanceof Keyed matched)
@ -514,13 +514,13 @@ public final class StorageModule implements Listener, CommandExecutor {
int level = beaconLevel(b);
Inventory model = Bukkit.createInventory(null, 27); Map<Integer, Runnable> actions = new HashMap<>();
String now = p.primary == null ? "No effect set" : pretty(p.primary) + (p.secondary == null ? "" : " + " + (p.secondary.equals(p.primary) ? "power II" : pretty(p.secondary)));
model.setItem(4, legacyIcon(Material.SEA_LANTERN, "Dune Beacon", level == 0 ? "No pyramid below - build iron, gold, emerald, diamond or netherite blocks" : "Level " + level + " - range " + BeaconRules.range(level) + " blocks", now));
model.setItem(4, legacyIcon(Material.SEA_LANTERN, StorageItems.POWERCORE_NAME, level == 0 ? "No pyramid below - build iron, gold, emerald, diamond or netherite blocks" : "Level " + level + " - range " + BeaconRules.range(level) + " blocks", now));
var options = BeaconRules.primaries(level); int slot = 10;
for (String name : options) { final String choice = name; int sl = slot++;
model.setItem(sl, legacyIcon(effectIcon(name), pretty(name), level >= 4 ? "Choose, then pick a secondary" : "Click to set", level >= 4 ? "" : payText()));
actions.put(sl, () -> { if (level >= 4) beaconSecondary(pl, key, p, choice); else beaconConfirm(pl, key, p, choice, null); });
}
com.example.dunegui.NativeMenus.inventory(plugin, pl, "Dune Beacon", model, actions);
com.example.dunegui.NativeMenus.inventory(plugin, pl, StorageItems.POWERCORE_NAME, model, actions);
}
private void beaconSecondary(Player pl, String key, StorageData.Placed expected, String primary) {
Block block = currentBeacon(pl, key, expected);
@ -535,7 +535,7 @@ public final class StorageModule implements Listener, CommandExecutor {
actions.put(sl, () -> beaconConfirm(pl, key, expected, primary, choice)); }
model.setItem(slot, legacyIcon(Material.BARRIER, "No secondary", "Primary only"));
actions.put(slot, () -> beaconConfirm(pl, key, expected, primary, null));
com.example.dunegui.NativeMenus.inventory(plugin, pl, "Dune Beacon", model, actions);
com.example.dunegui.NativeMenus.inventory(plugin, pl, StorageItems.POWERCORE_NAME, model, actions);
}
private static boolean beaconPayment(ItemStack item) {
if (item == null || item.isEmpty() || !PAYMENT.contains(item.getType())) return false;
@ -574,7 +574,7 @@ public final class StorageModule implements Listener, CommandExecutor {
inventory.setItem(paymentSlot, payment.getAmount() == 1 ? null : payment.asQuantity(payment.getAmount() - 1));
}
p.primary = primary; p.secondary = secondary; data.dirty = true;
say(pl, "Beacon set: " + pretty(primary) + (secondary == null ? "" : " + " + (secondary.equals(primary) ? "power II" : pretty(secondary))) + ".");
say(pl, StorageItems.POWERCORE_NAME + " set: " + pretty(primary) + (secondary == null ? "" : " + " + (secondary.equals(primary) ? "power II" : pretty(secondary))) + ".");
beaconPulse(block, p);
}
@ -644,13 +644,13 @@ public final class StorageModule implements Listener, CommandExecutor {
/** Click-free way in for clients that cannot sneak-click: opens the settings of the storage block being looked at (within 5 blocks). */
private void settingsAtCrosshair(Player pl) {
Block b = pl.getTargetBlockExact(5); var p = b == null ? null : data.at(b);
if (p == null) { say(pl, "Look at an Ender Chest or Speed Hopper (within 5 blocks), or left-click it with a Wrench."); return; }
if (p == null) { say(pl, "Look at a DuneChest device within 5 blocks, or left-click it with a Wrench."); return; }
panel(pl, b, p);
}
// ---------- /dunechest give ----------
@Override public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
if (a.length >= 1 && a[0].equalsIgnoreCase("panel") && s instanceof Player pl) { settingsAtCrosshair(pl); return true; }
if (!s.hasPermission("dune.admin")) { s.sendMessage("Look at an Ender Chest or Speed Hopper and use a Wrench or /dunechest panel."); return true; }
if (!s.hasPermission("dune.admin")) { s.sendMessage("Look at a DuneChest device and use a Wrench or /dunechest panel."); return true; }
if (a.length < 2 || !a[0].equalsIgnoreCase("give")) { s.sendMessage("/dunechest give <player> <ender|hopper1|hopper2|hopper3|crafter|wrench|beacon> [amount]"); return true; }
Player t = Bukkit.getPlayerExact(a[1]); if (t == null || a.length < 3) { s.sendMessage("Player offline or missing item."); return true; }
ItemStack item = switch (a[2].toLowerCase(Locale.ROOT)) { case "ender" -> items.create(StorageItems.ENDER, 1); case "hopper1" -> items.create(StorageItems.HOPPER, 1);

View file

@ -1,6 +1,7 @@
package com.example.dunechest;
import java.util.*;
import java.util.function.BiPredicate;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
@ -75,7 +76,8 @@ public final class StorageRules {
}
/** Build a grid of real inputs and reserve their source slots without changing the inventory. */
static int[] matchIngredients(ItemStack[] template, ItemStack[] source, ItemStack[] actualGrid) {
static int[] matchIngredients(ItemStack[] template, ItemStack[] source, ItemStack[] actualGrid,
BiPredicate<ItemStack, ItemStack> matches) {
int[] consumption = new int[source.length];
for (int gridSlot = 0; gridSlot < template.length; gridSlot++) {
ItemStack ingredient = template[gridSlot];
@ -83,7 +85,7 @@ public final class StorageRules {
int slot = 0;
while (slot < source.length) {
ItemStack stack = source[slot];
if (stack != null && stack.getAmount() > consumption[slot] && ingredient.isSimilar(stack)) break;
if (stack != null && stack.getAmount() > consumption[slot] && matches.test(ingredient, stack)) break;
slot++;
}
if (slot == source.length) return null;

View file

@ -1,5 +1,5 @@
name: DuneChest
version: 1.0.6
version: 1.0.7
main: com.example.dunechest.DuneChest
api-version: '1.21.8'
softdepend: [floodgate, DuneMenus, DuneEss]

View file

@ -5,6 +5,9 @@ import com.example.dunechest.StorageModule;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
@ -35,7 +38,7 @@ public final class DuneChestPaperValidation extends JavaPlugin implements Listen
Bukkit.getScheduler().runTask(this, () -> {
try {
validateCrafter();
getLogger().info("DUNECHEST_VALIDATION {\"ok\":true,\"cases\":6}");
getLogger().info("DUNECHEST_VALIDATION {\"ok\":true,\"cases\":7}");
} catch (Exception | AssertionError failure) {
getLogger().log(java.util.logging.Level.SEVERE, "DUNECHEST_VALIDATION {\"ok\":false}", failure);
} finally {
@ -85,6 +88,18 @@ public final class DuneChestPaperValidation extends JavaPlugin implements Listen
throw new AssertionError("Valid upgrade did not credit and debit the exact stacks");
}
validateRecipePreview(module, table.getWorld(), placedType, placed, mk1, mk2);
ItemStack legacy = mk1.clone();
var legacyMeta = legacy.getItemMeta();
legacyMeta.displayName(Component.text("Speed Hopper Mk I", NamedTextColor.GOLD)
.decoration(TextDecoration.ITALIC, false));
legacy.setItemMeta(legacyMeta);
load(input, legacy, 4, redstone);
output.clear();
craft.invoke(module, table, placed);
if (!output.containsAtLeast(mk2, 1) || !input.isEmpty()) {
throw new AssertionError("Renaming the hopper broke upgrades using the previous name");
}
}
private void validateRecipePreview(StorageModule module, World world, Class<?> placedType,

View file

@ -60,11 +60,11 @@ class StorageRulesTest {
ItemStack mk2 = new HopperStack(2, 2);
ItemStack vanilla = new HopperStack(0, 64);
assertNull(StorageRules.matchIngredients(new ItemStack[]{mk1}, new ItemStack[]{vanilla, mk2}, new ItemStack[1]));
assertNull(StorageRules.matchIngredients(new ItemStack[]{mk1, mk1}, new ItemStack[]{vanilla, mk1}, new ItemStack[2]));
assertNull(StorageRules.matchIngredients(new ItemStack[]{mk1}, new ItemStack[]{vanilla, mk2}, new ItemStack[1], ItemStack::isSimilar));
assertNull(StorageRules.matchIngredients(new ItemStack[]{mk1, mk1}, new ItemStack[]{vanilla, mk1}, new ItemStack[2], ItemStack::isSimilar));
ItemStack[] actualGrid = new ItemStack[3];
assertArrayEquals(new int[]{0, 0, 2}, StorageRules.matchIngredients(
new ItemStack[]{mk2, null, mk2}, new ItemStack[]{vanilla, mk1, mk2}, actualGrid));
new ItemStack[]{mk2, null, mk2}, new ItemStack[]{vanilla, mk1, mk2}, actualGrid, ItemStack::isSimilar));
assertTrue(mk2.isSimilar(actualGrid[0]));
assertNull(actualGrid[1]);
assertEquals(1, actualGrid[2].getAmount());

View file

@ -52,14 +52,36 @@ def identity(path):
return result
DUNECHEST_PLANETS = {'arrakis', 'caladan', 'giedi_prime', 'kaitain', 'sigma_draconis_iv'}
DUNECHEST_FLEET_JAR = 'f797c8bea59817a761ab18d87b045258698881d38e9aff776462cedb7d94627a'
DUNECHEST_ORDOS_PREDECESSOR = '94e591f11f10c3174c821bbfc8734f50a9638981e17269db2682be6e36d8fb97'
DUNECHEST_PLANET_PREDECESSOR = 'a1cd67aeea65d4a9dc98b75b1466fd54a120213e3eef31582c9492d546e484c2'
def verify_dunechest_fleet_target(sid, root, unit, incoming, installed):
expected_root = Path('/opt/dunerealms/lobby') if sid == 'lobby' else Path('/opt/dunerealms/servers') / sid
if sid not in DUNECHEST_PLANETS | {'lobby'} or root != expected_root or unit != f'dune-{sid}.service':
raise ValueError('DuneChest fleet release requires an exact reviewed server root and unit')
if incoming != DUNECHEST_FLEET_JAR:
raise ValueError('Fleet release must install the exact reviewed DuneChest JAR')
allowed = {None, incoming} if sid == 'lobby' else {incoming}
if sid == 'sigma_draconis_iv':
allowed.add(DUNECHEST_ORDOS_PREDECESSOR)
elif sid in DUNECHEST_PLANETS:
allowed.add(DUNECHEST_PLANET_PREDECESSOR)
if installed not in allowed:
raise ValueError('Unexpected DuneChest fleet predecessor')
def plan(artifacts, inventory, expected_source):
mode=inventory.get('mode')
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest'}:
if mode not in {'gui-preserve-backends','pillager-preserve-economy','arrakis-crysknife','navigator','planet-dunechest','fleet-dunechest'}:
raise ValueError('An explicit supported rollout mode is required')
pillager=mode=='pillager-preserve-economy'
crysknife=mode=='arrakis-crysknife'
navigator=mode=='navigator'
dunechest=mode=='planet-dunechest'
fleet_dunechest=mode=='fleet-dunechest'
dunechest=mode=='planet-dunechest' or fleet_dunechest
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:
@ -101,6 +123,8 @@ def plan(artifacts, inventory, expected_source):
verify_public_menu(inventory['menuPack']['url'], menu)
if (pillager or crysknife or navigator or dunechest) and not(menu and menu.get('unified')):
raise ValueError('This rollout requires its verified unified item/skin pack')
if fleet_dunechest and menu['sha256'] != '25ae69ae7198002ebff65b1eafbb454be7df235f51cdc46bb6233aa0b3ceec7a':
raise ValueError('Fleet release must use the exact resource pack tested on Ordos')
if navigator:
from plugin_navigator_transition import verify_module as verify_navigator, verify_jarvis as verify_navigator_jarvis
transition=json.loads((artifacts/'navigator-transition.json').read_text())
@ -145,10 +169,11 @@ def plan(artifacts, inventory, expected_source):
expected={'dunemenus','dunerealmsgui'} | ({'jarvistranslator'} if sid in planets else set())
if sid not in planets|{'lobby'} or root!=target or unit!=f'dune-{sid}.service' or wanted!=expected or selected_prerequisites:
raise ValueError('Navigator rollout requires its reviewed server root, unit and plugin selection')
if dunechest and (
if dunechest and (wanted!={'dunechest'} or selected_prerequisites):
raise ValueError('DuneChest rollout allows only the DuneChest artifact')
if dunechest and not fleet_dunechest and (
sid not in {'arrakis','caladan','giedi_prime','kaitain','sigma_draconis_iv'}
or root!=Path('/opt/dunerealms/servers')/sid or unit!=f'dune-{sid}.service'
or wanted!={'dunechest'} or selected_prerequisites
):
raise ValueError('DuneChest rollout requires an exact planet root and only the DuneChest artifact')
if pillager:
@ -277,9 +302,11 @@ def plan(artifacts, inventory, expected_source):
installed=existing_paths.get('dunechest')
approved_dunechest = {
chosen[0]['sha256'],
'0c56c56e03310572e0fc1f603d4fd23230456c64ab9d2892f3a0849fb349a1ae',
DUNECHEST_ORDOS_PREDECESSOR,
}
if installed is not None and digest(installed) not in approved_dunechest:
if fleet_dunechest:
verify_dunechest_fleet_target(sid, root, unit, chosen[0]['sha256'], digest(installed) if installed else None)
elif installed is not None and digest(installed) not in approved_dunechest:
raise ValueError('Existing DuneChest differs from the approved release or predecessor')
replaced={entry['filename'] for entry in previous}
retained=[{'filename':path.name,'sha256':digest(path),'metadata':metadata(path)}

View file

@ -58,6 +58,26 @@ class FleetInstallerTests(unittest.TestCase):
def deployment(self):
return installer.plan(self.artifacts, self.inventory, SOURCE)
def test_dunechest_fleet_requires_exact_lobby_and_planet_predecessors(self):
check = installer.verify_dunechest_fleet_target
incoming = installer.DUNECHEST_FLEET_JAR
predecessor = installer.DUNECHEST_PLANET_PREDECESSOR
lobby = Path('/opt/dunerealms/lobby')
arrakis = Path('/opt/dunerealms/servers/arrakis')
sigma = Path('/opt/dunerealms/servers/sigma_draconis_iv')
check('lobby', lobby, 'dune-lobby.service', incoming, None)
check('arrakis', arrakis, 'dune-arrakis.service', incoming, predecessor)
check('sigma_draconis_iv', sigma, 'dune-sigma_draconis_iv.service', incoming, installer.DUNECHEST_ORDOS_PREDECESSOR)
for target in (
('lobby', arrakis, 'dune-lobby.service', incoming, None),
('lobby', lobby, 'dune-lobby.service', incoming, predecessor),
('arrakis', arrakis, 'dune-arrakis.service', incoming, None),
('sigma_draconis_iv', sigma, 'dune-sigma_draconis_iv.service', incoming, predecessor),
('arrakis', arrakis, 'dune-arrakis.service', predecessor, predecessor),
):
with self.subTest(target=target), self.assertRaises(ValueError):
check(*target)
def test_planning_is_read_only_and_requires_exact_source_and_hash(self):
before = {p.name: p.read_bytes() for p in self.plugins.iterdir()}
self.deployment()