Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,76 @@

## Unreleased

## Version 1.4.0

### New Features

#### Storage

+ Added a storage for every player, opened from the main menu or with `/tritown storage`. Each page is the size of a
large chest and works like one, with a row of buttons beneath it.
+ **Quick deposit** stores everything in your main inventory that your storage already holds some of, **Sort**
merges and orders a page (shift-click for every page), and **Take page** moves a page into your inventory.
+ **Unpack** empties a shulker box or bundle straight into your storage. Full ones can't be stored as they are.
+ Name your pages, give them icons, and jump between them from an overview of every page.
+ Every player starts with `storage.free-pages` pages (default `2`). More can be bought up to `storage.max-pages`
(default `27`), each costing `storage.price.multiplier` times the one before, starting at `storage.price.base`.
Every purchase asks for confirmation first.
+ Administrators with `tritown.storage.admin` can open anyone's storage, online or not, with
`/tritown storage view <player>`, and hand out pages with `/tritown storage pages <player> <add|set> <amount>`.
+ Added a **Storage** section to the admin panel (`tritown.admin.storage`). It lists every storage, fullest first, with
how many pages were bought and what they earned, and opens any of them read-only.

#### Item Protection

+ Items now belong to the player who has them, and the only way to hand one to someone else is a trade
(`/trade <player>`).
+ Items you drop can only be picked up by you. So can whatever you mine, harvest, shear or fish up, the loot of a
mob you kill (with a bow or a tamed pet too), and a vault's reward.
+ Death drops, and anything the world drops by itself, can still be picked up by anyone.
+ Mobs, allays and foxes can't pick up anyone's items. Piglins still barter, and pay back whoever threw the gold.
+ Only the player who fired an arrow or trident can pick it back up.
+ Containers belong to whoever fills them, for as long as anything is inside: furnaces, hoppers, brewing stands,
droppers, crafters, decorated pots, shelves, chiseled bookshelves, jukeboxes, campfires and lecterns.
+ Nobody else can open, feed, empty or break one, blow it up, or break it with a piston. An empty container is free for anyone again, so
shared furnaces still work.
+ Hoppers carry the owner along: your items can fill a free container, which becomes yours, but never someone
else's.
+ Anyone can still read a lectern. Only its owner can take the book.
+ Item frames, armor stands, allays, and mobs you have saddled, armoured or given a chest are yours too. Nobody else
can take the item, shear it off, ride the mob, or break the frame or stand.
+ Items the plugin hands you that don't fit in your inventory, from a trade, a shop or your storage, now drop as
yours.
+ Administrators with `tritown.protection.admin` can see who owns the container or entity they are looking at with
`/tritown protection inspect`, and clear the claim with `release`. `tritown.protection.bypass` lets staff open, take
from and break anything.
+ Everything can be tuned or switched off under `item-protection` in `config.yml`, including a list of worlds where
nothing is protected.

#### Misc

+ Vanilla containers are decoration now, in favour of the storage. Chests, trapped chests, barrels, shulker boxes,
ender chests, chest minecarts and chest boats can still be placed, with a warning, but nothing can be put in them.
+ One with items inside opens only to take them out, so nothing stored in them is lost. An empty one does not open
at all.
+ Hoppers can still empty them but can no longer fill them.
+ Each group can be left alone under `storage.lock-containers`, and `tritown.storage.bypass` exempts builders.

#### Economy

+ Storage pages are a new money sink, listed as **Storage pages** in the admin panel's economy breakdown and in
`/eco history`.

### Technical Details

+ Added the storage core under `storage/`: `StorageManager` (loading, the one-editor lock, pricing and saving),
one JSON file per player under `plugins/TriTown/storage/`, written atomically with a backup, on a single writer thread.
+ Added the item protection core under `protection/`: `ItemOwnership` (drop owners, kept on the game's own `Item`
owner field), `DropWindows` (per-tick windows that credit drops which do not exist yet), and `Claims` (container
and entity claims in their persistent data, released lazily).
+ `StorageGUI` is the first menu that lets the game move items itself, with the button row, shift-clicks and
double-clicks guarded by hand.

## Version 1.3.0

