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
94 changes: 94 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,100 @@

## Unreleased

## Version 1.3.0

### New Features

#### Towns

+ Added a founding credit. Every player without a town is given one once, the next time they join, on top of their
starting balance. Only founding a town with `/t new` can spend it: it comes off the price Towny charges, so a new
player who spends their balance by mistake can still found a town.
+ Joining someone else's town gives the credit up. It is never paid out as money.
+ `/balance` shows the credit while you hold it.
+ Set the amount with `towns.founding-credit` (default `100.0`), or `0` to turn it off.

#### Main Menu

+ Added a main menu. Every player carries a glowing menu item in the last slot of their hotbar; right-click it — or
click it in your inventory, or run `/tritown menu` — to open it.
+ Your profile sits at the top: balance, founding credit, leaderboard rank, town and nation.
+ Below it: your town at a glance (residents, bank, upkeep, time to the new day) with a shortcut into TownyMenu,
the global shop, trading, paying, the leaderboard, the server's vital signs, a sidebar switch, and the admin
panel for those allowed it.
+ Anything switched off on the server, or that you are not allowed to use, is left out rather than greyed, and
each row is centred on what remains.
+ **Trade** lists the players close enough to trade with, nearest first, with anyone waiting for your answer
first and glowing; click one to ask, or to accept. **Pay** lists everyone online and asks for the amount in
chat. Both run `/trade` and `/pay`, so the same rules and permissions apply.
+ **Leaderboard** shows the richest players as heads, gold, silver and bronze at the top, with your own rank on
every page.
+ The menu item cannot be moved, dropped, stored, crafted with, placed or handed to anything — including item
frames, armour stands, allays and the trade table. A copy that turns up anywhere but its slot is deleted within a
second, and it is taken off you when you log out, so it is never saved and never left behind. Whatever was in the
slot before is moved into your inventory, or dropped at your feet if it is full.
+ `main-menu.item.enabled` turns the item off (the menu stays reachable with `/tritown menu`), and
`main-menu.item.material` picks what it is — a nether star by default.

#### News

+ Added server news: update notes administrators write in game and every player reads from the main menu or with
`/tritown news`.
+ A post has a title, an optional summary and label (such as `v1.3`), and categories of short entries — a line
or two about one change each. Every entry carries a tag: New, Changed, Fixed, Removed or Note.
+ Posts are listed pinned first, then newest. Inside a post, its card sits at the top and its categories follow
in order, each one's entries read straight off its card; a long one opens to show them one by one, and
**Read as a book** shows the whole post as pages.
+ Players are told what they have missed.
+ Joining with unread posts lists them in chat a moment later, each one a link to the post.
+ The **News** button in the main menu glows while anything is unread and stacks up to the number unread, and the
menu item's description counts them too.
+ Publishing a post can announce it to everyone online with a title, a sound and a link, or go out quietly.
+ A new player only has the newest post waiting for them, not the whole backlog. `/tritown news readall` (or
**Mark all as read**) clears the rest.
+ Posts are written entirely in menus, with `tritown.news.manage`: open **Manage** in the news, or run
`/tritown news manage`.
+ A post starts as a draft that only editors can see, can be previewed exactly as players will see it, and is
published when it is ready. It can be taken back to drafts, and deleting it asks first.
+ **Write entries** takes one line after another in chat until you type `done`. Starting a line with `+`, `*`,
`!`, `-` or `?` tags it New, Changed, Fixed, Removed or Note; without one it keeps the tag of the line before.
+ Categories and entries can be reordered, retagged and removed, a post can be pinned to the top, and a post or
category takes its icon from any item you click in your inventory.
+ Every title, summary, category name and entry can be translated into each language the server has, and players
read their own language, falling back to the text as first written.
+ The `news` block of `config.yml` switches the news off, sets the join message's delay and length, what an
announcement shows and plays, and how long an entry may be (`max-entry-length`, default 200).

### Improvements

#### Economy

+ Raised the default starting balance from 100 to 200. Existing servers keep the value already in their
`config.yml`.

#### Admin Panel

+ The admin panel now opens at full size, keeps its cards centred when you may not open one of them, and has a
button back to the main menu.

### Technical Details

#### Misc

