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

## Unreleased

## Version 1.5.1

### New Features

#### Towns

+ Added **resource regions**: parts of a town whose resources grow back on their own, and which only the town's
residents can gather. Made for a starter town that new players join.
+ Mining, foraging, farming and excavation: ore turns to a stand-in block such as bedrock and comes back, trees
regrow, and crops are replanted as seedlings and grow through their stages. A crop can only be harvested ripe.
+ Husbandry and combat: spawners keep animals or monsters about, replace those lost after a set time and keep them
from wandering off. Monsters can be given a level, and do not burn in daylight.
+ Residents can gather even when the town denies them the right to build, destroy and use. Only the gathering itself
is allowed: they still cannot build, open anything or break a block that is not a ripe resource.
+ Nothing in a region can be changed by anyone else either. Nothing grows, spreads, decays, burns, floods or
explodes there except through TriTown, and animals there cannot be led away, renamed or bred.
+ Walking into a region shows its name and what can be gathered, or why you cannot gather there.
+ Resource regions are set up in game by administrators with `/tritown gather`.
+ Draw a region with the wand (`/tritown gather wand`) inside one town's land, then `/tritown gather create <id>`.
+ Add a resource by clicking a block, or a seed for a crop, in your own inventory: every block of that kind in the
region becomes one. Set how long it takes to grow back, what stands in for it meanwhile, whether it keeps its
vanilla drops, extra drops with their own chances, and what it may grow back as by weight, for an ore vein that is
different every time.
+ Add a spawner by standing where it belongs and clicking a spawn egg. Set how many mobs it keeps, how quickly it
replaces them, how far they roam and how strong its monsters are.
+ Rename, close, resize, outline and regrow regions from the editor. `/tritown gather build` lets you change a
region freely without anything counting as a harvest.
+ Harvested blocks keep growing back across restarts. Deleting a region, or the town it belongs to, grows everything
back first and removes its mobs.
+ Players see their town's resource regions, and a tally of what they have gathered in each category, from the new
**Resource Regions** button in the main menu or with `/tritown resources`.

### Technical Details

#### Combat

+ `MobSetup.spawn` takes a `prepare` callback that runs before the mob joins the world.

## Version 1.5.0

### New Features
Expand Down
36 changes: 29 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

TriTown is a Minecraft Paper plugin that adds custom town features for the Trilleo server on top of
[Towny](https://github.com/TownyAdvanced/Towny). Where [TownyMenu](https://github.com/Trilleo/TownyMenu) is a general
GUI for Towny's existing features, TriTown holds functionality specific to this server. It targets Minecraft 26.2 (Paper
API 26.2), hard-depends on Towny and Vault, and is written in Kotlin. [README.md](README.md) has the player-facing
GUI for Towny's existing features, TriTown holds functionality specific to this server. It targets Minecraft 26.3 (Paper
API 26.3), hard-depends on Towny and Vault, and is written in Kotlin. [README.md](README.md) has the player-facing
overview.