### New Features
Expand Down
46 changes: 43 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ The server console reads commands from the terminal running Gradle.
src/main/kotlin/net/trilleo/mc/plugins/tritown/
├── Main.kt # Plugin entry point (Main.instance, Main.reload())
├── commands/ # Sub-commands (auto-registered)
│ ├── admin/ economy/ info/ menu/ news/
│ └── moderation/ scoreboard/ shop/ trade/
│ ├── admin/ economy/ info/ menu/ news/ protection/
│ └── moderation/ scoreboard/ shop/ storage/ trade/
├── config/ # PluginConfig (typed config.yml wrapper), EconomySettings
├── data/ # JSON-persisted PlayerData / ServerData and their managers
├── economy/ # The economy: ledger, accounts, currencies, Vault provider, statistics,
Expand All @@ -81,9 +81,12 @@ src/main/kotlin/net/trilleo/mc/plugins/tritown/
├── listeners/ # Event listeners, including Towny events (auto-registered)
├── menu/ # The main menu item and the invariant that keeps it unique (not scanned)
├── news/ # Server news: posts, storage, read state, notifications (not scanned)
├── protection/ # Item protection: drop owners, drop windows, container and entity claims
│ # (not scanned)
├── recipes/ # Recipes (auto-registered, implement PluginRecipe)
├── registration/ # Auto-registration engine (do not modify lightly)
├── shops/ # Admin shops: model, trading, storage, FancyNpcs bridge (not scanned)
├── storage/ # Personal storage: pages, pricing, the viewer lock, files (not scanned)
├── tasks/ # Scheduled tasks (auto-registered, extend PluginTask)
├── towns/ # Town founding credit (not scanned)
├── trades/ # Player trades: sessions, escrow, the swap (not scanned)
Expand All @@ -99,7 +102,7 @@ src/main/resources/
The plugin uses `PackageScanner` to discover components at startup — you **never** edit `plugin.yml` or wire things
manually. Just extend the right base class and place the file in the correct package. Packages outside the table below
are never scanned, which is why the economy core lives in `economy/`, the shop core in `shops/`, the trade core
in `trades/` and the news core in `news/`: each has to be alive before the registrars build the commands and menus that read it. `menu/` is outside
in `trades/`, the storage core in `storage/` and the news core in `news/`: each has to be alive before the registrars build the commands and menus that read it. `menu/` is outside
the scan for a simpler reason: `MenuItem` is not a `PluginItem`, because it is named in each holder's language.

| Component | Base Class | Package |
Expand Down Expand Up @@ -272,6 +275,43 @@ The panel in `guis/admin` is where an owner reads the server; `/tritown admin` o
- **Both windows are drawn for their viewer**, never for a side, and anything that changes the table calls
`TradeGUI.redraw` so the two can never disagree.

## Working with Storage

**A storage holds a player's belongings, and replaces vanilla containers.** See
[Personal Storage](docs/DEVELOPER_GUIDE.md#personal-storage).

- **Go through `StorageManager`** — it is the only thing that loads, changes or writes a storage. Charge for a page with
`buyPage`, which withdraws before granting.
- **One editor per storage.** Open one through `StorageGUI.open`, which takes the lock with `StorageManager.claim`;
anything that changes a storage's items without holding it would be overwritten by the editor's next copy-back.
- **`StorageGUI` is the only menu that lets the game move items.** Every other GUI cancels its clicks. A change to it
keeps the button row untouchable, keeps shift-clicks and `COLLECT_TO_CURSOR` out of the game's hands, and checks
`StorageItems.accepts` before anything lands on a page.
- **Leave the storage menu through `leave`**, never by opening another menu directly: `GUIManager` does not deliver a
close to a menu that is replaced, and `finish` is what copies the page back and lets go of the lock.
- **Encode on the server thread, write on the writer.** Items are encoded in `StorageManager.toStored`; `StorageStore`
only ever sees text.
- **Recognise a vanilla container by its inventory's holder**, never by `InventoryType`: TriTown's own menus are
chest-shaped too and have no holder.

## Working with Item Protection

**Items belong to the player who has them; a trade is the only way to hand one over.** See
[Item Protection](docs/DEVELOPER_GUIDE.md#item-protection).

- **An item in an inventory is never marked.** Ownership exists only on a dropped `Item` (the game's own owner field,
set through `ItemOwnership`) and as a claim on a container or entity holder (`Claims`). Never stamp an `ItemStack`
with an owner: a mark nothing strips follows the item into an inventory and stops it stacking.
- **Never drop an item for a player with `dropItemNaturally` alone.** Use `ItemOwnership.dropFor`, or
`InventoryUtil.give`, whose overflow already does.
- **A drop that does not exist yet gets a window.** Call `ItemOwnership.expect` from the event that names the player.
The spawn claims it. Death drops stay public through `suppress`.
- **Claims are released lazily.** `Claims.ownerOf` clears a claim on a vacant holder (empty and unviewed). Never add a
task to release them, and read with `Claims.recorded` only for what a destroyed holder leaves behind.
- **Ask `Protection.settings(world)` first** in every handler, and let `Protection.BYPASS_PERMISSION` through.
- **A new holder of player items** (a block, an entity, a feature that spills items) must be taught to `Claims.of`
or given an owner before it ships. Otherwise it becomes a way to hand items over outside a trade.

## Working with the Main Menu

The main menu (`guis/menu`) is how players reach TriTown, opened from the menu item in hotbar slot 8 or with
Expand Down
Loading