TownyExternal
一个简单插件,通过简洁易用的 HTTP API 暴露 Towny 的信息。
默认情况下,服务器监听 127.0.0.1:8064,但可以进行配置。
端点
/api/towns 获取所有城镇的列表
/api/town/{id} 获取特定城镇
/api/nations 获取所有国家的列表
/api/nation/{id} 获取特定国家
缓存
TownyExternal 有三种类型的缓存:Redis、H2 和 Postgres。
对于拥有大量玩家、城镇或国家的服务器来说,H2 可能会占用过多内存或速度过慢。在这种情况下,你可以使用 Postgres 或 Redis。
H2(推荐,默认)
所有内容都将存储在内存中。这是最简单且默认的选项,但由于重启服务器时会清除缓存,因此相比其他两种选项需要更多调用 Towny API。
如果你没有预先设置的内容,则无需在 config.yml 中添加此行(因为它是默认值),但你也可以添加。
cache: "h2"
Redis
需要安装 Redis 或类似程序如 Valkey。
将以下内容添加到你的 config.yml 中。
cache: "redis"
redis-host: "127.0.0.1" # 或者你的主机地址
redis-port: "6379" # 或者你的端口号
redis-prefix: "" # 可以留空,如果其他程序使用相同数据库可设置前缀
Postgres
需要安装 PostgreSQL。
将以下内容添加到你的 config.yml 中。
cache: "postgres"
postgres-host: "127.0.0.1" # 或者你的主机地址
postgres-port: "5432" # 或者你的端口号
postgres-db: "townyexternal" # 或者你的数据库名称
postgres-user: "youruser" # 修改此项
postgres-pass: "yourpass" # 修改此项
TownyExternal
A simple plugin that exposes information from Towny in a simple, easy to use, HTTP API.
By default, the server listens to 127.0.0.1:8064, but that can be configured.
Endpoints
/api/towns fetches a list of all towns
/api/town/{id} fetches a specific town
/api/nations fetches a list of all nations
/api/nation/{id} fetches a specific nation
Caching
There are three types of caches for TownyExternal: Redis, H2, and Postgres.
For some servers with a large amount of players, towns, or nations, H2 might use too much memory or be too slow. In
that case, you can use Postgres or Redis.
H2 (recommended, default)
Everything will be stored in memory. This is the easiest option and default, but required more calls to the Towny API than the other two options since the cache will be cleared when your server restarts.
If you have nothing already set, you don't have to add this line to your config.yml since it's default, but you can.
cache: "h2"
Redis
Requires installation of Redis or a similar program like Valkey.
Add the following to your config.yml.
cache: "redis"
redis-host: "127.0.0.1" # or whatever your host is
redis-port: "6379" # or whatever your port is
redis-prefix: "" # can be left blank, set if you have other programs using the same database
Postgres
Requires installation of PostgreSQL.
Add the following to your config.yml.
cache: "postgres"
postgres-host: "127.0.0.1" # or whatever your host is
postgres-port: "5432" # or whatever your port is
postgres-db: "townyexternal" # or whatever your database name is
postgres-user: "youruser" # change this
postgres-pass: "yourpass" # change this
评论 0
登录后参与评分
还没有评论,来抢沙发吧