## Tech Stack
Expand All @@ -14,7 +14,7 @@ overview.
|:---------------|:-------------------------------------------------|
| Language | Kotlin 2.3.10 |
| Build | Gradle 9.7.1 (Kotlin DSL) |
| Platform | Paper API 26.2 (MC 26.2) |
| Platform | Paper API 26.3 (MC 26.3) |
| Towny | 0.103.2.7 (`towny_version` in gradle.properties) |
| Vault API | 1.7.1 (`vault_api_version` in gradle.properties) |
| FancyNpcs API | 2.9.2 (`fancynpcs_version`, API artifact only) |
Expand Down Expand Up @@ -58,7 +58,7 @@ Before finishing any task that changes the plugin, do all of the following:
```

The local test server lives in `run/` (gitignored). `copyPlugin` puts the matching Towny jar in `run/plugins/`, but the
Paper 26.2 jar (`run/paper-*.jar`), Vault, and FancyNpcs (Maven carries its API only) must be downloaded by hand, and
Paper 26.3 jar (`run/paper-*.jar`), Vault, and FancyNpcs (Maven carries its API only) must be downloaded by hand, and
`eula.txt` accepted, before `startServer` works. No economy plugin is needed — TriTown supplies the economy itself.
The server console reads commands from the terminal running Gradle.

Expand All @@ -68,7 +68,7 @@ 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/ adventure/ economy/ info/ items/ menu/ mobs/
│ ├── admin/ adventure/ economy/ gathering/ info/ items/ menu/ mobs/
│ └── moderation/ news/ protection/ scoreboard/ shop/ storage/ trade/
├── combat/ # Combat: stats, DamageMath, the health lens, the HUD, indicators (not scanned)
├── config/ # PluginConfig (typed config.yml wrapper), EconomySettings
Expand All @@ -77,9 +77,11 @@ src/main/kotlin/net/trilleo/mc/plugins/tritown/
├── economy/ # The economy: ledger, accounts, currencies, Vault provider, statistics,
│ # storage (not scanned)
├── enums/ # AccountType, FlowCategory, StatsWindow, TransactionType, FillMode, …
├── gathering/ # Resource regions: nodes that grow back, spawners, Towny permits, storage (not scanned)
├── gear/ # Gear: its data, stats, drawing and refreshing, the Forge and its costs (not scanned)
├── guis/ # GUIs (auto-registered, extend PluginGUI / PagedPluginGUI); admin/ is the panel,
│ # menu/ the main menu, news/ the news, forge/ the Forge, bestiary/ the bestiary;
│ # menu/ the main menu, news/ the news, forge/ the Forge, bestiary/ the bestiary,
│ # gathering/ the region editor and the players' Resource Regions menu;
│ # ConfirmGUI asks before the irreversible
├── items/ # Custom items (auto-registered, extend PluginItem)
├── listeners/ # Event listeners, including Towny events (auto-registered)
Expand Down Expand Up @@ -110,7 +112,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/`, 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
in `trades/`, the storage core in `storage/`, the news core in `news/` and resource regions in `gathering/`: 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 @@ -360,6 +362,26 @@ The main menu (`guis/menu`) is how players reach TriTown, opened from the menu i
`NewsRender.material`.
- **Every editor click re-checks `tritown.news.manage`**, not only the command that opened the menu.

## Working with Resource Regions

