diff --git a/.github/workflows/lobby.yml b/.github/workflows/lobby.yml new file mode 100644 index 00000000..c58bb92d --- /dev/null +++ b/.github/workflows/lobby.yml @@ -0,0 +1,28 @@ +name: Build Guild Lobby companion +on: + workflow_dispatch: + push: + branches: [main, beta] + paths: ['DuneLobby/**', 'worlds/**', '.github/workflows/lobby.yml'] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: '8.14' + - run: gradle -p DuneLobby build + - uses: actions/upload-artifact@v4 + with: + name: Dune-Guild-Lobby + path: | + DuneLobby/build/libs/*.jar + worlds/Dune-Guild-Lobby-1.1.0.zip + DuneLobby/README.md + DuneLobby/VALIDATION.md + if-no-files-found: error diff --git a/DuneLobby/README.md b/DuneLobby/README.md new file mode 100644 index 00000000..bd146364 --- /dev/null +++ b/DuneLobby/README.md @@ -0,0 +1,83 @@ +# Spacing Guild lobby world + +A separate **Minecraft Java / Paper 1.21.4 / Java 21** End-dimension lobby. The rebuilt 1.1.0 world is already built and saved in [`../worlds/Dune-Guild-Lobby-1.1.0.zip`](../worlds/Dune-Guild-Lobby-1.1.0.zip); the deterministic builder and runtime companion are here. It does not replace a planet world. + +![Actual Minecraft Navigator chamber](previews/actual-1.1.0/navigator-chamber.jpg) + +The image above is an actual Minecraft 1.21.4 client capture of the rebuilt world, using vanilla rendering. Version 1.1.0 replaces the simplified 1.0.0 draft. It has opaque interior walls, enclosed connecting halls and flat ceilings; no outside or sky views. The original AI overview remains in previews as a historical reference, not evidence of the delivered build. The independently decoded block plan is in previews/actual-1.1.0/. + +## Rooms + +| Room | Centre X/Z | Contents | +|---|---|---| +| Central spawn | 0 / 0 | Safe arrival at **0.5, 81, 10.5**, facing north; monumental amber Navigator tank on a broad stepped dais, upper galleries and Guild liaison | +| Starport / teleport | -78 / -58 | Dune II inspired square arrival apron, grounded frigate, control tower and **five raised launch pads** with striped edges, lights and destination consoles | +| Official Exchange | -66 / 40 | CHOAM counters, commodities, storage and Exchange Broker | +| News | 62 / -42 | Illustrated dispatch panel, reading benches and interactive news lecterns | +| Rules | 62 / 37 | Charter panel, benches and interactive rules lecterns | +| Smuggler exchange | -66 / 101 | Enclosed dim side passage, framed paintings, screens, brown awnings, pipes, crates and worn copper; separate **water** and **spice** seller NPCs | + +All rooms connect by enclosed corridors. Launch consoles ask for confirmation. There are no Nether portals: the starport is a landing/launch design. + +## Install the already built world + +1. Use a **separate lobby Paper backend**. Stop that server before copying files. Leave existing planet servers and worlds in place. +2. Extract the ZIP into the server directory. It contains `guild_lobby/`, `plugins/DuneLobby-1.1.0.jar`, and these setup instructions. Do not extract over an existing `guild_lobby`; preserve it separately first. +3. Install [ImageFrame from Spigot](https://www.spigotmc.org/resources/106031/). The tested version is **2026.1.5.0**, which lists Minecraft 1.21.4 support. With Python available, `python DuneLobby/tools/install_imageframe.py /path/to/lobby-server` downloads that exact dependency and verifies its SHA256. The third-party JAR is not vendored in this repository/package. Dependency source: (GPL-3.0). +4. Start Paper. DuneLobby loads `guild_lobby` as **THE_END**, preserves the saved blocks and restores the 25 ImageFrame paintings. Artwork is included in DuneLobby's JAR, so no remote artwork hosting is required. ImageFrame map IDs are allocated for this server rather than trusting IDs from another world. Keep ImageFrame installed to render the pictures. +5. `/lobby` returns to central spawn. Console `dunelobby verify` checks spawn clearance, room/pad/vendor accessibility, NPCs and artwork. Console `dunelobby artwork` restores decorations if required; it reuses registered image maps instead of creating duplicates. + +DuneLobby creates a world only when **console** runs `dunelobby build`, and refuses if a folder with that name already exists. This command is for reproducing a new world, not installing the included map. No planet file or existing lobby structure is regenerated on startup. To replace a 1.0.0 lobby, stop the server, preserve that old guild_lobby folder, and import the new ZIP; merely updating the JAR will not replace the draft geometry. + +Keep Paper's default primary world as a small bootstrap world; the plugin loads the End lobby as a secondary world and routes joins/respawns there. Do not use `guild_lobby` as `level-name`, since that loads it as the primary overworld before the plugin can select THE_END. Example **lobby backend** settings: + +```properties +level-name=lobby_bootstrap +level-type=minecraft:flat +generator-settings={"layers":[],"biome":"minecraft:the_void","structures":{}} +generate-structures=false +allow-nether=false +spawn-protection=0 +``` + +For an existing multiworld server instead of a dedicated backend, set `join-at-lobby: false` and `respawn-at-lobby: false` in `plugins/DuneLobby/config.yml` to preserve other plugins' routing. The shipped ZIP is a **Paper multiworld import**, not a standalone singleplayer save or a schematic. DuneLobby supplies the void generator and prevents new End terrain around the build. + +## Network and economy + +- Optional DuneEss: launch consoles call the player's existing `/duneess travel `, preserving configured fares, permissions and Arrakis checks. The Navigator liaison opens `/duneess travel`. +- Without DuneEss: consoles teleport to an already loaded planet world, or request a Velocity/Bungee `Connect` using the names in the lobby config. Requests have no delivery acknowledgment and charge no fare. Configure and test the destinations on your own network; no live server deployment is performed by this package. +- The Exchange Broker opens `/dune exchange` when DuneCore is installed. Without DuneCore it explains that the official market needs that integration; no fake Solaris balances are created. +- Both smuggler sellers work without DuneCore/Vault: one drinking water potion for 4 emeralds, one orange-dye spice sample for 8 emeralds (configurable). **These are lobby barter goods**, deliberately not tagged finite Arrakis water or redeemable DuneCore spice. This avoids minting Solaris or faction rewards outside the existing economy. They are stationary, named, invulnerable villagers with custom merchant menus. +- News and rules lecterns display the text in the companion config. Run `dunelobby reload` after edits. Illustrated noticeboards are static artwork, not a live website feed. + +Velocity example (adapt the backend address): + +```toml +[servers] +lobby = "127.0.0.1:25570" +# Keep existing planet entries. +try = ["lobby"] + +[advanced] +bungee-plugin-message-channel = true +``` + +Use your existing modern forwarding configuration and forwarding secret. Do not install DuneTerrain on a dedicated lobby backend, since it is intended to create a selected planet. DuneCore/DuneEss remain optional and their shared economy/database setup is unchanged. + +## Protection and build + +Visitors cannot break/place blocks, manipulate frames, use ordinary container blocks or damage entities in the lobby. Explosions do not damage blocks, hostile spawns are suppressed, and falling below the build returns the player to spawn. Operators have `dunelobby.build` for maintenance; other worlds are unaffected. This companion does not implement a general-purpose region protection system for other plugins' console edits. + +Build the companion with `gradle -p DuneLobby build` using Java 21 and Gradle 8.14+. Typographic boards are reproducible with `python DuneLobby/tools/prepare_boards.py` (Pillow). Existing project artwork is copied unchanged from `docs/artwork`. The build embeds the local artwork; it downloads no artwork. + +Design references: [1984 Navigator / heighliner production artwork](https://www.duneinfo.com/arrakis/navigators/), [Dune II Starport](https://dunerts.wiki.gg/wiki/Starport_(Dune_II)). Reference designs are interpreted in blocks; the original game sprites and film stills are not included as new assets. + +## Validation + +See `VALIDATION.md` for the recorded build, actual saved-world checks and limitations. The package includes `manifest.json` with file hashes. No live network, paid Solaris transfer or real player account is used in local validation. + +## Rendering and compatibility + +There are 25 ImageFrame paintings (1,024 map tiles), plus framed item displays and lit copper/blackstone borders. Local artwork is embedded in the companion JAR. No client mod or shader is required. The visual check used the installed Java client against a loopback-only test server. Computer control was then stopped by the user; no further app input was issued. + +The companion disables the End dragon-fight controller using the tested Paper 1.21.4 ServerLevel.setDragonFight API through a narrow reflection adapter. This prevents a boss bar, dragon and exit-portal generation after a real player joins. Other Paper versions require validation; incompatible versions report an explicit error instead of silently claiming the lobby is ready. diff --git a/DuneLobby/VALIDATION.md b/DuneLobby/VALIDATION.md new file mode 100644 index 00000000..f73d55c6 --- /dev/null +++ b/DuneLobby/VALIDATION.md @@ -0,0 +1,31 @@ +# Guild lobby 1.1.0 validation — 2026-10-18 + +This rebuild supersedes the simplified 1.0.0 draft. The current package is `worlds/Dune-Guild-Lobby-1.1.0.zip` (21,383,329 bytes), SHA256 `f66c0bc3192a1b1010b28e7123af60133b7ec32a2eb5fc62ca88e6d36a2bc5cf`. + +## Changes and visual evidence + +- Monumental Navigator tank, broad stepped dais, gold floor medallion, upper galleries, carved blackstone columns, short diagonal connections and furnished rooms replace the sparse grid layout. +- All connecting halls and room boundaries are opaque interiors with flat ceilings. There are no exterior/sky views. The outer enclosure is opaque too. +- Twenty-five ImageFrame paintings use 1,024 map tiles; fifteen separate item displays decorate the official market. Water and spice sellers remain separate NPCs in the dim, screened smuggler market. +- `previews/actual-1.1.0/navigator-chamber.jpg` is an actual installed Minecraft Java 1.21.4 client window capture, using vanilla rendering. It was displayed to the user before their approval. It is not an AI rendering. The historical concept remains separately labelled. +- The real client joined the local loopback test server. An End dragon-controller issue discovered during that check was corrected: the companion disables the controller through the tested Paper 1.21.4 adapter, preventing the boss bar, dragon and vanilla exit portal from appearing. +- Computer control was stopped by the user after the visual check. No further app input was issued. The previously captured game image was exported as an artifact through file operations. + +## Checks completed + +1. Java 21 / Gradle 8.14 build passed against Paper API 1.21.4. There is no separate unit-test suite; these checks run the real server and decode the saved world. +2. Built a fresh world on Paper 1.21.4 build 232 with ImageFrame 2026.1.5.0. The builder performed 565,328 block placements. +3. Restarted with the final companion, restored all 25 image maps and verified the saved world without regenerating its blocks. +4. Runtime flood-fill and environment checks passed: six rooms, both seller approaches, five launch pads, four named NPCs, 1,024 artwork frames, clear supported spawn, opaque flat ceiling/enclosure and no active dragon battle controller. +5. After clean shutdown, an independent Anvil/NBT reader confirmed data version 4189, spawn 0/81/10, 386,882 non-air blocks in the inspected height range (including enclosure), four villagers, 1,024 glowing painting frames, fifteen item frames, six text labels, and no Ender Dragon. It checked the flat ceiling and outer walls directly from saved blocks. Results and an actual-block plan are in `previews/actual-1.1.0/`. +6. ZIP integrity check passed. The package includes a per-file SHA256 manifest, the actual saved End chunks, companion JAR and setup/dependency installer. Locks, UUID identity files, player data and the server executable are excluded. Local test servers were shut down. + +Final runtime output: + +```text +GUILD_VERIFY PASS walkable=13791 artwork=1024 [] +``` + +## Limits + +The screenshot verifies the Navigator interior; it is not a claim of pixel-for-pixel equivalence to the earlier AI art. Other room geometry, paint placement and connectivity were checked from the saved world and running server. Merchant clicks, paid Solaris transfers, remote proxy destinations and production concurrency were not exercised. No live server was deployed. The smuggler merchants use emerald barter and sample goods, separate from redeemable faction rewards. Paper versions other than the tested 1.21.4 require validation because the dragon-controller adapter is version-specific. Install the new world folder to replace a 1.0.0 draft; updating only the JAR deliberately leaves existing blocks intact. diff --git a/DuneLobby/artwork/arrakis-cover.png b/DuneLobby/artwork/arrakis-cover.png new file mode 100644 index 00000000..4cc00ac0 Binary files /dev/null and b/DuneLobby/artwork/arrakis-cover.png differ diff --git a/DuneLobby/artwork/exchange.png b/DuneLobby/artwork/exchange.png new file mode 100644 index 00000000..c92d16ea Binary files /dev/null and b/DuneLobby/artwork/exchange.png differ diff --git a/DuneLobby/artwork/guild-navigator.png b/DuneLobby/artwork/guild-navigator.png new file mode 100644 index 00000000..ffea0c0f Binary files /dev/null and b/DuneLobby/artwork/guild-navigator.png differ diff --git a/DuneLobby/artwork/news.png b/DuneLobby/artwork/news.png new file mode 100644 index 00000000..64e38914 Binary files /dev/null and b/DuneLobby/artwork/news.png differ diff --git a/DuneLobby/artwork/rules.png b/DuneLobby/artwork/rules.png new file mode 100644 index 00000000..e54da647 Binary files /dev/null and b/DuneLobby/artwork/rules.png differ diff --git a/DuneLobby/artwork/shai-hulud-encounter.png b/DuneLobby/artwork/shai-hulud-encounter.png new file mode 100644 index 00000000..410d5033 Binary files /dev/null and b/DuneLobby/artwork/shai-hulud-encounter.png differ diff --git a/DuneLobby/artwork/sietch-panorama.png b/DuneLobby/artwork/sietch-panorama.png new file mode 100644 index 00000000..8b70aa46 Binary files /dev/null and b/DuneLobby/artwork/sietch-panorama.png differ diff --git a/DuneLobby/artwork/smuggler-spice-mission.png b/DuneLobby/artwork/smuggler-spice-mission.png new file mode 100644 index 00000000..4b3aa32c Binary files /dev/null and b/DuneLobby/artwork/smuggler-spice-mission.png differ diff --git a/DuneLobby/artwork/smuggler-water-camp.png b/DuneLobby/artwork/smuggler-water-camp.png new file mode 100644 index 00000000..07236060 Binary files /dev/null and b/DuneLobby/artwork/smuggler-water-camp.png differ diff --git a/DuneLobby/artwork/spice-expedition.png b/DuneLobby/artwork/spice-expedition.png new file mode 100644 index 00000000..b9b50e68 Binary files /dev/null and b/DuneLobby/artwork/spice-expedition.png differ diff --git a/DuneLobby/artwork/world-0.png b/DuneLobby/artwork/world-0.png new file mode 100644 index 00000000..8bcb66b3 Binary files /dev/null and b/DuneLobby/artwork/world-0.png differ diff --git a/DuneLobby/artwork/world-1.png b/DuneLobby/artwork/world-1.png new file mode 100644 index 00000000..adf80037 Binary files /dev/null and b/DuneLobby/artwork/world-1.png differ diff --git a/DuneLobby/artwork/world-2.png b/DuneLobby/artwork/world-2.png new file mode 100644 index 00000000..031610ea Binary files /dev/null and b/DuneLobby/artwork/world-2.png differ diff --git a/DuneLobby/artwork/world-3.png b/DuneLobby/artwork/world-3.png new file mode 100644 index 00000000..ec6e5cf6 Binary files /dev/null and b/DuneLobby/artwork/world-3.png differ diff --git a/DuneLobby/artwork/world-4.png b/DuneLobby/artwork/world-4.png new file mode 100644 index 00000000..7ba50f52 Binary files /dev/null and b/DuneLobby/artwork/world-4.png differ diff --git a/DuneLobby/build.gradle.kts b/DuneLobby/build.gradle.kts new file mode 100644 index 00000000..587cf6f0 --- /dev/null +++ b/DuneLobby/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { java } +group = "com.example" +version = "1.1.0" +repositories { mavenCentral(); maven("https://repo.papermc.io/repository/maven-public/") } +dependencies { compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") } +java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) } +tasks.withType { options.encoding = "UTF-8" } +tasks.processResources { from("artwork") { into("artwork") } } diff --git a/DuneLobby/previews/README.md b/DuneLobby/previews/README.md new file mode 100644 index 00000000..f2ed4bcf --- /dev/null +++ b/DuneLobby/previews/README.md @@ -0,0 +1,12 @@ +## Delivered 1.1.0 interior + +ctual-1.1.0/navigator-chamber.jpg is the actual installed Minecraft Java 1.21.4 client, captured during local visual verification. It is not an AI rendering. ctual-1.1.0/saved-world-plan.png and JSON are decoded from the saved blocks. The approved revision uses opaque interiors and flat ceilings; the older roofless concept below is retained only as historical design material. + +# Lobby previews + +- `guild-lobby-concept.png`: built-in ImageGen concept rendering, generated 2026-10-18. This is a visual design reference, not a Minecraft screenshot. +- `saved-world-plan.png` and `.json`: rendered and inspected from the actual saved Anvil world by `tools/inspect_world.py`; no image-generation model is used for the plan. + +Final ImageGen prompt (reference image was the preceding five-room starport concept): + +> Update this Minecraft Dune Spacing Guild lobby rendering with a SIXTH room, a shady SMUGGLER EXCHANGE. Preserve every existing room: central spawn with amber Guild Navigator tank, Dune II-inspired STARPORT / TELEPORT upper left with square landing and launch pads and block-built frigate, official EXCHANGE left, NEWS upper right, RULES right, purple End atmosphere and gold/blackstone architecture. Widen framing or pull back as needed to show all six distinct connected rooms clearly. Add the new smugglers' den as a substantial enclosed annex in the lower foreground below the official Exchange, attached via a narrow dim side corridor branching off the official Exchange. It must be visibly different: lower vaulted ceiling (removed for cutaway), dark worn stone, rusty copper pipes, patchwork brown cloth awnings/screens, stacked barrels and crates, low amber lanterns, discreet violet accents. TWO separate Minecraft villager seller NPCs behind separate screened market counters: WATER SELLER next to blue glass water vessels and a cauldron, SPICE SELLER beside orange spice samples and sacks represented by brown blocks and barrels. Small clear labels over counters 'WATER' and 'SPICE'. Shady illicit back-room atmosphere but navigable and readable. Clearly label the new annex 'SMUGGLER EXCHANGE' with matching clean external architectural callout. Keep five other callouts correctly pointing to their rooms. Floor of annex is fully supported and bounded, no unsafe holes; visible corridor connection. High-quality architectural Minecraft shader concept overview, block-built geometry and pixel textures, no photoreal smooth creatures. Retain wall artwork in framed maps. One wide coherent elevated isometric roofless cutaway, clean presentation, no HUD or watermark. diff --git a/DuneLobby/previews/actual-1.1.0/navigator-chamber.jpg b/DuneLobby/previews/actual-1.1.0/navigator-chamber.jpg new file mode 100644 index 00000000..7685593e Binary files /dev/null and b/DuneLobby/previews/actual-1.1.0/navigator-chamber.jpg differ diff --git a/DuneLobby/previews/actual-1.1.0/saved-world-plan.json b/DuneLobby/previews/actual-1.1.0/saved-world-plan.json new file mode 100644 index 00000000..582604bb --- /dev/null +++ b/DuneLobby/previews/actual-1.1.0/saved-world-plan.json @@ -0,0 +1,23 @@ +{ + "minecraft": "1.21.4", + "data_version": 4189, + "spawn": [ + 0, + 81, + 10 + ], + "saved_non_air_blocks_in_build_height": 386882, + "entities": { + "minecraft:glow_item_frame": 1024, + "minecraft:text_display": 6, + "minecraft:item_frame": 15, + "minecraft:villager": 4 + }, + "npc_roles": { + "exchange": 1, + "water": 1, + "spice": 1, + "liaison": 1 + }, + "checks": "PASS: saved spawn, five launch pads, six rooms, four unique NPCs, 1024 artwork frames, opaque enclosure and flat ceiling, no dragon" +} diff --git a/DuneLobby/previews/actual-1.1.0/saved-world-plan.png b/DuneLobby/previews/actual-1.1.0/saved-world-plan.png new file mode 100644 index 00000000..5964125b Binary files /dev/null and b/DuneLobby/previews/actual-1.1.0/saved-world-plan.png differ diff --git a/DuneLobby/previews/guild-lobby-concept.png b/DuneLobby/previews/guild-lobby-concept.png new file mode 100644 index 00000000..f280684b Binary files /dev/null and b/DuneLobby/previews/guild-lobby-concept.png differ diff --git a/DuneLobby/previews/saved-world-plan.json b/DuneLobby/previews/saved-world-plan.json new file mode 100644 index 00000000..b97981fa --- /dev/null +++ b/DuneLobby/previews/saved-world-plan.json @@ -0,0 +1,21 @@ +{ + "minecraft": "1.21.4", + "data_version": 4189, + "spawn": [ + 0, + 81, + 10 + ], + "saved_non_air_blocks_in_build_height": 109535, + "entities": { + "minecraft:glow_item_frame": 276, + "minecraft:villager": 4 + }, + "npc_roles": { + "exchange": 1, + "water": 1, + "spice": 1, + "liaison": 1 + }, + "checks": "PASS: saved spawn, five launch pads, six rooms, four unique NPCs, 276 artwork frames, no dragon" +} diff --git a/DuneLobby/previews/saved-world-plan.png b/DuneLobby/previews/saved-world-plan.png new file mode 100644 index 00000000..99d9f542 Binary files /dev/null and b/DuneLobby/previews/saved-world-plan.png differ diff --git a/DuneLobby/settings.gradle.kts b/DuneLobby/settings.gradle.kts new file mode 100644 index 00000000..be5a57e8 --- /dev/null +++ b/DuneLobby/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "DuneLobby" diff --git a/DuneLobby/src/main/java/com/example/dunelobby/DuneLobby.java b/DuneLobby/src/main/java/com/example/dunelobby/DuneLobby.java new file mode 100644 index 00000000..97607ee7 --- /dev/null +++ b/DuneLobby/src/main/java/com/example/dunelobby/DuneLobby.java @@ -0,0 +1,235 @@ +package com.example.dunelobby; + +import org.bukkit.*; +import org.bukkit.block.BlockFace; +import org.bukkit.command.*; +import org.bukkit.entity.*; +import org.bukkit.event.*; +import org.bukkit.event.block.*; +import org.bukkit.event.entity.*; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.*; +import org.bukkit.event.player.*; +import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.WorldInfo; +import org.bukkit.inventory.*; +import org.bukkit.inventory.meta.*; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.plugin.java.JavaPlugin; +import java.io.*; +import java.nio.file.*; +import java.util.*; + +/** Separate optional lobby backend; never changes planet terrain or existing world blocks. */ +public final class DuneLobby extends JavaPlugin implements Listener, CommandExecutor { + private World lobby; + private NamespacedKey roleKey; + private final Map travelCooldown = new HashMap<>(); + private static final class TravelMenu implements InventoryHolder { + final String planet; final Inventory inventory; + TravelMenu(String planet) { this.planet=planet; inventory=Bukkit.createInventory(this,9,"Guild departure: "+planet); } + public Inventory getInventory() { return inventory; } + } + public static final class VoidGenerator extends ChunkGenerator { + @Override public void generateNoise(WorldInfo info, Random random,int x,int z,ChunkData data) {} + @Override public boolean shouldGenerateNoise() { return false; } + @Override public boolean shouldGenerateSurface() { return false; } + @Override public boolean shouldGenerateBedrock() { return false; } + @Override public boolean shouldGenerateCaves() { return false; } + @Override public boolean shouldGenerateDecorations() { return false; } + @Override public boolean shouldGenerateMobs() { return false; } + @Override public boolean shouldGenerateStructures() { return false; } + } + @Override public void onEnable() { + saveDefaultConfig(); roleKey=new NamespacedKey(this,"role"); + getCommand("lobby").setExecutor(this); getCommand("dunelobby").setExecutor(this); + Bukkit.getPluginManager().registerEvents(this,this); + Bukkit.getMessenger().registerOutgoingPluginChannel(this,"BungeeCord"); + Bukkit.getScheduler().runTask(this,()-> { + File folder=new File(Bukkit.getWorldContainer(),getConfig().getString("world","guild_lobby")); + if(new File(folder,"level.dat").isFile()) { + loadWorld(); ensureNpcs(); + if(Bukkit.getPluginManager().isPluginEnabled("ImageFrame")) Bukkit.getScheduler().runTaskLater(this,()->new LobbyArtwork(this,lobby).restore(),80); + getLogger().info("Existing Guild lobby loaded; structure left unchanged."); + } else getLogger().info("No lobby imported. Console: dunelobby build to create a NEW world."); + }); + } + private void loadWorld() { + String name=getConfig().getString("world","guild_lobby"); + if(!name.matches("[A-Za-z0-9_-]+")) throw new IllegalArgumentException("world must be a simple folder name"); + lobby=Bukkit.createWorld(new WorldCreator(name).environment(World.Environment.THE_END).generator(new VoidGenerator()).generateStructures(false)); + disableDragonBattle(); + lobby.setSpawnLocation(new Location(lobby,.5,81,10.5,180,0)); + lobby.setGameRule(GameRule.DO_MOB_SPAWNING,false); lobby.setGameRule(GameRule.DO_FIRE_TICK,false); + lobby.setGameRule(GameRule.MOB_GRIEFING,false); lobby.setGameRule(GameRule.DO_DAYLIGHT_CYCLE,false); + lobby.setGameRule(GameRule.DO_WEATHER_CYCLE,false); lobby.setGameRule(GameRule.DO_INSOMNIA,false); + lobby.setGameRule(GameRule.KEEP_INVENTORY,true); lobby.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS,false); + lobby.setGameRule(GameRule.SPAWN_RADIUS,0); lobby.setTime(18000); lobby.setDifficulty(Difficulty.PEACEFUL); + lobby.setPVP(false); lobby.getWorldBorder().setCenter(-16,16); lobby.getWorldBorder().setSize(330); + lobby.setKeepSpawnInMemory(false); + // Keep the bounded lobby footprint loaded: NPC/art restoration must see all rooms. + for(int cx=-8;cx<=6;cx++) for(int cz=-7;cz<=8;cz++) lobby.addPluginChunkTicket(cx,cz,this); + for(EnderDragon dragon:lobby.getEntitiesByClass(EnderDragon.class)) dragon.remove(); + } + private void disableDragonBattle() { + // Paper 1.21.4 exposes ServerLevel.setDragonFight. Clearing the controller prevents + // both a boss bar and vanilla portal/dragon generation after a real player joins. + try { + Object handle=lobby.getClass().getMethod("getHandle").invoke(lobby); + var setter=Arrays.stream(handle.getClass().getMethods()) + .filter(m->m.getName().equals("setDragonFight")&&m.getParameterCount()==1).findFirst().orElseThrow(); + setter.invoke(handle,new Object[]{null}); + } catch(ReflectiveOperationException|NoSuchElementException e) { + throw new IllegalStateException("This lobby requires the tested Paper 1.21.4 dragon-controller API",e); + } + } + private boolean inLobby(World world) { return lobby!=null && world.equals(lobby); } + private void ensureNpcs() { + for(int x=-8;x<=6;x++) for(int z=-6;z<=8;z++) lobby.getChunkAt(x,z).load(); + npc("liaison","Guild Navigator Liaison",13,87,-11,Villager.Profession.CLERIC); + npc("exchange","CHOAM Exchange Broker",-82,81,23,Villager.Profession.LIBRARIAN); + npc("water","Discreet Water Seller",-78,81,110,Villager.Profession.FISHERMAN); + npc("spice","Discreet Spice Seller",-54,81,110,Villager.Profession.LEATHERWORKER); + } + private void npc(String role,String name,int x,int y,int z,Villager.Profession profession) { + for(Villager entity:lobby.getEntitiesByClass(Villager.class)) if(role.equals(entity.getPersistentDataContainer().get(roleKey,PersistentDataType.STRING))) return; + lobby.spawn(new Location(lobby,x+.5,y,z+.5,180,0),Villager.class,v->{ + v.setCustomName(ChatColor.GOLD+name); v.setCustomNameVisible(true); v.setAI(false); v.setSilent(true); + v.setInvulnerable(true); v.setPersistent(true); v.setRemoveWhenFarAway(false); v.setProfession(profession); + v.setVillagerType(role.equals("water")||role.equals("spice")?Villager.Type.SWAMP:Villager.Type.DESERT); + v.getPersistentDataContainer().set(roleKey,PersistentDataType.STRING,role); v.setRecipes(List.of()); + }); + } + @Override public boolean onCommand(CommandSender sender,Command command,String label,String[] args) { + if(command.getName().equals("lobby")) { + if(sender instanceof Player p) { if(lobby==null) p.sendMessage("The Guild lobby is not loaded."); else p.teleport(lobby.getSpawnLocation()); } + return true; + } + if(args.length==0) { sender.sendMessage("/dunelobby build | artwork | verify | reload"); return true; } + switch(args[0].toLowerCase(Locale.ROOT)) { + case "build" -> { + if(sender instanceof Player) { sender.sendMessage("World creation is console-only."); return true; } + File target=new File(Bukkit.getWorldContainer(),getConfig().getString("world","guild_lobby")); + if(target.exists() || lobby!=null) { sender.sendMessage("Refusing to overwrite an existing world. Import it or choose a new world name."); return true; } + loadWorld(); long n=new LobbyBuilder(lobby).build(); ensureNpcs(); lobby.save(); + try { Files.writeString(lobby.getWorldFolder().toPath().resolve("DUNE-LOBBY.txt"),"DuneLobby 1.1.0 / Minecraft Java 1.21.4 / End lighting, opaque enclosure / spawn 0.5 81 10.5 yaw 180\n"); } + catch(IOException e) { getLogger().warning(e.toString()); } + sender.sendMessage("GUILD_BUILD_COMPLETE: "+n+" placements. Run dunelobby artwork, then dunelobby verify."); + } + case "artwork" -> { if(lobby!=null) new LobbyArtwork(this,lobby).install(); } + case "verify" -> { if(lobby==null) sender.sendMessage("Lobby not loaded."); else Bukkit.getScheduler().runTaskLater(this,()->verify(sender),10); } + case "reload" -> { reloadConfig(); sender.sendMessage("Rules, notices, trade prices and routing reloaded."); } + default -> sender.sendMessage("Unknown lobby operation."); + } + return true; + } + private void verify(CommandSender sender) { + List failures=new ArrayList<>(); + Location s=lobby.getSpawnLocation(); + if(lobby.getEnvironment()!=World.Environment.THE_END) failures.add("environment"); + if(lobby.getEnderDragonBattle()!=null) failures.add("dragon battle controller active"); + if(!lobby.getBlockAt(s.getBlockX(),80,s.getBlockZ()).getType().isSolid() || !lobby.getBlockAt(s.getBlockX(),81,s.getBlockZ()).isPassable() || !lobby.getBlockAt(s.getBlockX(),82,s.getBlockZ()).isPassable()) failures.add("spawn clearance"); + // Flood-fill two-block-high walkable cells with step height <= 1. + Set seen=new HashSet<>(); ArrayDeque todo=new ArrayDeque<>(); todo.add(new int[]{0,81,10}); + while(!todo.isEmpty()) { + int[] p=todo.removeFirst(); String k=p[0]+","+p[1]+","+p[2]; + if(p[0]<-120||p[0]>92||p[2]<-94||p[2]>128||p[1]<79||p[1]>101||!seen.add(k)) continue; + if(!walkable(p[0],p[1],p[2])) { seen.remove(k); continue; } + for(int[] d:new int[][]{{1,0},{-1,0},{0,1},{0,-1}}) for(int dy:new int[]{0,1,-1}) { + int x=p[0]+d[0],y=p[1]+dy,z=p[2]+d[1]; + if(!seen.contains(x+","+y+","+z) && walkable(x,y,z)) { todo.add(new int[]{x,y,z}); break; } + } + } + int[][] targets={{0,81,10},{-66,81,35},{62,81,-36},{66,81,30},{-66,81,100},{-78,81,-32},{-78,81,109},{-54,81,109}}; + for(int[] p:targets) if(!seen.contains(p[0]+","+p[1]+","+p[2])) failures.add("unreachable "+Arrays.toString(p)); + for(int[] p:LobbyBuilder.PADS) if(!seen.contains(p[0]+",83,"+p[1])) failures.add("launch pad "+Arrays.toString(p)); + for(int[] p:new int[][]{{0,10},{-78,-58},{-66,40},{62,-42},{62,37},{-66,101},{-30,-21},{31,21}}) + if(!lobby.getBlockAt(p[0],128,p[1]).getType().isOccluding()) failures.add("missing flat ceiling "+Arrays.toString(p)); + for(int y:new int[]{81,96,120}) for(int[] p:new int[][]{{-126,0},{96,0},{0,-98},{0,130}}) + if(!lobby.getBlockAt(p[0],y,p[1]).getType().isOccluding()) failures.add("visible sky boundary "+Arrays.toString(p)); + for(String role:List.of("liaison","exchange","water","spice")) if(lobby.getEntitiesByClass(Villager.class).stream().noneMatch(v->role.equals(v.getPersistentDataContainer().get(roleKey,PersistentDataType.STRING)))) failures.add("missing NPC "+role); + long art=lobby.getEntitiesByClass(ItemFrame.class).stream().filter(v->v.getPersistentDataContainer().has(new NamespacedKey(this,"art"),PersistentDataType.STRING)).count(); + if(art!=LobbyArtwork.tileCount()) failures.add("art frames "+art+" != "+LobbyArtwork.tileCount()); + String result="GUILD_VERIFY "+(failures.isEmpty()?"PASS":"FAIL")+" walkable="+seen.size()+" artwork="+art+" "+failures; + sender.sendMessage(result); + try { Files.writeString(getDataFolder().toPath().resolve("verification.txt"),result+"\n"); } catch(IOException e) { getLogger().warning(e.toString()); } + } + private boolean walkable(int x,int y,int z) { + return lobby.getBlockAt(x,y-1,z).getType().isSolid() && lobby.getBlockAt(x,y,z).isPassable() && !lobby.getBlockAt(x,y,z).isLiquid() && lobby.getBlockAt(x,y+1,z).isPassable(); + } + @EventHandler public void join(PlayerJoinEvent e) { + if(lobby!=null && getConfig().getBoolean("join-at-lobby",true)) Bukkit.getScheduler().runTask(this,()->e.getPlayer().teleport(lobby.getSpawnLocation())); + } + @EventHandler public void respawn(PlayerRespawnEvent e) { if(lobby!=null && getConfig().getBoolean("respawn-at-lobby",true)) e.setRespawnLocation(lobby.getSpawnLocation()); } + @EventHandler public void move(PlayerMoveEvent e) { + if(inLobby(e.getPlayer().getWorld()) && e.getTo()!=null && e.getTo().getY()<65) e.setTo(lobby.getSpawnLocation()); + } + @EventHandler public void damage(EntityDamageEvent e) { if(inLobby(e.getEntity().getWorld())) e.setCancelled(true); } + @EventHandler public void spawn(CreatureSpawnEvent e) { + if(inLobby(e.getLocation().getWorld()) && (e.getEntity() instanceof EnderDragon || e.getSpawnReason()!=CreatureSpawnEvent.SpawnReason.CUSTOM)) e.setCancelled(true); + } + @EventHandler public void breakBlock(BlockBreakEvent e) { if(inLobby(e.getBlock().getWorld())&&!e.getPlayer().hasPermission("dunelobby.build")) e.setCancelled(true); } + @EventHandler public void placeBlock(BlockPlaceEvent e) { if(inLobby(e.getBlock().getWorld())&&!e.getPlayer().hasPermission("dunelobby.build")) e.setCancelled(true); } + @EventHandler public void explode(EntityExplodeEvent e) { if(inLobby(e.getLocation().getWorld())) e.blockList().clear(); } + @EventHandler public void blockExplode(BlockExplodeEvent e) { if(inLobby(e.getBlock().getWorld())) e.blockList().clear(); } + @EventHandler public void hanging(HangingBreakEvent e) { if(inLobby(e.getEntity().getWorld())) e.setCancelled(true); } + @EventHandler public void entityInteract(PlayerInteractEntityEvent e) { + if(!inLobby(e.getPlayer().getWorld())) return; + if(e.getRightClicked() instanceof ItemFrame) { e.setCancelled(true); return; } + String role=e.getRightClicked().getPersistentDataContainer().get(roleKey,PersistentDataType.STRING); + if(role==null) return; e.setCancelled(true); if(e.getHand()!=EquipmentSlot.HAND) return; + switch(role) { + case "liaison" -> { if(Bukkit.getPluginCommand("duneess")!=null) e.getPlayer().performCommand("duneess travel"); else departure(e.getPlayer(),"arrakis"); } + case "exchange" -> { if(Bukkit.getPluginCommand("dune")!=null) e.getPlayer().performCommand("dune exchange"); else e.getPlayer().sendMessage(ChatColor.GOLD+"CHOAM market integration requires DuneCore on this backend."); } + case "water","spice" -> trade(e.getPlayer(),role); + } + } + private void trade(Player player,String role) { + boolean water=role.equals("water"); + ItemStack result=new ItemStack(water?Material.POTION:Material.ORANGE_DYE); + ItemMeta meta=result.getItemMeta(); meta.setDisplayName(ChatColor.GOLD+(water?"Smuggled drinking water":"Smuggler spice sample")); + meta.setLore(List.of("Guild lobby barter goods","Not redeemable for Solaris or faction rewards")); + if(meta instanceof PotionMeta potion) potion.setBasePotionType(org.bukkit.potion.PotionType.WATER); + result.setItemMeta(meta); + int price=Math.max(1,Math.min(64,getConfig().getInt(water?"water-price-emeralds":"spice-price-emeralds",water?4:8))); + MerchantRecipe recipe=new MerchantRecipe(result,0,999,false,0,0f); recipe.addIngredient(new ItemStack(Material.EMERALD,price)); + Merchant merchant=Bukkit.createMerchant(water?"Discreet Water Seller":"Discreet Spice Seller"); merchant.setRecipes(List.of(recipe)); player.openMerchant(merchant,true); + } + @EventHandler public void interact(PlayerInteractEvent e) { + if(!inLobby(e.getPlayer().getWorld()) || e.getClickedBlock()==null || e.getAction()!=Action.RIGHT_CLICK_BLOCK) return; + var b=e.getClickedBlock(); e.setCancelled(true); if(e.getHand()!=EquipmentSlot.HAND) return; + int x=b.getX(),z=b.getZ(); + for(int i=0;i=p[1]-9 && z<=p[1]-7) { departure(e.getPlayer(),LobbyBuilder.PLANETS.get(i)); return; } } + if(b.getType()==Material.LECTERN) { + boolean rules=z>0; List text=getConfig().getStringList(rules?"rules":"news"); + ItemStack book=new ItemStack(Material.WRITTEN_BOOK); BookMeta meta=(BookMeta)book.getItemMeta(); meta.setTitle(rules?"Guild Charter":"Guild News"); meta.setAuthor("Spacing Guild"); + meta.setPages(text.stream().map(line->ChatColor.DARK_GRAY+line).toList()); book.setItemMeta(meta); e.getPlayer().openBook(book); + } + } + private void departure(Player player,String planet) { + TravelMenu menu=new TravelMenu(planet); ItemStack confirm=new ItemStack(Material.LIME_CONCRETE); ItemMeta meta=confirm.getItemMeta(); + meta.setDisplayName("Confirm departure: "+planet); meta.setLore(List.of("DuneEss fares and access rules apply when installed.")); confirm.setItemMeta(meta); + menu.inventory.setItem(4,confirm); player.openInventory(menu.inventory); + } + @EventHandler public void menu(InventoryClickEvent e) { + if(!(e.getView().getTopInventory().getHolder() instanceof TravelMenu menu)) return; + e.setCancelled(true); if(e.getRawSlot()!=4 || !(e.getWhoClicked() instanceof Player player)) return; + long now=System.currentTimeMillis(); if(now-travelCooldown.getOrDefault(player.getUniqueId(),0L)<5000) return; + travelCooldown.put(player.getUniqueId(),now); + Bukkit.getScheduler().runTask(this,()-> { + player.closeInventory(); + if(Bukkit.getPluginCommand("duneess")!=null) { player.performCommand("duneess travel "+menu.planet); return; } + World target=Bukkit.getWorld(menu.planet); + if(target!=null) { player.teleport(target.getSpawnLocation()); return; } + String server=getConfig().getString("servers."+menu.planet,""); + if(server.isBlank()) { player.sendMessage("No destination configured."); return; } + try { + ByteArrayOutputStream bytes=new ByteArrayOutputStream(); DataOutputStream out=new DataOutputStream(bytes); out.writeUTF("Connect"); out.writeUTF(server); + player.sendPluginMessage(this,"BungeeCord",bytes.toByteArray()); player.sendMessage("Guild departure requested. If you remain here, the destination or proxy is unavailable."); + } catch(IOException ex) { player.sendMessage("Guild departure could not be requested."); } + }); + } + @EventHandler public void drag(InventoryDragEvent e) { if(e.getView().getTopInventory().getHolder() instanceof TravelMenu) e.setCancelled(true); } + @EventHandler public void quit(PlayerQuitEvent e) { travelCooldown.remove(e.getPlayer().getUniqueId()); } + @Override public void onDisable() { if(lobby!=null) lobby.save(); } +} diff --git a/DuneLobby/src/main/java/com/example/dunelobby/LobbyArtwork.java b/DuneLobby/src/main/java/com/example/dunelobby/LobbyArtwork.java new file mode 100644 index 00000000..6fcd9f47 --- /dev/null +++ b/DuneLobby/src/main/java/com/example/dunelobby/LobbyArtwork.java @@ -0,0 +1,134 @@ +package com.example.dunelobby; + +import org.bukkit.*; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.*; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.MapMeta; +import org.bukkit.map.MapView; +import org.bukkit.persistence.PersistentDataType; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.Future; + +/** Uses ImageFrame's published loader API through reflection; no vendored third-party code. */ +final class LobbyArtwork { + private final DuneLobby plugin; + private final World world; + private final NamespacedKey key; + private static final java.util.concurrent.atomic.AtomicBoolean INSTALLING=new java.util.concurrent.atomic.AtomicBoolean(); + private static final UUID OWNER=UUID.fromString("79a66e02-e519-4489-a153-89f0037d7d11"); + private record Panel(String name,String file,int x,int y,int z,int width,int height) {} + private static final List PANELS=List.of( + new Panel("guild","guild-navigator.png",-3,85,26,6,4), + new Panel("choam","exchange.png",-88,85,20,5,3), + new Panel("expedition","spice-expedition.png",-54,85,20,5,3), + new Panel("news","news.png",57,85,-60,10,5), + new Panel("rules","rules.png",58,85,17,8,5), + new Panel("smugglers","smuggler-water-camp.png",-70,84,122,8,4), + new Panel("arrakis","world-0.png",-110,88,-87,5,4), + new Panel("giedi","world-1.png",-100,88,-87,5,4), + new Panel("kaitain","world-2.png",-90,88,-87,5,4), + new Panel("caladan","world-3.png",-68,88,-87,5,4), + new Panel("sigma","world-4.png",-58,88,-87,5,4), + new Panel("navigator_left","guild-navigator.png",-23,103,-26,6,10), + new Panel("navigator_right","arrakis-cover.png",18,103,-26,6,10), + new Panel("choam_history_south","spice-expedition.png",-86,85,60,10,6), + new Panel("choam_arrakis_south","arrakis-cover.png",-56,85,60,10,6), + new Panel("news_caladan","world-3.png",44,85,-60,6,6), + new Panel("news_kaitain","world-2.png",73,85,-60,6,6), + new Panel("news_expedition_south","spice-expedition.png",47,85,-22,8,6), + new Panel("news_sandworm_south","shai-hulud-encounter.png",69,85,-22,8,6), + new Panel("charter_sietch_south","sietch-panorama.png",45,85,56,10,6), + new Panel("charter_arrakis_south","arrakis-cover.png",70,85,56,10,6), + new Panel("starport_guild_south","guild-navigator.png",-110,86,-29,10,7), + new Panel("starport_arrakis_south","arrakis-cover.png",-59,86,-29,10,7), + new Panel("smuggler_water","smuggler-water-camp.png",-85,84,84,8,5), + new Panel("smuggler_spice","smuggler-spice-mission.png",-57,84,84,8,5)); + LobbyArtwork(DuneLobby plugin,World world) { this.plugin=plugin; this.world=world; key=new NamespacedKey(plugin,"art"); } + static int tileCount() { return PANELS.stream().mapToInt(p->p.width*p.height).sum(); } + static int panelCount() { return PANELS.size(); } + void restore() { install(); } + void install() { + if(!Bukkit.getPluginManager().isPluginEnabled("ImageFrame")) { plugin.getLogger().warning("Install ImageFrame 2026.1.5.0 to restore image decorations; structural lobby remains usable."); return; } + if(!INSTALLING.compareAndSet(false,true)) { plugin.getLogger().info("Artwork restoration is already running."); return; } + // Creation waits for ImageFrame's sync map allocation: run OFF the server thread. + Bukkit.getScheduler().runTaskAsynchronously(plugin,()-> { + try { + ClassLoader cl=Bukkit.getPluginManager().getPlugin("ImageFrame").getClass().getClassLoader(); + Class main=cl.loadClass("com.loohp.imageframe.ImageFrame"); Object manager=main.getField("imageMapManager").get(null); + Class managerType=cl.loadClass("com.loohp.imageframe.objectholders.ImageMapManager"); + // ImageFrame loads saved maps asynchronously after enable. Avoid creating duplicate + // names/map IDs while its storage is still being restored. + Object storage=managerType.getMethod("getStorage").invoke(manager); + Class storageType=cl.loadClass("com.loohp.imageframe.storage.ImageFrameStorage"); + for(int attempt=0;;attempt++) { + var saved=(Set)storageType.getMethod("getAllImageIndexes").invoke(storage); + var loaded=(Collection)managerType.getMethod("getMaps").invoke(manager); + if(loaded.size()>=saved.size()) break; + if(attempt>=60) throw new IllegalStateException("ImageFrame data did not finish loading; retry dunelobby artwork after checking its logs."); + Thread.sleep(1000); + } + Class infoType=cl.loadClass("com.loohp.imageframe.objectholders.NonUpdatableImageMapCreateInfo"); + Class mapType=cl.loadClass("com.loohp.imageframe.objectholders.NonUpdatableStaticImageMap"); + Class dithering=cl.loadClass("com.loohp.imageframe.objectholders.DitheringType"); + Object dither=dithering.getMethod("fromName",String.class).invoke(null,"floyd-steinberg"); + Class loaders=cl.loadClass("com.loohp.imageframe.objectholders.ImageMapLoaders"); + Object loader=loaders.getMethod("getLoader",Class.class,Class.class,String.class,org.bukkit.command.CommandSender.class).invoke(null,mapType,infoType,"image/png",Bukkit.getConsoleSender()); + for(Panel p:PANELS) { + String name="dune_lobby_"+p.name; + Object map=managerType.getMethod("getFromCreator",UUID.class,String.class).invoke(manager,OWNER,name); + if(map==null) { + BufferedImage original; + try(var input=plugin.getResource("artwork/"+p.file)) { if(input==null) throw new IllegalStateException("Missing artwork "+p.file); original=ImageIO.read(input); } + // Map tiles are a display-format conversion; ImageFrame stores and renders them. + BufferedImage canvas=new BufferedImage(p.width*128,p.height*128,BufferedImage.TYPE_INT_ARGB); + var g=canvas.createGraphics(); g.drawImage(original,0,0,canvas.getWidth(),canvas.getHeight(),null); g.dispose(); + BufferedImage[] tiles=new BufferedImage[p.width*p.height]; + for(int i=0;i)loader.getClass().getMethod("create",infoType).invoke(loader,info)).get(); + managerType.getMethod("addMap",cl.loadClass("com.loohp.imageframe.objectholders.ImageMap")).invoke(manager,map); + } + @SuppressWarnings("unchecked") List views=(List)map.getClass().getMethod("getMapViews").invoke(map); + Bukkit.getScheduler().callSyncMethod(plugin,()-> { mount(p,views); return null; }).get(); + } + Bukkit.getScheduler().runTask(plugin,()-> { world.save(); plugin.getLogger().info("GUILD_ARTWORK_COMPLETE: "+PANELS.size()+" ImageFrame panels installed."); }); + } catch(Exception e) { plugin.getLogger().log(java.util.logging.Level.SEVERE,"ImageFrame artwork failed",e); } + finally { INSTALLING.set(false); } + }); + } + private void mount(Panel p,List views) { + Map existing=new HashMap<>(); + for(ItemFrame frame:world.getEntitiesByClass(ItemFrame.class)) { + String tag=frame.getPersistentDataContainer().get(key,PersistentDataType.STRING); if(tag!=null) existing.put(tag,frame); + } + boolean facesNorth=p.name.equals("guild")||p.name.equals("smugglers")||p.name.endsWith("_south"); + int backing=p.z+(facesNorth?1:-1); + for(int x=p.x-1;x<=p.x+p.width;x++) for(int y=p.y-1;y<=p.y+p.height;y++) { + if(x!=p.x-1&&x!=p.x+p.width&&y!=p.y-1&&y!=p.y+p.height) continue; + world.getBlockAt(x,y,backing).setType(Material.WAXED_CUT_COPPER,false); + } + for(int x:new int[]{p.x-2,p.x+p.width+1}) { + for(int y=p.y-1;y<=p.y+p.height;y++) world.getBlockAt(x,y,backing).setType(Material.CHISELED_POLISHED_BLACKSTONE,false); + world.getBlockAt(x,p.y+p.height+1,backing).setType(Material.LANTERN,false); + } + for(int row=0;rowf.setFacingDirection(face,true)); + frame.setVisible(false); frame.setFixed(true); frame.setInvulnerable(true); frame.setPersistent(true); + frame.getPersistentDataContainer().set(key,PersistentDataType.STRING,tag); + ItemStack item=new ItemStack(Material.FILLED_MAP); MapMeta meta=(MapMeta)item.getItemMeta(); meta.setMapView(views.get(row*p.width+col)); item.setItemMeta(meta); frame.setItem(item,false); + } + } +} diff --git a/DuneLobby/src/main/java/com/example/dunelobby/LobbyBuilder.java b/DuneLobby/src/main/java/com/example/dunelobby/LobbyBuilder.java new file mode 100644 index 00000000..f4bcf50d --- /dev/null +++ b/DuneLobby/src/main/java/com/example/dunelobby/LobbyBuilder.java @@ -0,0 +1,443 @@ +package com.example.dunelobby; + +import org.bukkit.*; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Sign; +import org.bukkit.block.sign.Side; +import org.bukkit.block.data.Directional; +import org.bukkit.block.data.type.Slab; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.TextDisplay; +import org.bukkit.entity.Display; +import org.bukkit.inventory.ItemStack; +import java.util.*; + +/** Deterministic, bounded build. Coordinates are also used by the saved-world verifier. */ +final class LobbyBuilder { + static final int FLOOR = 80; + static final List PLANETS = List.of("arrakis", "caladan", "giedi_prime", "kaitain", "sigma_draconis_iv"); + static final int[][] PADS = {{-100,-73},{-78,-75},{-56,-73},{-101,-39},{-55,-39}}; + private final World w; + private long count; + LobbyBuilder(World world) { w = world; } + void block(int x,int y,int z,Material m) { w.getBlockAt(x,y,z).setType(m,false); count++; } + void box(int x1,int y1,int z1,int x2,int y2,int z2,Material m) { + for(int x=x1;x<=x2;x++) for(int z=z1;z<=z2;z++) for(int y=y1;y<=y2;y++) block(x,y,z,m); + } + private boolean inside(int x,int z,int rx,int rz) { + return Math.abs(x)<=rx && Math.abs(z)<=rz && Math.abs(x)+Math.abs(z)<=rx+rz-5; + } + /** Heavy carved room walls; the entire lobby shares a flat opaque ceiling. */ + private void room(int cx,int cz,int rx,int rz,int height,boolean shady) { + for(int x=-rx;x<=rx;x++) for(int z=-rz;z<=rz;z++) { + if(!inside(x,z,rx,rz)) continue; + boolean edge = !inside(x+1,z,rx,rz)||!inside(x-1,z,rx,rz)||!inside(x,z+1,rx,rz)||!inside(x,z-1,rx,rz); + block(cx+x,76,cz+z,Material.DEEPSLATE_TILES); + block(cx+x,77,cz+z,Material.POLISHED_BLACKSTONE_BRICKS); + block(cx+x,78,cz+z,Material.POLISHED_BLACKSTONE_BRICKS); + block(cx+x,79,cz+z,Material.CHISELED_POLISHED_BLACKSTONE); + Material floor = Math.floorMod(Math.floorDiv(x,4)+Math.floorDiv(z,4),2)==0?Material.DEEPSLATE_TILES:Material.POLISHED_BLACKSTONE_BRICKS; + if(Math.abs(x)==rx-3 || Math.abs(z)==rz-3) floor=shady?Material.WAXED_WEATHERED_COPPER:Material.GILDED_BLACKSTONE; + if(Math.abs(x)==rx-5 || Math.abs(z)==rz-5) floor=shady?Material.CRACKED_DEEPSLATE_BRICKS:Material.WAXED_CUT_COPPER; + block(cx+x,80,cz+z,floor); + int wallTop=FLOOR+height; + if(edge) { + for(int y=65;y<=wallTop;y++) { + Material m=Material.POLISHED_BLACKSTONE_BRICKS; + if(y>=85 && y=-12;z--) { + int y=80+(int)Math.ceil(-z/2.0); + box(-6,81,z,6,y,z,Material.POLISHED_BLACKSTONE_BRICKS); + for(int x:new int[]{-6,6}) block(x,y,z,Material.GOLD_BLOCK); + for(int x:new int[]{-8,8}) { block(x,y+1,z,Material.POLISHED_BLACKSTONE_BRICK_WALL); if(z%3==0) block(x,y+2,z,Material.LANTERN); } + } + box(-10,87,-27,10,89,-15,Material.WAXED_CUT_COPPER); + box(-9,90,-26,9,121,-14,Material.ORANGE_STAINED_GLASS); + box(-8,91,-25,8,120,-15,Material.AIR); + box(-10,122,-27,10,123,-14,Material.WAXED_CUT_COPPER); + box(-9,124,-26,9,124,-15,Material.CHISELED_POLISHED_BLACKSTONE); + for(int x:new int[]{-11,11}) { + box(x-1,87,-27,x+1,124,-14,Material.POLISHED_BLACKSTONE_BRICKS); + for(int y=89;y<=123;y+=4) { + box(x-1,y,-15,x+1,y,-13,Material.WAXED_OXIDIZED_COPPER); + block(x,y,-12,Material.GOLD_BLOCK); + } + for(int y=91;y<=119;y+=7) { block(x, y,-12,Material.LANTERN); } + } + for(int x=-8;x<=8;x+=4) for(int z:new int[]{-24,-16}) { block(x,90,z,Material.SHROOMLIGHT); block(x,121,z,Material.SHROOMLIGHT); } + // Oversized folded aquatic body, bulbous head, ribbed trunk and fanned hands. + ellipsoid(0,105,-21,4.0,8.3,3.0,Material.SMOOTH_SANDSTONE); + ellipsoid(0,115,-20,5.6,4.3,3.5,Material.CUT_SANDSTONE); + ellipsoid(0,112,-17,3.5,2.1,1.5,Material.SMOOTH_SANDSTONE); + ellipsoid(0,95,-22,5.7,2.7,2.6,Material.SANDSTONE); + block(-3,115,-17,Material.BROWN_TERRACOTTA); block(3,115,-17,Material.BROWN_TERRACOTTA); + block(0,111,-16,Material.BLACK_TERRACOTTA); + for(int s:new int[]{-1,1}) { + ellipsoid(s*4.6,104,-19,1.5,5.2,1.6,Material.CUT_SANDSTONE); + ellipsoid(s*5.4,99,-19,2.7,1.4,2.3,Material.SMOOTH_SANDSTONE); + for(int f=0;f<5;f++) { + int end=s*(4+f); + box(Math.min(s*3,end),100+f/2,-17-f/2,Math.max(s*3,end),100+f/2,-17-f/2,Material.SMOOTH_SANDSTONE); + } + } + for(int y=99;y<=111;y+=2) for(int s:new int[]{-1,1}) box(s<0?-4:2,y,-18,s<0?-2:4,y,-17,Material.SANDSTONE); + for(int x:new int[]{-14,14}) for(int z=-25;z<=-11;z+=5) lamp(x,87,z,false); + box(11,87,-12,15,88,-12,Material.WAXED_CUT_COPPER); + sign(13,88,-11,BlockFace.SOUTH,"SPACING GUILD","NAVIGATOR","Right-click liaison","for planet travel"); + for(int x=-18;x<=18;x++) for(int z=-5;z<=23;z++) { + double r=Math.hypot(x,z-10); + if((r>=11.5 && r<=12.5)||(r>=4.5&&r<=5.5)) block(x,80,z,Material.GOLD_BLOCK); + if(r>12.5 && r<13.5) block(x,80,z,Material.WAXED_CUT_COPPER); + } + galleries(); + } + private void galleries() { + for(int x=-24;x<=24;x++) for(int z=-26;z<=26;z++) { + if(!inside(x,z,24,26) || !(Math.abs(x)>=21 || z>=24)) continue; + block(x,90,z,Material.POLISHED_BLACKSTONE_BRICKS); + if(Math.abs(x)==21 || z==24) { block(x,91,z,Material.POLISHED_BLACKSTONE_BRICK_WALL); if(Math.floorMod(x+z,6)==0) block(x,92,z,Material.LANTERN); } + } + for(int s:new int[]{-1,1}) for(int i=0;i<10;i++) { + int z=18-i,y=81+i; + box(s<0?-24:22,81,z,s<0?-22:24,y,z,Material.POLISHED_BLACKSTONE_BRICKS); + block(s*21,y+1,z,Material.WAXED_CUT_COPPER); + } + for(int s:new int[]{-1,1}) for(int z:new int[]{-19,-7,5,23}) { + box(s<0?-24:22,81,z-1,s<0?-22:24,89,z+1,Material.DEEPSLATE_BRICKS); + for(int y:new int[]{84,89}) block(s*22,y,z,Material.GOLD_BLOCK); + block(s*20,85,z,Material.LANTERN); + } + } + private void bridge(int x1,int z1,int x2,int z2,boolean shady) { + int minX=Math.min(x1,x2)-4,maxX=Math.max(x1,x2)+4,minZ=Math.min(z1,z2)-4,maxZ=Math.max(z1,z2)+4; + double vx=x2-x1,vz=z2-z1,length2=vx*vx+vz*vz; + for(int x=minX;x<=maxX;x++) for(int z=minZ;z<=maxZ;z++) { + double t=Math.max(0,Math.min(1,((x-x1)*vx+(z-z1)*vz)/length2)); + double d=Math.hypot(x-x1-t*vx,z-z1-t*vz); + if(d>3.6) continue; + box(x,76,z,x,79,z,Material.POLISHED_BLACKSTONE_BRICKS); + block(x,80,z,d<.8?Material.GOLD_BLOCK:d>2.5?Material.WAXED_CUT_COPPER:Material.DEEPSLATE_TILES); + box(x,81,z,x,88,z,Material.AIR); + block(x,93,z,Material.POLISHED_BLACKSTONE_BRICKS); + if(d>2.5) box(x,89,z,x,92,z,Material.CHISELED_POLISHED_BLACKSTONE); + } + for(int x=minX;x<=maxX;x++) for(int z=minZ;z<=maxZ;z++) { + double t=Math.max(0,Math.min(1,((x-x1)*vx+(z-z1)*vz)/length2)); + double d=Math.hypot(x-x1-t*vx,z-z1-t*vz); + if(d<2.5 || d>3.6 || !w.getBlockAt(x,80,z).getType().isSolid()) continue; + boolean outer=false; + for(int[] v:new int[][]{{1,0},{-1,0},{0,1},{0,-1}}) if(!w.getBlockAt(x+v[0],80,z+v[1]).getType().isSolid()) outer=true; + if(!outer) continue; + box(x,81,z,x,92,z,Material.POLISHED_BLACKSTONE_BRICKS); + block(x,84,z,Material.WAXED_CUT_COPPER); block(x,90,z,Material.WAXED_CUT_COPPER); + if(Math.floorMod(x+z,6)==0) { + block(x,88,z,Material.SHROOMLIGHT); + box(x,68,z,x,75,z,Material.DEEPSLATE_BRICKS); block(x,72,z,Material.WAXED_CUT_COPPER); + } + } + } + private void pad(int cx,int cz,int radius,int y,boolean launch,int number) { + box(cx-radius-1,80,cz-radius-1,cx+radius+1,y,cz+radius+1,Material.GRAY_CONCRETE); + for(int x=-radius;x<=radius;x++) for(int z=-radius;z<=radius;z++) { + Material m=Material.POLISHED_BASALT; + if(Math.abs(x)==radius || Math.abs(z)==radius) m=Math.floorMod(x+z,4)<2?Material.YELLOW_CONCRETE:Material.BLACK_CONCRETE; + if((Math.abs(x)<=1 && Math.abs(z)<=radius-2)||(Math.abs(z)<=1 && Math.abs(x)<=radius-2)) m=Material.SMOOTH_QUARTZ; + block(cx+x,y,cz+z,m); + } + for(int s:new int[]{-1,1}) for(int t:new int[]{-1,1}) { block(cx+s*radius,y+1,cz+t*radius,Material.LANTERN); } + if(launch) { + box(cx-2,81,cz+radius+1,cx+2,81,cz+radius+2,Material.SMOOTH_STONE); + box(cx-2,81,cz+radius+3,cx+2,81,cz+radius+3,Material.SMOOTH_STONE_SLAB); + box(cx-2,83,cz-radius-2,cx+2,84,cz-radius-2,Material.WAXED_CUT_COPPER); + block(cx,85,cz-radius-2,Material.LANTERN); + sign(cx,84,cz-radius-1,BlockFace.SOUTH,"DEPARTURE 0"+number,PLANETS.get(number-1).replace('_',' '),"Right-click console","Confirm destination"); + } + } + private void starport() { + pad(-78,-53,10,80,false,0); + for(int i=0;i