PayTp 模组文档 (v2)
- 更新于 2026-09-19
- 让我们共同翻译 PayTp!
- 中文文档请看这里
请注意,由于 API 发生了巨大变化,且 Minecraft 不再对源代码进行混淆,因此 v1.2.0 之后的补丁将不支持低于 26.1 的版本。*
关于数据迁移,请查看此处。*
概述
PayTp 是一款轻量级的 Fabric 模组,允许玩家通过支付一定数量的游戏内货币(物品)进行传送。
它支持灵活的传送模式、多语言本地化以及完全可定制的费用规则。
功能
- 可编辑的命令名称
- 跨维度传送到指定位置
- 玩家传送请求系统
- 家与返回(Home and Back)
- 信标路标(Warp)功能,带有分类的分页 SGUI 浏览器
- 完全可定制的 JEXL 传送价格与距离算法
- 末影箱 / 潜影盒支付支持
- Cloth Config API 支持(客户端)
- 可作为仅限服务端的模组使用
大多数功能可以通过将其对应的命令名称设置为空字符串来禁用。
例如,将配置文件中的 teleport.coordinateCommand 从 ptp 更改为空,即可禁用坐标传送功能。
游戏内的帮助指南会自动适应。
命令
所有显示均为默认命令名称,其中 <> 表示必需参数,() 表示可选参数
每个 <player> 参数仅接受并建议在线玩家名称;不支持实体选择器,如 @a、@p 和 @s。
/ptp <x> <y> <z> 文本是一种不可选择的格式提示,而非当前坐标建议;~ 和 ^ 相对坐标仍然受支持。
路标名称可以包含 Unicode 和特殊字符,只要不包含空格即可无需引号。包含空格的路标名称必须在每个路标命令中用双引号括起来。没有空格但带引号的名称同样有效。示例:主城, 主城#1, 和 "Main City"。创建时需要类型在名称之前,例如 /ptpwarp create server 主城;删除保留可选后缀形式 /ptpwarp delete "主城" forced。没有遗留的重复命令分支。当光标紧跟在 teleport、delete、rename、invite 或 exclude 之后时,服务器会列出完整适用的路标选项,如 "樱花谷";这是一个选择列表,而不是在输入部分名称后的前缀匹配。随后完成 invite/exclude 的在线玩家。点击 /ptphelp 中的命令仅插入其可执行命令前缀,永远不会复制占位符文本,如 <name> 或 <player>。
| 命令 |
描述 |
/ptphelp |
获取 PayTp 命令指南 |
/ptp (dimension) <x> <y> <z> |
传送到指定坐标(在特定维度内) |
/ptpto <player> |
发送传送到某玩家的请求 |
/ptphere <player> |
向某玩家发送请求,让其传送到你 |
/ptpaccept (player) |
接受传送请求(来自特定玩家) |
/ptpdeny (player) |
拒绝传送请求(来自特定玩家) |
/ptpcancel (player) |
取消待处理的传送请求(针对特定玩家) |
/ptpback |
返回到上一个位置 |
/ptphome |
传送到你的家(如果已配置) |
/ptphome set |
将你的家设置为当前位置 |
/ptpwarp |
打开分类的分页服务端路标 SGUI。 |
/ptpwarp teleport <name> |
传送到指定的路标 |
/ptpwarp create (private/public/server) <name> |
创建具有明确类型的路标;server 受权限控制。 |
/ptpwarp delete <name> (forced) |
删除你的路标;forced 受权限控制。 |
/ptpwarp rename <name> <new_name> |
重命名你创建的路标。 |
/ptpwarp invite <name> <player> |
邀请一名玩家加入你的私有路标之一。 |
/ptpwarp exclude <name> <player> |
从私有路标中移除已邀请的玩家。 |
/ptpwarp list (all/public/owned/invited/server) (page) |
筛选并分页浏览服务端路标。 |
配置
配置文件位置:
~/config/paytp.json
示例结构:
{
"general": {
"language": "en_us",
"helpCommand": "ptphelp",
"safeTeleport": false,
"safeTeleportRange": 5,
"effect": {
"particleEffect": true,
"soundEffect": true
}
},
"teleport": {
"coordinateCommand": "ptp",
"allowCrossDim": true
},
"request": {
"requestCommand": {
"toCommand": "ptpto",
"hereCommand": "ptphere",
"acceptCommand": "ptpaccept",
"denyCommand": "ptpdeny",
"cancelCommand": "ptpcancel"
},
"expireTime": 10
},
"home": {
"homeCommand": "ptphome",
"setRespawnPoint": false
},
"back": {
"backCommand": "ptpback",
"maxBackStack": 10
},
"warp": {
"warpCommand": "ptpwarp",
"serverWarpPermission": 2,
"autoDeleteInactiveWarps": true,
"maxInactiveTicks": 100,
"checkPeriodTicks": 20
},
"price": {
"currencyItem": "minecraft:diamond",
"minPrice": 1,
"maxPrice": 64,
"algorithm": "// 可用变量:\n//\n// 变量 | 可用方法\n// -------- | -----------------------------------------------------------\n// from | .x(), .y(), .z(), .dimension()\n// to | .x(), .y(), .z(), .dimension()\n// context | .coordinate(), .home(), .back(), .request(), .warp()\n// player | .uuid(), .name()\n// callback | .onSuccess(), .onFailure()\n//\n// Java 的内置 Math 方法可通过 \"math\" 命名空间使用。\n// Minecraft 命令可通过 minecraft:execute(\"command\") 使用。\n// 完整的系统 Shell 访问权限可通过 \"shell\" 命名空间使用。\n\nvar basePrice = 1;\nvar baseRadius = 10.0;\nvar pricePerBlock = 0.01;\nvar crossDimensionMultiplier = 1.5;\nvar homeMultiplier = 0.5;\nvar backMultiplier = 0.8;\nvar warpMultiplier = 0.5;\nvar netherCoordinateScale = 8.0;\n\nvar crossDimension = from.dimension() !== to.dimension();\nvar deltaX = from.x() - to.x();\nvar deltaY = from.y() - to.y();\nvar deltaZ = from.z() - to.z();\n\nif (crossDimension) {\n if (from.dimension() == \"minecraft:the_end\") {\n deltaX = from.x();\n deltaY = from.y();\n deltaZ = from.z();\n } else if (to.dimension() == \"minecraft:the_end\") {\n deltaX = to.x();\n deltaY = to.y();\n deltaZ = to.z();\n } else if (from.dimension() == \"minecraft:the_nether\") {\n deltaX = from.x() * netherCoordinateScale - to.x();\n deltaY = from.y() * netherCoordinateScale - to.y();\n deltaZ = from.z() * netherCoordinateScale - to.z();\n } else if (to.dimension() == \"minecraft:the_nether\") {\n deltaX = from.x() - to.x() / netherCoordinateScale;\n deltaY = from.y() - to.y() / netherCoordinateScale;\n deltaZ = from.z() - to.z() / netherCoordinateScale;\n }\n}\n\nvar distance = math:sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);\nvar multiplier = crossDimension ? crossDimensionMultiplier : 1.0;\n\nif (context.home() !== null) {\n multiplier = multiplier * homeMultiplier;\n} else if (context.back() !== null) {\n multiplier = multiplier * backMultiplier;\n} else if (context.warp() !== null) {\n multiplier = multiplier * warpMultiplier;\n}\n\nvar distanceBeyondBase = distance > baseRadius ? distance - baseRadius : 0;\n\ncallback.onSuccess() += () -> {\n minecraft:execute(\n \"effect give \" + player.name() + \" minecraft:weakness 1 1\"\n );\n};\n\ncallback.onFailure() += () -> {\n minecraft:execute(\"say hi\");\n};\n\nmath:round((basePrice + distanceBeyondBase * pricePerBlock) * multiplier).intValue();",
"deduction": {
"allowEnderChest": true,
"prioritizeEnderChest": true,
"allowShulkerBox": false,
"prioritizeShulkerBox": false
}
}
}
配置详情
常规设置
| 字段 |
类型 |
描述 |
language |
string |
自动发现的内置语言区域设置(例如 en_us);影响消息、SGUI 和帮助文本。 |
helpCommand |
string |
用于显示 PayTp 指南的命令(默认 /ptphelp)。 |
safeTeleport |
boolean |
将不安全的目的地移动到最近的安全位置;默认为 false。 |
safeTeleportRange |
int |
最大水平和垂直安全位置搜索范围;默认为 5,且必须介于 1 到 64 之间。 |
添加语言
在 src/main/resources/assets/pay-to-teleport/lang/ 下添加 <locale>.json。区域设置文件名必须匹配 [a-z0-9][a-z0-9_-]*,并且每个文件都必须包含一个非空的 paytp.language.name,供 Mod Menu 选择器使用。PayTp 会自动从模组容器中检测到所有匹配的 JSON 文件;添加语言无需编辑 Java 枚举、Gson 适配器或 UI 注册表。en_us.json 是必需的后备语言。其他语言中缺失的键将回退到英语,并产生一次性的服务器警告。
传送效果 (general.effect)
| 字段 |
类型 |
描述 |
particleEffect |
boolean |
启用传送粒子效果;默认为 true。 |
soundEffect |
boolean |
启用传送音效;默认为 true。 |
坐标传送
| 字段 |
类型 |
描述 |
coordinateCommand |
string |
坐标传送命令(默认 /ptp)。 |
allowCrossDim |
boolean |
是否允许任何传送方法跨维度;默认为 true。当禁用时,维度参数不会被注册或显示。 |
传送请求系统
请求命令
| 字段 |
类型 |
描述 |
toCommand |
string |
请求传送到目标玩家的命令(默认 /ptpto)。 |
hereCommand |
string |
请求目标玩家传送到你所在位置的命令(默认 /ptphere)。 |
acceptCommand |
string |
接受请求的命令(默认 /ptpaccept)。 |
denyCommand |
string |
拒绝请求的命令(默认 /ptpdeny)。 |
cancelCommand |
string |
取消已发送请求的命令(默认 /ptpcancel)。 |
配置
| 字段 |
类型 |
描述 |
expireTime |
int |
请求过期时间(秒);默认为 10,且必须为非负数。 |
家园系统
| 字段 |
类型 |
描述 |
homeCommand |
string |
传送至家园的命令(默认 /ptphome)。 |
setRespawnPoint |
boolean |
设置家园时也移动玩家的重生点;默认为 false。当玩家在“家园”重生时,始终使用原版床的起身位置解析器;如果未找到有效位置,玩家将被移动到世界出生点。 |
返回系统
| 字段 |
类型 |
描述 |
backCommand |
string |
返回上一个位置的命令(默认 /ptpback)。 |
maxBackStack |
int |
保存的历史位置的最大数量;默认为 10,且必须大于零。 |
传送点系统
| 字段 |
类型 |
描述 |
warpCommand |
string |
传送到传送点的命令名称(默认 /ptpwarp)。 |
serverWarpPermission |
int |
创建服务器传送点和强制删除传送点所需的 Minecraft 权限等级;范围从 0 到 4,默认为 2。 |
autoDeleteInactiveWarps |
boolean |
在信标超过非活跃超时时间后删除传送点;默认为 true。当禁用时,它将保持不可用状态,直到信标重新激活。 |
maxInactiveTicks |
int |
信标非活跃超时时间(以刻为单位);默认为 100,且必须为非负数。 |
checkPeriodTicks |
int |
传送点到信标的检查间隔(以刻为单位);默认为 20,且必须大于零。 |
执行 /ptpwarp 命令且不带参数时,会为所有玩家打开一个包含六个筛选条件的 SGUI(服务器端 GUI),筛选条件分别为:全部、服务器、所有者、公开、邀请和已锁定。这些筛选条件在第一列垂直排列,图标依次为:水桶、下界合金锭、金锭、铁锭、铜锭和空桶;第二列为青染色玻璃分隔条。在剩余的 7×6 区域中,顶行包含“上一页”、汇总书和“下一页”,中间 7×4 的区域每页显示 28 个传送点,底行左侧放置“刷新”,右侧放置“关闭”。每个可用的传送点均以绿宝石块表示,而不可用和已锁定的传送点则以红石块表示。尝试访问已锁定的传送点时,会提示“未获得访问权限”,而不是声称该传送点不存在。已锁定的条目不会透露其所有者或坐标信息。每次点击都会通过相同的访问、活动、安全、跨维度、价格和支付路径重新解析该传送点,这与使用 /ptpwarp teleport <name> 时的逻辑一致,因此如果在菜单打开期间某个传送点被删除或失效,则无法从过期的菜单数据中使用它。该 SGUI 使用原版容器数据包,无需安装客户端模组。
费用计算设置
货币
| 字段 |
类型 |
描述 |
currencyItem |
string |
有效的货币物品 ID;默认为 minecraft:diamond。 |
价格范围与算法
| 字段 |
类型 |
描述 |
minPrice |
int |
非负价格的最终下限;默认为 1,且必须满足 0 <= minPrice <= maxPrice。 |
maxPrice |
int |
最终上限;默认为 64。将 minPrice 和 maxPrice 同时设置为 0 将跳过算法,并将价格固定为 0。 |
algorithm |
string |
一个 JEXL 脚本,用于计算距离和原始价格,且必须返回一个 int 类型的值。 |
支付扣除 (price.deduction)
| 字段 |
类型 |
描述 |
allowEnderChest |
boolean |
允许使用末影箱中的货币;默认为 true。 |
prioritizeEnderChest |
boolean |
优先从末影箱中扣除;默认为 true,且需要 allowEnderChest 开启。 |
allowShulkerBox |
boolean |
允许使用潜影盒中的货币;默认为 false。 |
prioritizeShulkerBox |
boolean |
优先从潜影盒中扣除;默认为 false,且需要 allowShulkerBox 开启。 |
JEXL 价格算法
price.algorithm 字符串同时包含距离计算和价格计算逻辑。服务端没有固定的距离公式或传送乘数。脚本可以非常简单,例如 10,这将返回固定的价格为 10。
可用变量
| 变量 |
类型 |
可用方法 |
from |
position |
.x(), .y(), .z(), .dimension() |
to |
position |
.x(), .y(), .z(), .dimension() |
context |
context |
.coordinate(), .home(), .back(), .request(), .warp() |
player |
player |
.uuid(), .name() |
callback |
callback |
.onSuccess(), .onFailure() |
context 包含五个可空的嵌套记录。每次执行时,恰好有一个访问器返回一个记录,其余四个返回 null:
| 访问器 |
记录内容 |
context.coordinate() |
坐标命令上下文;当前为空。 |
context.home() |
家上下文;当前为空。 |
context.back() |
返回上下文;当前为空。 |
context.request() |
otherPlayer() 返回另一个玩家,包含 uuid() 和 name();
isRequester() 是一个 bool 类型,指示当前 player 是否为请求发起者。 |
context.warp() |
包含 name()、accessType() 和 owner();其中 owner() 具有 uuid() 和 name()。 |
当当前 player 发起请求时,isRequester() 为 true;当他们接受传送到请求发送者的请求时,为 false。传送点的 accessType() 可以是 owned(所有者)、invited(邀请)、server(服务器)或 public(公开);对于无所有者的服务器传送点,owner() 为 null。
传送回调
callback.onSuccess() 和 callback.onFailure() 是每次传送各自独立的回调链。使用 += 可以追加任意数量的 JEXL Lambda 表达式。如果后续可能需要通过 -= 移除,请先将 Lambda 保存到变量中:
var audit = () -> {
minecraft:execute("scoreboard players add " + player.name() + " tp_success 1");
};
callback.onSuccess() += audit;
callback.onSuccess() += () -> {
minecraft:execute("tell " + player.name() + " Teleport completed");
};
callback.onSuccess() -= audit;
callback.onFailure() += () -> {
minecraft:execute("scoreboard players add " + player.name() + " tp_failed 1");
};
回调按照注册顺序执行。移除回调时需要相同的 Lambda 对象;重复编写相同的 Lambda 表达式会创建不同的对象。回调出错时会记录日志,但不会阻止后续回调的执行。价格脚本在目的地验证之前运行,以便当世界不可用、缺少安全目的地或禁用了跨维度传送时,能够调用 callback.onFailure();因此 to 代表最初请求的目的地。直到所有目的地检查通过后才会扣除费用。如果 maxPrice 为 0,则跳过价格脚本,不注册任何回调。
故意不提供 crossDimension。请在脚本内部确定它:
var crossDimension = from.dimension() != to.dimension();
返回值与严格模式
- 最后一个表达式必须返回一个
int。整数字面量(如 10)已满足此要求。
- 返回负整数将取消支付和传送。这允许算法或 Minecraft 命令结果有意停止操作,而不会导致脚本错误。
- JEXL 以严格模式运行,因此未定义的变量和无效的表达式被视为错误。
数学方法
[!TIP]
直接在价格算法中使用 math 进行距离、乘数、舍入和边界计算,无需调用外部进程。
math 命名空间暴露了 Java 内置的 Math 方法。
| 方法 |
返回类型 |
描述 |
math:sqrt(value) |
double |
返回值的平方根。 |
math:max(first, second) |
numeric |
返回两个值中较大的一个。 |
math:min(first, second) |
numeric |
返回两个值中较小的一个。 |
math:round(value) |
long |
返回最接近的整数值。 |
math:pow(base, exponent) |
double |
将 base 提升到指定的幂。 |
math:abs(value) |
numeric |
返回绝对值。 |
这些方法可能返回除 int 之外的数值类型。必要时请显式转换最终结果:
math:round(rawPrice).intValue();
Minecraft 命令
[!WARNING]
minecraft 命名空间可以执行服务器注册的所有命令,包括其他模组添加的命令。命令以服务器控制台身份运行,拥有 ALL_PERMISSIONS 权限,因此可以执行破坏性或管理性操作,例如 op、ban、data 和 stop。仅使用来自完全可信来源的算法。
| 方法 |
返回类型 |
描述 |
minecraft:execute(command) |
int |
执行 Minecraft 命令。前导 / 是可选的,并且会抑制命令反馈。 |
服务器(而非被传送的玩家)是命令源,因此不能使用 @s 来引用玩家。当命令需要玩家目标时,请使用算法中的 player.name()。涉及位置或维度的命令应明确指定其目标、坐标和维度,而不是依赖基于玩家的命令上下文:
minecraft:execute("scoreboard players add " + player.name() + " teleport_count 1");
minecraft:execute("effect give " + player.name() + " minecraft:regeneration 5 0");
10;
在配置验证期间,minecraft:execute(...) 返回 0 且不运行命令,因此加载或编辑算法不会修改服务器状态。
Shell 命令
[!CAUTION]
shell 命名空间以与 Minecraft 服务器相同的操作系统权限执行任意命令。仅使用来自完全可信来源的算法。Shell 命令是同步的,因此在完成之前会阻塞服务器线程。它们也在算法验证期间执行,包括配置加载、编辑和导入。
| 方法 |
返回类型 |
描述 |
shell:execute(command) |
ShellResult |
在类 Unix 系统上通过 /bin/sh -c 或在 Windows 上通过 cmd.exe /c 执行。 |
shell:run(command) |
string |
返回标准输出,或者在退出代码非零时抛出错误。 |
shell:runInt(command) |
int |
要求标准输出恰好包含一个有效的整数。 |
ShellResult 暴露了 exitCode、stdout 和 stderr:
var result = shell:execute("python3 /opt/paytp/price.py");
result.exitCode == 0 ? result.stdoutInt() : 0;
对于价格算法,runInt 通常是最简单的形式:
shell:runInt("python3 /opt/paytp/price.py '" + player.name() + "'");
示例算法
// 可用变量:
//
// 变量 | 可用方法
// -------- | -----------------------------------------------------------
// from | .x(), .y(), .z(), .dimension()
// to | .x(), .y(), .z(), .dimension()
// context | .coordinate(), .home(), .back(), .request(), .warp()
// player | .uuid(), .name()
// callback | .onSuccess(), .onFailure()
//
// Java 的内置 Math 方法可通过 "math" 命名空间访问。
// Minecraft 命令可通过 minecraft:execute("command") 访问。
// 完整的系统 Shell 访问权限可通过 "shell" 命名空间获得。
var basePrice = 1;
var baseRadius = 10.0;
var pricePerBlock = 0.01;
var crossDimensionMultiplier = 1.5;
var homeMultiplier = 0.5;
var backMultiplier = 0.8;
var warpMultiplier = 0.5;
var netherCoordinateScale = 8.0;
var crossDimension = from.dimension() != to.dimension();
var deltaX = from.x() - to.x();
var deltaY = from.y() - to.y();
var deltaZ = from.z() - to.z();
if (crossDimension) {
if (from.dimension() == "minecraft:the_end") {
deltaX = from.x();
deltaY = from.y();
deltaZ = from.z();
} else if (to.dimension() == "minecraft:the_end") {
deltaX = to.x();
deltaY = to.y();
deltaZ = to.z();
} else if (from.dimension() == "minecraft:the_nether") {
deltaX = from.x() * netherCoordinateScale - to.x();
deltaY = from.y() * netherCoordinateScale - to.y();
deltaZ = from.z() * netherCoordinateScale - to.z();
} else if (to.dimension() == "minecraft:the_nether") {
deltaX = from.x() - to.x() / netherCoordinateScale;
deltaY = from.y() - to.y() / netherCoordinateScale;
deltaZ = from.z() - to.z() / netherCoordinateScale;
}
}
var distance = math:sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
var multiplier = crossDimension ? crossDimensionMultiplier : 1.0;
if (context.home() != null) {
multiplier = multiplier * homeMultiplier;
} else if (context.back() != null) {
multiplier = multiplier * backMultiplier;
} else if (context.warp() != null) {
multiplier = multiplier * warpMultiplier;
}
callback.onSuccess() += () -> {
minecraft:execute("effect give " + player.name() + " minecraft:weakness 1 1");
};
var distanceBeyondBase = distance > baseRadius ? distance - baseRadius : 0;
math:round((basePrice + distanceBeyondBase * pricePerBlock) * multiplier).intValue();
默认算法额外处理下界坐标缩放和末地维度。它会被写入新生成的配置文件中,并可作为完整的起始模板使用。
验证与最终价格
- 如果
maxPrice 为 0,则不执行算法,每次传送费用均为 0。
- 负的脚本结果将取消支付和传送,且不会被截断。
- 否则,脚本结果将被强制截断到闭区间
[minPrice, maxPrice] 内。
- 在验证配置时,脚本会被编译并测试执行。在 Mod Menu 中,无效输入会标记为红色并阻止保存。
- 如果在实际传送过程中算法失败,
calculatePrice 返回 -1;PayTp 会记录错误、取消传送,并通知玩家支付流程失败。
Cloth Config 支持
如果客户端安装了 Cloth Config API,所有设置均可通过 Mod Menu 进行调整。该屏幕仅编辑该客户端本地的 config/paytp.json 文件;无法修改远程专用服务器。保存时会验证并以原子方式写入 UTF-8 JSON,但不会热重载正在运行的世界或服务器。要应用更改,请退出并重新打开单人/LAN 世界,或重启已编辑文件的专用服务器。价格算法可以在专用的多行编辑器中进行编辑,或从 .jexl 文件导入;无效的算法无法保存。
兼容性与部署
| 类型 |
支持情况 |
| Fabric Loader |
是 |
| 仅限服务端 |
是;未修改的原版客户端可以连接 |
| 客户端 UI (Cloth Config) |
可选;仅限本地配置 |
| 多语言支持 |
自动发现捆绑的 JSON 本地化文件 |
| Minecraft 版本 |
26.1+ 1.21.4 ~ 1.21.11 (legacy) |
PB4 SGUI 打包在 PayTp 服务端 JAR 内部,并通过原版容器数据包进行通信。PayTp 仅注册原版 Brigadier 参数类型,因此既不需要安装 waypoint 名称也不需要安装 SGUI 的客户端要求。
致谢
本模组受早期经济类传送插件启发。请求逻辑参考了 Teleport Command 模组。路点逻辑参考了 Beacon Waypoint 模组。
使用 Fabric API 开发,完全兼容原版存档。
欢迎在 GitHub 上提交问题或拉取请求,以改进配置和计算算法。
PayTp Mod Documentation (v2)
- Updated on 2026-09-19
- Let's translate PayTp together!
- 中文文档请看这里
*To be noted, due to huge API changes and the fact that Minecraft is no longer using obfuscation for source codes, patches later than v1.2.0 will NOT support versions below 26.1.
*For data migration, please check here.
Overview
PayTp is a lightweight Fabric mod for Minecraft that allows players to teleport by paying a certain amount of in-game currency (items).
It supports flexible teleportation modes, multi-language localization, and fully customizable cost rules.
Features
- Editable command names
- Cross-dimension teleport to a specified location
- Player teleport request system
- Home and Back
- Beacon waypoint (Warp) feature with a categorized, paginated SGUI browser
- Fully customizable JEXL teleportation price and distance algorithm
- Ender Chest / Shulker Box payment support
- Cloth Config API support (client-side)
- Can be used as a server-side only mod
Most features can be disabled by setting their corresponding command names to an empty string.
For example, changing teleport.coordinateCommand in the config file from ptp to empty will disable the coordinate teleport function.
The in-game help guide will automatically adapt.
Commands
All displays show the default command names, where <> indicates required parameters and () indicates optional parameters
Every <player> argument accepts and suggests online player names only; entity selectors such as @a, @p, and @s are not supported.
The /ptp <x> <y> <z> text is a non-selectable format hint rather than a current-coordinate suggestion; ~ and ^ relative coordinates remain supported.
Waypoint names may contain Unicode and special characters without quotes as long as they contain no whitespace. A name containing spaces must be enclosed in double quotes in every waypoint command. Quoted names without spaces remain valid as well. Examples: 主城, 主城#1, and "Main City". Create requires the type before the name, such as /ptpwarp create server 主城; delete keeps the optional suffix form /ptpwarp delete "主城" forced. There are no legacy duplicate command branches. With the cursor immediately after teleport, delete, rename, invite, or exclude, the server lists complete applicable waypoint choices such as "樱花谷"; this is a choice list, not prefix matching after typing part of a name. Online players are then completed after invite/exclude. Clicking a command in /ptphelp inserts only its executable command prefix and never copies placeholder text such as <name> or <player>.
| Command |
Description |
/ptphelp |
Get command guide for PayTp |
/ptp (dimension) <x> <y> <z> |
Teleport to specified coordinates (in a specific dimension) |
/ptpto <player> |
Send request to teleport to a player |
/ptphere <player> |
Send request to a player to teleport to you |
/ptpaccept (player) |
Accept a teleport request (from a specific player) |
/ptpdeny (player) |
Deny a teleport request (from a specific player) |
/ptpcancel (player) |
Cancel a pending teleport request (to a specific player) |
/ptpback |
Return to the previous location |
/ptphome |
Teleport to your home (if configured) |
/ptphome set |
Set your home to your current position |
/ptpwarp |
Open the categorized and paginated server-side waypoint SGUI. |
/ptpwarp teleport <name> |
Teleport to the specified waypoint |
/ptpwarp create (private/public/server) <name> |
Create a waypoint with an explicit type; server is permission-controlled. |
/ptpwarp delete <name> (forced) |
Delete your waypoint; forced is permission-controlled. |
/ptpwarp rename <name> <new_name> |
Rename a waypoint you created. |
/ptpwarp invite <name> <player> |
Invite a player to one of your private waypoints. |
/ptpwarp exclude <name> <player> |
Remove an invited player from a private waypoint. |
/ptpwarp list (all/public/owned/invited/server) (page) |
Filter and page through server waypoints. |
Configuration
Configuration File Location:
~/config/paytp.json
Example Structure:
{
"general": {
"language": "en_us",
"helpCommand": "ptphelp",
"safeTeleport": false,
"safeTeleportRange": 5,
"effect": {
"particleEffect": true,
"soundEffect": true
}
},
"teleport": {
"coordinateCommand": "ptp",
"allowCrossDim": true
},
"request": {
"requestCommand": {
"toCommand": "ptpto",
"hereCommand": "ptphere",
"acceptCommand": "ptpaccept",
"denyCommand": "ptpdeny",
"cancelCommand": "ptpcancel"
},
"expireTime": 10
},
"home": {
"homeCommand": "ptphome",
"setRespawnPoint": false
},
"back": {
"backCommand": "ptpback",
"maxBackStack": 10
},
"warp": {
"warpCommand": "ptpwarp",
"serverWarpPermission": 2,
"autoDeleteInactiveWarps": true,
"maxInactiveTicks": 100,
"checkPeriodTicks": 20
},
"price": {
"currencyItem": "minecraft:diamond",
"minPrice": 1,
"maxPrice": 64,
"algorithm": "// Available variables:\n//\n// Variable | Available methods\n// -------- | -----------------------------------------------------------\n// from | .x(), .y(), .z(), .dimension()\n// to | .x(), .y(), .z(), .dimension()\n// context | .coordinate(), .home(), .back(), .request(), .warp()\n// player | .uuid(), .name()\n// callback | .onSuccess(), .onFailure()\n//\n// Java\u0027s built-in Math methods are available through the \"math\" namespace.\n// Minecraft commands are available through minecraft:execute(\"command\").\n// Full system shell access is available through the \"shell\" namespace.\n\nvar basePrice \u003d 1;\nvar baseRadius \u003d 10.0;\nvar pricePerBlock \u003d 0.01;\nvar crossDimensionMultiplier \u003d 1.5;\nvar homeMultiplier \u003d 0.5;\nvar backMultiplier \u003d 0.8;\nvar warpMultiplier \u003d 0.5;\nvar netherCoordinateScale \u003d 8.0;\n\nvar crossDimension \u003d from.dimension() !\u003d to.dimension();\nvar deltaX \u003d from.x() - to.x();\nvar deltaY \u003d from.y() - to.y();\nvar deltaZ \u003d from.z() - to.z();\n\nif (crossDimension) {\n if (from.dimension() \u003d\u003d \"minecraft:the_end\") {\n deltaX \u003d from.x();\n deltaY \u003d from.y();\n deltaZ \u003d from.z();\n } else if (to.dimension() \u003d\u003d \"minecraft:the_end\") {\n deltaX \u003d to.x();\n deltaY \u003d to.y();\n deltaZ \u003d to.z();\n } else if (from.dimension() \u003d\u003d \"minecraft:the_nether\") {\n deltaX \u003d from.x() * netherCoordinateScale - to.x();\n deltaY \u003d from.y() * netherCoordinateScale - to.y();\n deltaZ \u003d from.z() * netherCoordinateScale - to.z();\n } else if (to.dimension() \u003d\u003d \"minecraft:the_nether\") {\n deltaX \u003d from.x() - to.x() / netherCoordinateScale;\n deltaY \u003d from.y() - to.y() / netherCoordinateScale;\n deltaZ \u003d from.z() - to.z() / netherCoordinateScale;\n }\n}\n\nvar distance \u003d math:sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);\nvar multiplier \u003d crossDimension ? crossDimensionMultiplier : 1.0;\n\nif (context.home() !\u003d null) {\n multiplier \u003d multiplier * homeMultiplier;\n} else if (context.back() !\u003d null) {\n multiplier \u003d multiplier * backMultiplier;\n} else if (context.warp() !\u003d null) {\n multiplier \u003d multiplier * warpMultiplier;\n}\n\nvar distanceBeyondBase \u003d distance \u003e baseRadius ? distance - baseRadius : 0;\n\ncallback.onSuccess() +\u003d () -\u003e {\n minecraft:execute(\n \"effect give \" + player.name() + \" minecraft:weakness 1 1\"\n );\n};\n\ncallback.onFailure() +\u003d () -\u003e {\n minecraft:execute(\"say hi\");\n};\n\nmath:round((basePrice + distanceBeyondBase * pricePerBlock) * multiplier).intValue();",
"deduction": {
"allowEnderChest": true,
"prioritizeEnderChest": true,
"allowShulkerBox": false,
"prioritizeShulkerBox": false
}
}
}
Configuration Details
General Settings
| Field |
Type |
Description |
language |
string |
Automatically discovered bundled language locale (for example en_us); affects messages, SGUI, and help text. |
helpCommand |
string |
Command used to display the PayTp guide (default /ptphelp). |
safeTeleport |
boolean |
Move an unsafe destination to the nearest safe position; defaults to false. |
safeTeleportRange |
int |
Maximum horizontal and vertical safe-position search range; defaults to 5 and must be from 1 to 64. |
Adding a Language
Add <locale>.json under src/main/resources/assets/pay-to-teleport/lang/. The locale filename must match [a-z0-9][a-z0-9_-]*, and every file must contain a non-blank paytp.language.name used by the Mod Menu selector. PayTp discovers all matching JSON files from the mod container automatically; adding a language does not require editing a Java enum, Gson adapter, or UI registry. en_us.json is required as the fallback. Missing keys in another language fall back to English and produce a one-time server warning.
Teleport Effects (general.effect)
| Field |
Type |
Description |
particleEffect |
boolean |
Enable teleport particles; defaults to true. |
soundEffect |
boolean |
Enable teleport sounds; defaults to true. |
Coordinate Teleport
| Field |
Type |
Description |
coordinateCommand |
string |
Coordinate teleport command (default /ptp). |
allowCrossDim |
boolean |
Whether any teleport method may cross dimensions; defaults to true. When disabled, the dimension argument is not registered or displayed. |
Teleport Request System
Request Commands
| Field |
Type |
Description |
toCommand |
string |
Command to request teleporting to the target player (default /ptpto). |
hereCommand |
string |
Command to request the target player to teleport to your location (default /ptphere). |
acceptCommand |
string |
Command to accept a request (default /ptpaccept). |
denyCommand |
string |
Command to deny a request (default /ptpdeny). |
cancelCommand |
string |
Command to cancel a sent request (default /ptpcancel). |
Configuration
| Field |
Type |
Description |
expireTime |
int |
Request expiration time in seconds; defaults to 10 and must be non-negative. |
Home System
| Field |
Type |
Description |
homeCommand |
string |
Command to teleport home (default /ptphome). |
setRespawnPoint |
boolean |
Also move the player's respawn point when setting home; defaults to false. When the player respawns at Home, the vanilla bed stand-up position resolver is always used; if it finds no valid position, the player is moved to the world spawn point. |
Back System
| Field |
Type |
Description |
backCommand |
string |
Command to return to previous location (default /ptpback). |
maxBackStack |
int |
Maximum saved historical positions; defaults to 10 and must be greater than zero. |
Waypoint System
| Field |
Type |
Description |
warpCommand |
string |
Command name to teleport to a waypoint (default /ptpwarp). |
serverWarpPermission |
int |
Minecraft permission level required to create server waypoints and force-delete waypoints; ranges from 0 to 4 and defaults to 2. |
autoDeleteInactiveWarps |
boolean |
Delete a waypoint after its beacon exceeds the inactivity timeout; defaults to true. When disabled, it remains unavailable until the beacon reactivates. |
maxInactiveTicks |
int |
Beacon inactivity timeout in ticks; defaults to 100 and must be non-negative. |
checkPeriodTicks |
int |
Waypoint-to-beacon check interval in ticks; defaults to 20 and must be greater than zero. |
Running /ptpwarp without arguments opens a six-filter SGUI for all, server, owned, public, invited, and locked waypoints. The filters are arranged vertically in the first column as a water bucket, netherite ingot, gold ingot, iron ingot, copper ingot, and empty bucket; the second column is a cyan stained-glass divider. In the remaining 7×6 region, the top row contains Previous, the summary book, and Next, the middle 7×4 area displays 28 waypoints per page, and the bottom row places Refresh on the left and Close on the right. Every usable waypoint is an emerald block, while inactive and locked waypoints are redstone blocks. Attempting a locked waypoint reports that access has not been granted instead of claiming the waypoint does not exist. Locked entries do not reveal their owner or coordinates. Every click resolves the waypoint again through the same access, activity, safety, cross-dimension, price, and payment path used by /ptpwarp teleport <name>, so a waypoint deleted or invalidated while the menu is open cannot be used from stale menu data. The SGUI uses vanilla container packets and requires no client mod.
Cost Calculation Settings
Currency
| Field |
Type |
Description |
currencyItem |
string |
A valid currency item ID; defaults to minecraft:diamond. |
Price Range and Algorithm
| Field |
Type |
Description |
minPrice |
int |
Final lower bound for non-negative prices; defaults to 1 and must satisfy 0 <= minPrice <= maxPrice. |
maxPrice |
int |
Final upper bound; defaults to 64. Setting both minPrice and maxPrice to 0 skips the algorithm and fixes the price at 0. |
algorithm |
string |
A JEXL script that calculates distance and raw price and must return an int. |
Payment Deduction (price.deduction)
| Field |
Type |
Description |
allowEnderChest |
boolean |
Allow Ender Chest currency; defaults to true. |
prioritizeEnderChest |
boolean |
Prioritize Ender Chest deduction; defaults to true and requires allowEnderChest. |
allowShulkerBox |
boolean |
Allow Shulker Box currency; defaults to false. |
prioritizeShulkerBox |
boolean |
Prioritize Shulker Box deduction; defaults to false and requires allowShulkerBox. |
JEXL Price Algorithm
The price.algorithm string contains both the distance calculation and the price calculation. There are no fixed Java-side distance formulas or teleport multipliers. A script may be as simple as 10, which returns a fixed price of 10.
Available Variables
| Variable |
Type |
Available methods |
from |
position |
.x(), .y(), .z(), .dimension() |
to |
position |
.x(), .y(), .z(), .dimension() |
context |
context |
.coordinate(), .home(), .back(), .request(), .warp() |
player |
player |
.uuid(), .name() |
callback |
callback |
.onSuccess(), .onFailure() |
context contains five nullable nested records. Exactly one accessor returns a record for
each execution; the other four return null:
| Accessor |
Record contents |
context.coordinate() |
Coordinate-command context; currently empty. |
context.home() |
Home context; currently empty. |
context.back() |
Back context; currently empty. |
context.request() |
otherPlayer() returns the other player with uuid() and name();
isRequester() is a bool indicating whether the current player initiated the request. |
context.warp() |
name(), accessType(), and owner(); the owner has uuid() and name(). |
isRequester() is true when the current player initiated the request and false when they
accepted a request to teleport to its sender. Warp accessType() is owned, invited, server,
or public; owner() is null for an ownerless server waypoint.
Teleport Callbacks
callback.onSuccess() and callback.onFailure() are independent callback chains for each teleport. Use += to append
any number of JEXL lambdas. Save a lambda to a variable first if it may later be removed with -=:
var audit = () -> {
minecraft:execute("scoreboard players add " + player.name() + " tp_success 1");
};
callback.onSuccess() += audit;
callback.onSuccess() += () -> {
minecraft:execute("tell " + player.name() + " Teleport completed");
};
callback.onSuccess() -= audit;
callback.onFailure() += () -> {
minecraft:execute("scoreboard players add " + player.name() + " tp_failed 1");
};
Callbacks execute in registration order. Removing one requires the same lambda object; repeating
the same lambda expression creates a different object. A callback error is logged without stopping
later callbacks. The price script runs before destination validation so that an unavailable world,
missing safe destination, or disabled cross-dimension teleport can invoke callback.onFailure();
to therefore represents the originally requested destination. No payment is taken until all
destination checks pass. A maxPrice of 0 bypasses the price script, so no callbacks are
registered.
crossDimension is intentionally not provided. Determine it inside the script:
var crossDimension = from.dimension() != to.dimension();
Return Value and Strict Mode
- The last expression must return an
int. Integer literals such as 10 already satisfy this requirement.
- Returning a negative integer cancels the payment and teleport. This allows an algorithm or
Minecraft command result to deliberately stop the operation without causing a script error.
- JEXL runs in strict mode, so undefined variables and invalid expressions are treated as errors.
Math Methods
[!TIP]
Use math for distance, multiplier, rounding, and boundary calculations directly inside the price algorithm without invoking an external process.
The math namespace exposes Java's built-in Math methods.
| Method |
Return type |
Description |
math:sqrt(value) |
double |
Returns the square root of a value. |
math:max(first, second) |
numeric |
Returns the greater of two values. |
math:min(first, second) |
numeric |
Returns the smaller of two values. |
math:round(value) |
long |
Returns the closest integer value. |
math:pow(base, exponent) |
double |
Raises base to the supplied power. |
math:abs(value) |
numeric |
Returns the absolute value. |
Methods may return a numeric type other than int. Convert the final result explicitly when
necessary:
math:round(rawPrice).intValue();
Minecraft Commands
[!WARNING]
The minecraft namespace can execute every command registered with the server, including commands added by other mods. Commands run as the server console with ALL_PERMISSIONS, so they can perform destructive or administrative operations such as op, ban, data, and stop. Only use algorithms from fully trusted sources.
| Method |
Return type |
Description |
minecraft:execute(command) |
int |
Executes a Minecraft command. The leading / is optional and command feedback is suppressed. |
The server—not the teleported player—is the command source, so @s cannot be used to refer to the
player. Use the algorithm's player.name() when a command needs a player target. Commands involving
locations or dimensions should specify their target, coordinates, and dimension explicitly instead
of relying on player-relative command context:
minecraft:execute("scoreboard players add " + player.name() + " teleport_count 1");
minecraft:execute("effect give " + player.name() + " minecraft:regeneration 5 0");
10;
During configuration validation, minecraft:execute(...) returns 0 without running the command,
so loading or editing an algorithm cannot modify server state.
Shell Commands
[!CAUTION]
The shell namespace executes arbitrary commands with the same operating-system permissions as the Minecraft server. Only use algorithms from fully trusted sources. Shell commands are synchronous and therefore block the server thread until they finish. They are also executed during algorithm validation, including config loading, editing, and importing.
| Method |
Return type |
Description |
shell:execute(command) |
ShellResult |
Executes through /bin/sh -c on Unix-like systems or cmd.exe /c on Windows. |
shell:run(command) |
string |
Returns standard output, or throws an error when the exit code is non-zero. |
shell:runInt(command) |
int |
Requires standard output to contain exactly one valid integer. |
ShellResult exposes exitCode, stdout, and stderr:
var result = shell:execute("python3 /opt/paytp/price.py");
result.exitCode == 0 ? result.stdoutInt() : 0;
For a price algorithm, runInt is usually the simplest form:
shell:runInt("python3 /opt/paytp/price.py '" + player.name() + "'");
Example Algorithm
// Available variables:
//
// Variable | Available methods
// -------- | -----------------------------------------------------------
// from | .x(), .y(), .z(), .dimension()
// to | .x(), .y(), .z(), .dimension()
// context | .coordinate(), .home(), .back(), .request(), .warp()
// player | .uuid(), .name()
// callback | .onSuccess(), .onFailure()
//
// Java's built-in Math methods are available through the "math" namespace.
// Minecraft commands are available through minecraft:execute("command").
// Full system shell access is available through the "shell" namespace.
var basePrice = 1;
var baseRadius = 10.0;
var pricePerBlock = 0.01;
var crossDimensionMultiplier = 1.5;
var homeMultiplier = 0.5;
var backMultiplier = 0.8;
var warpMultiplier = 0.5;
var netherCoordinateScale = 8.0;
var crossDimension = from.dimension() != to.dimension();
var deltaX = from.x() - to.x();
var deltaY = from.y() - to.y();
var deltaZ = from.z() - to.z();
if (crossDimension) {
if (from.dimension() == "minecraft:the_end") {
deltaX = from.x();
deltaY = from.y();
deltaZ = from.z();
} else if (to.dimension() == "minecraft:the_end") {
deltaX = to.x();
deltaY = to.y();
deltaZ = to.z();
} else if (from.dimension() == "minecraft:the_nether") {
deltaX = from.x() * netherCoordinateScale - to.x();
deltaY = from.y() * netherCoordinateScale - to.y();
deltaZ = from.z() * netherCoordinateScale - to.z();
} else if (to.dimension() == "minecraft:the_nether") {
deltaX = from.x() - to.x() / netherCoordinateScale;
deltaY = from.y() - to.y() / netherCoordinateScale;
deltaZ = from.z() - to.z() / netherCoordinateScale;
}
}
var distance = math:sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
var multiplier = crossDimension ? crossDimensionMultiplier : 1.0;
if (context.home() != null) {
multiplier = multiplier * homeMultiplier;
} else if (context.back() != null) {
multiplier = multiplier * backMultiplier;
} else if (context.warp() != null) {
multiplier = multiplier * warpMultiplier;
}
callback.onSuccess() += () -> {
minecraft:execute("effect give " + player.name() + " minecraft:weakness 1 1");
};
var distanceBeyondBase = distance > baseRadius ? distance - baseRadius : 0;
math:round((basePrice + distanceBeyondBase * pricePerBlock) * multiplier).intValue();
The default algorithm additionally handles Nether coordinate scaling and The End. It is written into a newly generated configuration file and can be used as a complete starting template.
Validation and Final Price
- If
maxPrice is 0, the algorithm is not executed and every teleport costs 0.
- A negative script result cancels the payment and teleport without being clamped.
- Otherwise, the script result is forcibly clamped to the inclusive range
[minPrice, maxPrice].
- The script is compiled and test-executed when the configuration is validated. In Mod Menu, invalid input is marked red and prevents saving.
- If an algorithm fails during an actual teleport,
calculatePrice returns -1; PayTp logs the error, cancels the teleport, and notifies the player that the payment process failed.
Cloth Config Support
If the Cloth Config API is installed on a client, all settings can be adjusted through Mod Menu. The screen edits only that client's local config/paytp.json; it cannot modify a remote dedicated server. Saving validates and atomically writes UTF-8 JSON but does not hot-reload a running world or server. Leave and reopen a single-player/LAN world, or restart the dedicated server whose file was edited, to apply changes. The price algorithm can be edited in a dedicated multi-line editor or imported from a .jexl file; invalid algorithms cannot be saved.
Compatibility & Deployment
| Type |
Supported |
| Fabric Loader |
Yes |
| Server Only |
Yes; unmodified vanilla clients can connect |
| Client UI (Cloth Config) |
Optional; local configuration only |
| Multi-language Support |
Automatically discovered bundled JSON locales |
| Minecraft Version |
26.1+ 1.21.4 ~ 1.21.11 (legacy) |
PB4 SGUI is bundled inside the PayTp server JAR and communicates through vanilla container packets. PayTp registers only vanilla Brigadier argument types, so neither waypoint names nor the SGUI introduce a client installation requirement.
Credits
This mod is inspired by early economy-style teleport plugins. The request logic references the Teleport Command mod. The waypoint logic references the Beacon Waypoint mod.
Developed using Fabric API and fully compatible with vanilla saves.
Feel free to submit issues or pull requests on GitHub to improve configuration and calculation algorithms.
评论 0
登录后参与评分
还没有评论,来抢沙发吧