**Parts of a town whose resources grow back, gathered only by its residents.** See
[Resource Regions](docs/DEVELOPER_GUIDE.md#resource-regions).

- **Go through `GatherManager`** — it is the only thing that reads or writes a region or a harvested block. `save()`
after editing a region in place; harvested blocks are flushed by `GatherSaveTask`.
- **Gathering overrides Towny only through a permit.** Decide at `LOWEST`, cancel what is refused, and leave a
`GatherPermits.grant` for what is allowed; `GatherTownyListener` lifts Towny's refusal only where a permit matches.
Never un-cancel a Towny event, or a Bukkit event Towny cancelled, without one, and never lift building: a starter
town's residents must still be unable to build, destroy or use anything that is not gathering.
- **Ask `GatherAccess.refusal`** before anyone gathers. It re-reads Towny on every call; a region keeps only its town's
UUID.
- **A region is held still.** Anything new that could change a block inside one — a mechanic, a mob, an item — must be
refused in `GatherBlockListener` unless it is a harvest, and anything that grows there grows through `Regrowth`.
- **Never overwrite a rebuilt spot.** A harvested block is only put back while the stand-in TriTown left is still there.
- **Spawner mobs are recognised by their PDC tag**, through `Spawners`, and are never eligible for loot. A new
husbandry or combat interaction goes in `GatherEntityListener` with its own permit.
- **Every editor click re-checks `tritown.gather.admin.edit`**, not only the command that opened the menu.

## Working with Combat

**Fights with mobs are in RPG numbers; fights between players are vanilla.** See [Combat](docs/DEVELOPER_GUIDE.md#combat).
Expand Down
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TriTown is in early development; see the [change log](CHANGELOG.md) for what has

**A menu in every hotbar.** Every player carries a glowing item in the last slot of their hotbar; right-click it, or
run `/tt menu`, for everything TriTown offers in one place. Your profile sits at the top — balance, founding credit,
leaderboard rank, town and nation — and below it are your town at a glance with a shortcut into
leaderboard rank, town and nation — beside it your town's resource regions, when it has any, and below it are your town at a glance with a shortcut into
[TownyMenu](https://github.com/Trilleo/TownyMenu), your storage, the global shop, a list of the players near enough to trade with
(anyone waiting for your answer first), a list of players to pay, the richest players as heads, the server's vital signs,
the Forge, the server news, your bestiary, a sidebar switch, and the admin panel for those allowed it. Anything switched off on the server, or that you may not
Expand All @@ -33,6 +33,16 @@ starting balance. Only founding a town with `/t new` can spend it: TriTown takes
new player who spends their balance by mistake can still found a town. Joining someone else's town gives it up, and
`/balance` shows it while you hold it.

**Resource regions in town.** Mark out part of a town — a mine, a farm, a wood, animal pens, a monster arena — and
its resources grow back on their own. Ore turns to bedrock when mined and returns, crops are replanted and grow through
their stages, trees regrow, and spawners keep animals and monsters about. Only the town's residents can gather there,
and they can even when the town denies them building, destroying and using everywhere else, which suits a starter town
new players join. Nothing else in a region can be changed by anyone, and nothing grows, burns or explodes there except
through TriTown. Everything is set up in game: draw the region with a wand, then click blocks, seeds and spawn eggs in
your inventory to add resources and spawners, and set each one's regrow time, the block that stands in while it is gone,
extra drops with their chances, and — for an ore vein that is different every time — what it may grow back as.
Players find their town's regions from the main menu or `/tt resources`, along with a tally of what they have gathered.

**A sidebar that follows you.** A scoreboard that changes with where you are standing: a new player without a town is
pointed at joining one, your own claims show your town's level, residents, land, bank, upkeep and any warning, another
town's claims show whose land it is and what the plot costs, and enemy territory says so. Values sit under headings that
Expand Down Expand Up @@ -108,7 +118,7 @@ built on.

| Dependency | Version |
|:---------------|:------------------------------------|
| Paper | 26.2+ |
| Paper | 26.3+ |
| Java | 25+ |
| Towny | 0.103.2.7+ |
| Vault | 1.7+ |
Expand All @@ -131,7 +141,7 @@ The compiled JAR is placed in `build/libs/`. Run `./gradlew copyPlugin` to copy
into `run/plugins/` for the local test server, or `./gradlew startServer` to copy them and start the server. Before the
first start:

- download a Paper 26.2 jar from [papermc.io](https://papermc.io/downloads/paper) into `run/`;
- download a Paper 26.3 jar from [papermc.io](https://papermc.io/downloads/paper) into `run/`;
- put Vault into `run/plugins/`;
- put [FancyNpcs](https://modrinth.com/plugin/fancynpcs) into `run/plugins/` as well, to test shop NPCs — only its API
is published to Maven, so the plugin itself is not fetched by the build;
Expand Down Expand Up @@ -168,6 +178,8 @@ itself, are still anyone's.
| `/tt mob <level/balance>` | Inspect mob levels and the balance (OP only) |
| `/tt item <give/list>` | Hand out the server's own items and gear (OP only) |
| `/tt forge` | Craft gear, and upgrade, refine, reforge or salvage it |
| `/tt resources` | See your town's resource regions and what you have gathered |
| `/tt gather <action> …` | Set up resource regions (OP only) |

`/eco` takes `give`, `take` and `set` (`<player> <amount> [currency]`), `reset <player>` back to the starting balance,
`info <player>` for an account's details, `history [player]` to browse recorded transactions in a menu, and `flush` to
Expand Down Expand Up @@ -281,6 +293,14 @@ version stays available as `/tritown:balance` and so on.
| `mobs.nameplates` | `true` | Show a levelled mob's level and health when a player looks at it |
| `mobs.ranks.exempt` | bosses | Kinds of mob that never spawn as elites or champions |
| `towns.founding-credit` | `100.0` | Credit only `/t new` can spend, given once to players without a town; `0` is off |
| `gathering.enabled` | `true` | Turn resource regions off entirely |
| `gathering.max-volume` | `250000` | The most blocks one region may cover |
| `gathering.default-regrow-seconds` | `60` | How long a newly added resource takes to grow back |
| `gathering.depleted-blocks.<category>` | `BEDROCK` / `AIR` | What stands in for a harvested block, per category, unless the resource sets one |
| `gathering.spawner-range` | `48` | How close a player has to be for a spawner to call up mobs |
| `gathering.effects` | `true` | Particles and a chime when a block grows back |
| `gathering.entry-titles` | `true` | Show a region's name when a player walks in |
| `gathering.save-interval` | `60` | Seconds between writing harvested blocks to disk |
| `news.enabled` | `true` | Turn the server news off entirely |
| `news.join-message.enabled` | `true` | List a player's unread posts a moment after they join |
| `news.join-message.delay-seconds` | `3` | How long after joining |
Expand Down
Loading