+ `PagedLayout.CENTERED` frames a paged menu like `FRAMED` and centres a page that is not full, and `GUIFrame` gained
`spacedColumns`, `packedColumns` and `centeredSlots` for laying out rows of buttons and short lists.
`PagedPluginGUI.contentIndex` now takes the click event, since on a centred page the slot an item lands in depends
on how many share it.
+ `GUIManager` no longer delivers clicks and drags that are already cancelled, so a guard at a lower priority can
refuse a click knowing no menu will act on it.
+ `CommandRegistrar.find`, `canRun` and `run` let a menu run one of TriTown's commands directly, with its permission
check, whatever label it ended up registered under.
+ `PagedPluginGUI.topButtons` places items over the top border of a framed menu, where they stay put as the pages turn.
+ `ConfirmGUI` asks before something that cannot be undone: a subject, up to three choices with actions, and Cancel.
+ `Lang.idFor` gives the language a sender reads, for text kept outside the language files.
+ The atomic write the shop file used (temporary file, `.bak`, atomic move) is now `AtomicFile`, shared with the news
file.

## Version 1.2.0

### New Features
Expand Down
49 changes: 43 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,27 @@ 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/
│ └── moderation/ scoreboard/ shop/
│ ├── admin/ economy/ info/ menu/ news/
│ └── moderation/ scoreboard/ shop/ 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,
│ # storage (not scanned)
├── enums/ # AccountType, FlowCategory, StatsWindow, TransactionType, FillMode, …
├── guis/ # GUIs (auto-registered, extend PluginGUI / PagedPluginGUI); admin/ is the panel
├── guis/ # GUIs (auto-registered, extend PluginGUI / PagedPluginGUI); admin/ is the panel,
│ # menu/ the main menu, news/ the news; ConfirmGUI asks before the irreversible
├── items/ # Custom items (auto-registered, extend PluginItem)
├── 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)
├── recipes/ # Recipes (auto-registered, implement PluginRecipe)
├── registration/ # Auto-registration engine (do not modify lightly)
├── shops/ # Admin shops: model, trading, storage, FancyNpcs bridge (not scanned)
├── tasks/ # Scheduled tasks (auto-registered, extend PluginTask)
├── towns/ # Town founding credit (not scanned)
├── trades/ # Player trades: sessions, escrow, the swap (not scanned)
└── utils/ # Lang, EconomyUtil, InventoryUtil, itemStack DSL, MessageUtil, LoreUtil,
# ChatPrompt, CountdownUtil, TeamUtil, TagUtil, PDCUtil, GameRuleUtil
# ChatPrompt, CountdownUtil, TeamUtil, TagUtil, PDCUtil, GameRuleUtil, AtomicFile
src/main/resources/
├── config.yml plugin.yml
└── lang/ # en_US.yml, zh_CN.yml — every player-facing string
Expand All @@ -94,8 +98,9 @@ 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/` and the trade core
in `trades/`: each has to be alive before the registrars build the commands and menus that read it.
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
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 @@ -267,6 +272,38 @@ 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 the Main Menu

The main menu (`guis/menu`) is how players reach TriTown, opened from the menu item in hotbar slot 8 or with
`/tritown menu`. See [Main Menu](docs/DEVELOPER_GUIDE.md#main-menu).

- **The menu points the way; it never does the work.** A button runs the command or opens the menu that owns the
action — through `CommandRegistrar.run`, never by repeating its logic — so each rule and message lives in one place.
- **Leave out what the viewer cannot use**, and lay the rest out with `GUIFrame.spacedColumns` so each row stays
centred. Never draw a greyed-out button, and never fix a slot that leaves a hole when a button is missing.
- **The main menu and every menu it opens are six rows.**
- **`MenuItem.reconcile` is the only code that creates a menu item.** The invariant is one copy, in slot 8, only while
the player is online. A new way the item could move gets a guard in `MenuItemListener` (cancel at `LOWEST`, then
`reconcileLater` if the client may be out of step), never a second place that hands out or restores a copy.
- **Never let a menu act on a cancelled click.** `GUIManager` already skips them; a GUI that listens to inventory
events itself must do the same, or a refused click on the menu item reaches it anyway.

## Working with News

**Update notes administrators write in game and every player reads.** See
[Server News](docs/DEVELOPER_GUIDE.md#server-news).

- **Go through `NewsManager`** — it is the only thing that reads or writes a post. After editing a post in place, call
`NewsManager.changed(post)`, which saves at once and dates a published post as edited.
- **A post's words are the administrator's, not translation keys.** Titles, summaries, category names and entries are
`LocalizedText` MiniMessage, embedded as written; read them with `forViewer(player)`, never `tr`. Only the words
around a post live in the language files.
- **Unread comes from `NewsReadState` and nowhere else**, and `unread` must stay one pass over the published posts:
the menu item reads it every second for every player.
- **Keep the model free of Bukkit types** — it is the file's shape. An icon is a material's name, read back through
`NewsRender.material`.
- **Every editor click re-checks `tritown.news.manage`**, not only the command that opened the menu.

## Versioning & Releases

- `plugin_version` in [gradle.properties](gradle.properties) is the single source of truth for the plugin version. It
Expand Down
Loading