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

## Unreleased

## Version 1.1.2

### New Features

#### Town Menu

+ A town's page has a new Outposts button that lists where its outposts are, for players with Towny's new
`towny.command.town.outpost.list.other` permission. Your own town's outposts still teleport you when clicked.

#### Admin Menus

+ Each world's settings have a new Minimum Adjacent Claims button, which sets how many of a town's own chunks a new
claim in that world must touch (Towny's new `/townyworld set minadjacency`).

### Improvements

#### Town Menu

+ The Cede This Plot button shows what ceding costs when the server charges for it (Towny's new
`price_town_cede` setting), and so do the Prices menu and the Ceding Land lesson.

#### Tutorial

+ The outposts lesson says when outposts can only be claimed in worlds where your town has no other land, and the
jailing lesson says when a nation's capital may jail any resident of the nation. Each line only appears when the
server has the matching Towny setting turned on.

### Technical Details

#### Misc

+ TownyMenu now needs Towny 0.103.2.10 or newer, which fixes towns' home blocks and war settings not loading. The new
`Prices.cede` gives the cost of ceding a plot.

## Version 1.1.1

### New Features
Expand Down
14 changes: 7 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ player-facing overview.

## Tech Stack

| Tool | Version |
|:---------------|:-------------------------------------------------|
| Language | Kotlin 2.3.10 |
| Build | Gradle 9.7.1 (Kotlin DSL) |
| Platform | Paper API 26.3 (MC 26.3) |
| Towny | 0.103.2.7 (`towny_version` in gradle.properties) |
| Java toolchain | JDK 25 |
| Tool | Version |
|:---------------|:--------------------------------------------------|
| Language | Kotlin 2.3.10 |
| Build | Gradle 9.7.1 (Kotlin DSL) |
| Platform | Paper API 26.3 (MC 26.3) |
| Towny | 0.103.2.10 (`towny_version` in gradle.properties) |
| Java toolchain | JDK 25 |

## After Every Change: Keep the Changelog and Docs in Sync

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@

## Requirements

| Dependency | Version |
|:-----------|:-----------|
| Paper | 26.3+ |
| Java | 25+ |
| Towny | 0.103.2.7+ |
| Dependency | Version |
|:-----------|:------------|
| Paper | 26.3+ |
| Java | 25+ |
| Towny | 0.103.2.10+ |

TownyMenu is an addon: Towny must be installed on the server, or TownyMenu will not load.

Expand Down
1 change: 1 addition & 0 deletions docs/UTILITY_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ actually take, and everything returns `0` without an economy.
|:-----------------------------------|:----------------------------------------------------------------------------------|
| `claim(Town, count)` | What claiming `count` chunks costs the town, at its current rising claim price |
| `outpost()` | What claiming an outpost costs |
| `cede()` | What giving a chunk to another town with `/town cede plot` costs the giving town |
| `unclaimRefund()` | What a town gets back per unclaimed chunk; negative when unclaiming costs instead |
| `plotType(String, count)` | What setting `count` plots to a plot type costs (`reset` prices the default type) |
| `merge(remaining, succumbing)` | What merging the second town into the first costs, before any debt it takes on |
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

# Plugin Properties
plugin_version=1.1.1
plugin_version=1.1.2

# Dependency Versions
towny_version=0.103.2.7
towny_version=0.103.2.10
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class BorderViewMenu(player: Player, back: Menu?) : Menu(player, player.tr("bord

override fun build() {
if (!BorderView.available) {
button(13, Icons.icon(Material.BARRIER, tr("border-view.unavailable"), tr("border-view.unavailable-description")))
button(
13,
Icons.icon(Material.BARRIER, tr("border-view.unavailable"), tr("border-view.unavailable-description"))
)
backButton(22)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.palmergames.bukkit.towny.permissions.PermissionNodes
import net.trilleo.mc.plugins.townymenu.guis.framework.Icons
import net.trilleo.mc.plugins.townymenu.guis.framework.Menu
import net.trilleo.mc.plugins.townymenu.guis.tutorial.Tutorial
import net.trilleo.mc.plugins.townymenu.utils.Prices
import net.trilleo.mc.plugins.townymenu.utils.TownyUtil
import net.trilleo.mc.plugins.townymenu.utils.tr
import org.bukkit.Material
Expand Down Expand Up @@ -55,6 +56,7 @@ class PricesMenu(player: Player, back: Menu) : Menu(player, player.tr("prices.ti
}
add(cost("prices.claim-refund", TownySettings.getClaimRefundPrice()))
add(cost("prices.bonus-claim", town?.bonusBlockCost ?: TownySettings.getPurchasedBonusBlocksCost()))
add(cost("prices.cede", Prices.cede()))
if (TownySettings.isAllowingOutposts()) {
add(cost("prices.outpost", TownySettings.getOutpostCost()))
if (TownySettings.getPerOutpostUpkeepCost() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import net.trilleo.mc.plugins.townymenu.utils.tr
import org.bukkit.Material
import org.bukkit.entity.Player

/** One world's Towny settings (`/townyworld`): toggles, wilderness permissions and name, and resetting to defaults. */
/**
* One world's Towny settings (`/townyworld`): toggles, wilderness permissions and name, the minimum
* adjacent claims, and resetting to defaults.
*/
class AdminWorldMenu(player: Player, private val world: TownyWorld, back: Menu) :
Menu(player, player.tr("admin-world.title", "world" to TownyUtil.text(world.name)), 5, back) {

Expand Down Expand Up @@ -58,6 +61,26 @@ class AdminWorldMenu(player: Player, private val world: TownyWorld, back: Menu)
) {
run("$command set usedefault", ::snapshot)
}
val adjacency = world.minAdjacentChunks
guarded(
16, PermissionNodes.TOWNY_COMMAND_TOWNYWORLD_SET,
Icons.icon(
Material.COMPARATOR, tr("admin-world.min-adjacency"), tr("admin-world.min-adjacency-description"),
if (adjacency > 0) tr("admin-world.min-adjacency-current", "count" to adjacency)
else tr("common.current", "value" to tr("common.off")),
actions = hints("click.change")
)
) {
prompt(
tr("admin-world.min-adjacency"),
tr("admin-world.min-adjacency-label"),
tr("admin-world.min-adjacency-hint"),
initial = adjacency.coerceAtLeast(0).toString(),
maxLength = 2
) { value ->
run("$command set minadjacency ${TownyUtil.argument(value)}", { world.minAdjacentChunks })
}
}

WILD_PERMISSIONS.forEachIndexed { index, (type, material, key) ->
val allowed = world.getUnclaimedZonePerm(type)
Expand All @@ -76,7 +99,8 @@ class AdminWorldMenu(player: Player, private val world: TownyWorld, back: Menu)
backButton(40)
}

private fun snapshot(): List<Any?> = toggleList().map { it.value() } + world.unclaimedZoneName
private fun snapshot(): List<Any?> =
toggleList().map { it.value() } + world.unclaimedZoneName + world.minAdjacentChunks

private fun toggles(): Menu =
ToggleMenu(player, tr("admin-world.toggles-title", "world" to TownyUtil.text(world.name)), this, toggleList())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
package net.trilleo.mc.plugins.townymenu.guis.town

import com.palmergames.bukkit.towny.TownyAPI
import com.palmergames.bukkit.towny.`object`.Town
import net.trilleo.mc.plugins.townymenu.guis.framework.Icons
import net.trilleo.mc.plugins.townymenu.guis.framework.Menu
import net.trilleo.mc.plugins.townymenu.guis.framework.MenuEntry
import net.trilleo.mc.plugins.townymenu.guis.framework.PagedMenu
import net.trilleo.mc.plugins.townymenu.utils.Prices
import net.trilleo.mc.plugins.townymenu.utils.TownyUtil
import net.trilleo.mc.plugins.townymenu.utils.tr
import org.bukkit.Material
import org.bukkit.entity.Player

/** Teleport targets for each of a town's outpost spawns. */
/**
* A town's outpost spawns: teleport targets for the viewer's own town, and a read-only list of
* locations for any other town, since Towny only lets residents travel to their own outposts.
*/
class OutpostsMenu(player: Player, private val town: Town, back: Menu) :
PagedMenu(player, player.tr("outposts.title"), back) {
PagedMenu(player, title(player, town), back) {

override fun entries(): List<MenuEntry> {
val cost = costLine(Prices.townSpawn(player, town, outpost = true))
val own = resident?.townOrNull == town
val cost = if (own) costLine(Prices.townSpawn(player, town, outpost = true)) else null
return town.allOutpostSpawns.mapIndexed { index, location ->
val icon = {
Icons.icon(
Material.COMPASS, tr("outposts.outpost", "number" to index + 1), null,
tr("outposts.world", "world" to (location.world?.name ?: "-")),
tr("outposts.location", "x" to location.blockX, "y" to location.blockY, "z" to location.blockZ),
*listOfNotNull(cost).toTypedArray(),
actions = listOf(tr("click.teleport"))
actions = if (own) hints("click.teleport") else emptyList()
)
}
MenuEntry(icon) { runAndClose("towny:town outpost ${index + 1}") }
if (own) MenuEntry(icon) { runAndClose("towny:town outpost ${index + 1}") } else MenuEntry(icon)
}
}

private companion object {
fun title(player: Player, town: Town): String =
if (TownyAPI.getInstance().getResident(player)?.townOrNull == town) player.tr("outposts.title")
else player.tr("outposts.title-other", "town" to TownyUtil.name(town.name))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class TownClaimsMenu(player: Player, back: Menu) : Menu(player, player.tr("claim
PermissionNodes.TOWNY_COMMAND_TOWN_CEDE_PLOT,
Icons.icon(
Material.OAK_BOAT, tr("claims.cede"), tr("claims.cede-description"),
*listOfNotNull(costLine(Prices.cede())).toTypedArray(),
actions = hints("click.choose-town")
)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ class TownInfoMenu(player: Player, private val town: Town, back: Menu) :
NationInfoMenu(player, nation, this).open()
}
}
if (viewer?.townOrNull != town && town.hasOutpostSpawn() && !town.isRuined) {
grid.add(
PermissionNodes.TOWNY_COMMAND_TOWN_OUTPOST_LIST_OTHER,
Icons.icon(
Material.COMPASS, tr("town-info.outposts"), tr("town-info.outposts-description"),
tr("town.outposts", "count" to town.allOutpostSpawns.size),
actions = hints("click.view")
)
) {
OutpostsMenu(player, town, this).open()
}
}
if (viewer != null && !viewer.hasTown() && town.isOpen) {
grid.add(
PermissionNodes.TOWNY_COMMAND_TOWN_JOIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import net.trilleo.mc.plugins.townymenu.guis.plot.PlotMenu
import net.trilleo.mc.plugins.townymenu.guis.resident.FriendsMenu
import net.trilleo.mc.plugins.townymenu.guis.resident.ResidentMenu
import net.trilleo.mc.plugins.townymenu.guis.town.*
import net.trilleo.mc.plugins.townymenu.utils.Prices
import net.trilleo.mc.plugins.townymenu.utils.TownyUtil
import net.trilleo.mc.plugins.townymenu.utils.tr
import org.bukkit.Material
Expand Down Expand Up @@ -390,6 +391,7 @@ object Tutorial {
} else {
buildList {
addAll(player.money(TownySettings.getOutpostCost(), "tutorial.fact.outpost-cost"))
if (TownySettings.getOutpostsLimitedPerWorld()) add(player.tr("tutorial.fact.outposts-per-world"))
town(player)?.let {
add(
player.tr(
Expand All @@ -410,7 +412,9 @@ object Tutorial {
},
Lesson(
"claims/cede", Material.OAK_BOAT, "tutorial.claims.cede", "tutorial.claims.cede-body",
withTown { player, _, back -> TownClaimsMenu(player, back) }),
withTown { player, _, back -> TownClaimsMenu(player, back) }) { player ->
player.money(Prices.cede(), "tutorial.fact.cede-cost")
},
Lesson(
"claims/takeover", Material.IRON_SWORD, "tutorial.claims.takeover", "tutorial.claims.takeover-body",
withTown { player, _, back -> TownClaimsMenu(player, back) },
Expand Down Expand Up @@ -524,6 +528,7 @@ object Tutorial {
addAll(player.money(TownySettings.getBailMaxAmount(), "tutorial.fact.max-bail"))
}
town(player)?.let { add(player.tr("town-jail.jails-count", "count" to it.jails.orEmpty().size)) }
if (TownySettings.canNationLeadersJailNationResidents()) add(player.tr("tutorial.fact.nation-jail"))
}
},
Lesson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ object Prices {
/** What claiming an outpost costs, whatever the town already owns. */
fun outpost(): Double = TownySettings.getOutpostCost()

/** What giving a chunk away with `/town cede plot` costs the town that gives it. */
fun cede(): Double = TownySettings.getCedePlotCost().toDouble()

/** What a town gets back per unclaimed chunk. Negative when the server charges for unclaiming instead. */
fun unclaimRefund(): Double = TownySettings.getClaimRefundPrice()

Expand Down
14 changes: 13 additions & 1 deletion src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ outlaws:

outposts:
title: "Outposts"
title-other: "Outposts: {town}"
outpost: "<light_purple>Outpost #{number}"
world: "<gray>World: <white>{world}"
location: "<gray>Location: <white>{x}, {y}, {z}"
Expand Down Expand Up @@ -538,6 +539,8 @@ town-info:
invite-description: "Invite this town to join {nation}."
merge: "<gold>Merge into Your Town"
merge-description: "Ask the <gold>mayor</gold> of {town} to merge their town into {own}. They must be online to accept."
outposts: "<light_purple>Outposts"
outposts-description: "See where this town's <light_purple>outposts</light_purple> are."

town-list:
title: "Towns"
Expand Down Expand Up @@ -771,6 +774,7 @@ prices:
claim: "<gray>Per claim: <gold>{cost}"
claim-refund: "<gray>Refund per unclaim: <gold>{cost}"
bonus-claim: "<gray>Per bonus claim: <gold>{cost}"
cede: "<gray>Ceding a plot: <gold>{cost}"
outpost: "<gray>Per outpost: <gold>{cost}"
outpost-upkeep: "<gray>Daily upkeep per outpost: <gold>{cost}"
upkeep: "<gold>Daily Upkeep"
Expand Down Expand Up @@ -1194,6 +1198,11 @@ admin-world:
rename-wild-description: "The name shown when players walk into unclaimed <green>land</green>."
reset: "<red>Reset to Defaults"
reset-description: "Replace this world's settings with the new-world defaults from Towny's config."
min-adjacency: "<green>Minimum Adjacent Claims"
min-adjacency-description: "How many of a town's own <green>chunks</green> a new <green>claim</green> in this world must touch. Outposts are exempt."
min-adjacency-current: "<gray>Current: <green>{count}"
min-adjacency-label: "Adjacent chunks"
min-adjacency-hint: "Enter 1, 2, or 3, or 0 to turn the rule off."
wild-build: "<gold>Wilderness Building"
wild-destroy: "<gold>Wilderness Breaking"
wild-switch: "<gold>Wilderness Switches"
Expand Down Expand Up @@ -1537,8 +1546,11 @@ tutorial:
claim-refund: "<gray>Refund per unclaimed chunk: <gold>{cost}"
outposts-disabled: "<red>Outposts are turned off on this server."
outpost-cost: "<gray>Price per outpost: <gold>{cost}"
outposts-per-world: "<gray>Outposts can only be claimed in worlds where your town has no other <green>land</green>."
cede-cost: "<gray>Price per ceded plot: <gold>{cost}"
bonus-cost: "<gray>Price per bonus claim: <gold>{cost}"
jail-hours: "<gray>Longest jail sentence: <yellow>{hours} hours"
nation-jail: "<gray>The <gold>capital</gold> can <red>jail</red> any resident of its nation, not just its own."
jailed: "<red>You are jailed: {hours} hours left."
join-nation-residents: "<gray>Residents a town needs to join a nation: <green>{count}"
nation-cost: "<gray>Founding a nation costs: <gold>{cost}"
Expand Down Expand Up @@ -1625,7 +1637,7 @@ tutorial:
unclaim: "Unclaiming Land"
unclaim-body: "Unclaim <green>chunks</green> you no longer need to free their claim slots. The <gold>home block</gold> can't be unclaimed. Some servers slowly restore unclaimed <green>land</green> to how it looked before."
outposts: "Outposts"
outposts-body: "An <light_purple>outpost</light_purple> is a <green>claim</green> away from your town, such as a distant mine or farm. Each outpost has a spawn that residents can teleport to, and more <green>land</green> can be claimed around it. A <gold>mayor</gold> can also turn an existing claim into an outpost, or move an outpost's spawn, from the <yellow>Plot menu</yellow>."
outposts-body: "An <light_purple>outpost</light_purple> is a <green>claim</green> away from your town, such as a distant mine or farm. Each outpost has a spawn that residents can teleport to, and more <green>land</green> can be claimed around it. A <gold>mayor</gold> can also turn an existing claim into an outpost, or move an outpost's spawn, from the <yellow>Plot menu</yellow>. Another town's page has an <yellow>Outposts</yellow> button that shows where its outposts are."
bonus: "Bonus Claims"
bonus-body: "Reached your claim limit? Buy bonus claims with <gold>money</gold> from the town <gold>bank</gold>. The <gold>price</gold> can rise with each one you buy."
cede: "Ceding Land"
Expand Down
Loading