Skip to content

Commit 10b6f2a

Browse files
authored
Pay-To-Teleport v1.2.0 (#1)
* allow disabling commands * Remove payment message when price is 0 * Add new command "ptpwrap" for waypoints - Replace help message command texts with suggest command text, and polish text contents - Add new command section "wrap" for waypoint support: - Create: players can create global waypoints by standing on an activated beacon and texting. - Delete: anyone can delete any waypoint in the server. - Teleport: waypoints are public to everyone on the server - List: players can use command "/ptpwrap list (page)" to view all available waypoints on server. The interactable GUI is supported. * Update mod version in gradle.properties * Rename all "wrap" to "warp" * Add sound effects * Complete documents for waypoints and soundEffect * Add missing note * Update wrapstate for 1.21.5 * Replace getServerWorld() with getWorld() in PayTpCommand * Update API to 1.21.9
1 parent f6e2a8a commit 10b6f2a

File tree

17 files changed

+1151
-277
lines changed

17 files changed

+1151
-277
lines changed

README.cn.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,43 @@ See the English document [here](./README.md).
66

77
## 简介
88

9-
**PayTp** 是一款轻量但功能齐全的“付费传送”模组,让玩家在服务器或单人世界中使用物品作为货币进行传送。
10-
支持以下特性:
9+
**PayTp** 是一款轻量但功能齐全的“付费传送”模组,让玩家在服务器或单人世界中使用物品作为货币进行传送。支持以下特性:
1110

11+
- 跨维度的指定坐标传送
1212
- 玩家间传送请求系统
1313
- 家(Home)与回溯(Back)功能
14-
- 自定义传送价格算法
14+
- 信标传送点(Warp)功能
15+
- 可调整的传送价格算法
1516
- 末影箱 / 潜影盒 支付支持
16-
- Cloth Config 图形化配置界面(客户端)
17+
- **Cloth Config** 图形化配置界面(客户端)
1718
- 可作为 **纯服务器端模组** 使用(Server-Side Only)
1819

20+
大部分功能可通过将其对应指令名称设置为**空字符串****禁用**
21+
比方说:将配置文件中的`general.mainCommand``ptp`修改为****,可以禁用坐标tp功能。
22+
游戏内帮助文档将会自动适配。
23+
1924
---
2025

2126
## 可用命令总览
2227

23-
*指令中<>表示必填参数,()表示可选参数*
24-
25-
| 命令 | 功能 |
26-
|-------------------------|-----------------|
27-
| `/ptp` | 指令指南。 |
28-
| `/ptp (维度) <x> <y> <z>` | 传送到(指定维度的)指定坐标。 |
29-
| `/ptpto <玩家>` | 请求传送到指定玩家。 |
30-
| `/ptphere <玩家>` | 请求对方传送至自己当前位置。 |
31-
| `/ptpaccept (玩家)` | 接受(指定玩家的)传送请求。 |
32-
| `/ptpdeny (玩家)` | 拒绝(指定玩家的)传送请求。 |
33-
| `/ptpcancel (玩家)` | 取消(指定玩家的)传送请求。 |
34-
| `/ptpback` | 回到上一次传送点。 |
35-
| `/ptphome` | 回家。 |
36-
| `/ptphome set` | 设置家为当前位置。 |
28+
*显示均为默认配置下指令名,其中<>表示必填参数,()表示可选参数*
29+
30+
| 命令 | 功能 |
31+
|-------------------------|----------------------|
32+
| `/ptp` | 指令指南。 |
33+
| `/ptp (维度) <x> <y> <z>` | 传送到(指定维度的)指定坐标。 |
34+
| `/ptpto <玩家>` | 请求传送到指定玩家。 |
35+
| `/ptphere <玩家>` | 请求对方传送至自己当前位置。 |
36+
| `/ptpaccept (玩家)` | 接受(指定玩家的)传送请求。 |
37+
| `/ptpdeny (玩家)` | 拒绝(指定玩家的)传送请求。 |
38+
| `/ptpcancel (玩家)` | 取消(指定玩家的)传送请求。 |
39+
| `/ptpback` | 回到上一次传送点。 |
40+
| `/ptphome` | 回家。 |
41+
| `/ptphome set` | 设置家为当前位置。 |
42+
| `/ptpwarp <名称>` | 前往指定名称的全服传送点。 |
43+
| `/ptpwarp create <名称>` | 创建新的全服传送点(需在激活信标光束内) |
44+
| `/ptpwarp delete <名称>` | 删除指定名称的全服传送点 |
45+
| `/ptpwarp list (页数)` | 查看全服所有的传送点 |
3746

3847
---
3948

@@ -72,6 +81,12 @@ See the English document [here](./README.md).
7281
"backCommand": "ptpback",
7382
"maxBackStack": 10,
7483
"backMultiplier": 0.8
84+
},
85+
"warp": {
86+
"warpCommand": "ptpwarp",
87+
"maxInactiveTicks": 100,
88+
"checkPeriodTicks": 20,
89+
"warpMultiplier": 0.5
7590
},
7691
"price": {
7792
"currencyItem": "minecraft:diamond",
@@ -84,7 +99,8 @@ See the English document [here](./README.md).
8499
},
85100
"setting": {
86101
"effect": {
87-
"particleEffect": true
102+
"particleEffect": true,
103+
"soundEffect": true
88104
},
89105
"flag": {
90106
"allowEnderChest": true,
@@ -149,6 +165,17 @@ See the English document [here](./README.md).
149165

150166
---
151167

168+
### 传送点系统
169+
170+
| 字段名 | 类型 | 说明 |
171+
|--------------------|----------|-------------------------------|
172+
| `warpCommand` | `string` | 前往传送点的命令(默认 `/ptpwarp`|
173+
| `maxInactiveTicks` | `int` | 当绑定的传送点对应信标失效后,该传送点被删除前的冷却时间。 |
174+
| `checkPeriodTicks` | `int` | 传送点与信标的匹配检查间隔时间。 |
175+
| `warpMultiplier` | `double` | 传送至传送点时的倍率,例如 0.5 表示半价。 |
176+
177+
---
178+
152179

153180
### 花费计算设置
154181

@@ -176,6 +203,7 @@ See the English document [here](./README.md).
176203
| 字段名 | 类型 | 说明 |
177204
|------------------|-----------|---------------|
178205
| `particleEffect` | `boolean` | 是否启用传送时的粒子效果。 |
206+
| `soundEffect` | `boolean` | 是否启用传送时的声音效果。 |
179207

180208
#### 特性开关
181209

@@ -266,6 +294,6 @@ See the English document [here](./README.md).
266294

267295
## 致谢
268296

269-
本模组灵感来自早期经济型传送插件,请求逻辑参考**Teleport Command**模组,使用 Fabric API 编写,兼容原版存档。
297+
本模组灵感来自早期经济型传送插件,请求逻辑参考**Teleport Command**模组,传送点系统参考**Beacon Waypoint**模组。使用 Fabric API 编写,兼容原版存档。
270298
欢迎在 GitHub 上提交 Issue 或 PR 改进配置逻辑与算法。
271299

README.md

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,41 @@ It supports flexible teleportation modes, multi-language localization, and fully
1212
---
1313

1414
## Features
15-
- Pay-to-teleport system
16-
- Configurable teleport cost (item type, amount, etc.)
17-
- Cross-dimension teleport support
18-
- Support for `/back`, `/home`, and `/tpa`-like commands
19-
- Multi-language support (English, Simplified Chinese, Traditional Chinese)
20-
- Full configuration file via Cloth Config and ModMenu
15+
- Cross-dimension teleport to a specified location
16+
- Player teleport request system
17+
- Home and Back
18+
- Beacon waypoint (Warp) feature
19+
- Adjustable teleportation cost algorithm
20+
- Ender Chest / Shulker Box payment support
21+
- **Cloth Config** API support (client-side)
22+
- Can be used as a **server-side only** mod
23+
24+
Most features can be **disabled** by setting their corresponding command names to **an empty string**.
25+
For example, changing `general.mainCommand` in the config file from `ptp` to **empty** will disable the coordinate teleport function.
26+
The in-game help guide will automatically adapt.
2127

2228
---
2329

2430
## Commands
2531

26-
| Command | Description |
27-
|--------------------------------|-------------------------------------------------------------|
28-
| `/ptp ` | Get command guide for PayTp. |
29-
| `/ptp (dimension) <x> <y> <z>` | Teleport to specified coordinates (in a specific dimension) |
30-
| `/ptpto <player>` | Send request to teleport to a player |
31-
| `/ptphere <player>` | Send request to a player to teleport to you |
32-
| `/ptpaccept (player)` | Accept a teleport request (from a specific player) |
33-
| `/ptpdeny (player)` | Deny a teleport request (from a specific player) |
34-
| `/ptpcancel (player)` | Cancel a pending teleport request (to a specific player) |
35-
| `/ptpback` | Return to the previous location |
36-
| `/ptphome` | Teleport to your home (if configured) |
37-
| `/ptphome set` | Set your home to your current position |
32+
*All displays show the default command names, where <> indicates required parameters and () indicates optional parameters*
33+
34+
| Command | Description |
35+
|--------------------------------|--------------------------------------------------------------|
36+
| `/ptp ` | Get command guide for PayTp |
37+
| `/ptp (dimension) <x> <y> <z>` | Teleport to specified coordinates (in a specific dimension) |
38+
| `/ptpto <player>` | Send request to teleport to a player |
39+
| `/ptphere <player>` | Send request to a player to teleport to you |
40+
| `/ptpaccept (player)` | Accept a teleport request (from a specific player) |
41+
| `/ptpdeny (player)` | Deny a teleport request (from a specific player) |
42+
| `/ptpcancel (player)` | Cancel a pending teleport request (to a specific player) |
43+
| `/ptpback` | Return to the previous location |
44+
| `/ptphome` | Teleport to your home (if configured) |
45+
| `/ptphome set` | Set your home to your current position |
46+
| `/ptpwarp <name>` | Teleport to the specified waypoint |
47+
| `/ptpwarp create <name>` | Create a new waypoint (must be within an active beacon beam) |
48+
| `/ptpwarp delete <name>` | Delete the specified waypoint |
49+
| `/ptpwarp list (page)` | View all waypoints on the server |
3850

3951
---
4052

@@ -74,6 +86,12 @@ It supports flexible teleportation modes, multi-language localization, and fully
7486
"maxBackStack": 10,
7587
"backMultiplier": 0.8
7688
},
89+
"warp": {
90+
"warpCommand": "ptpwarp",
91+
"maxInactiveTicks": 100,
92+
"checkPeriodTicks": 20,
93+
"warpMultiplier": 0.5
94+
},
7795
"price": {
7896
"currencyItem": "minecraft:diamond",
7997
"parameter": {
@@ -85,7 +103,8 @@ It supports flexible teleportation modes, multi-language localization, and fully
85103
},
86104
"setting": {
87105
"effect": {
88-
"particleEffect": true
106+
"particleEffect": true,
107+
"soundEffect": true
89108
},
90109
"flag": {
91110
"allowEnderChest": true,
@@ -165,8 +184,19 @@ It supports flexible teleportation modes, multi-language localization, and fully
165184
| `minPrice` | `int` | Minimum teleport cost. |
166185
| `maxPrice` | `int` | Maximum cost per teleport. |
167186
| `baseRadius` | `double` | Radius within which teleportation costs the minimum price. |
168-
| `rate` | `double` | Distance rate multiplier for cost beyond base radius. |
187+
| `rate` | `double` | Distance increase rate for cost beyond base radius. |
188+
189+
---
190+
191+
### 传送点系统
169192

193+
| 字段名 | 类型 | 说明 |
194+
|--------------------|----------|--------------------------------------------------------------------------------------------|
195+
| `warpCommand` | `string` | Command name to teleport to a waypoint (default `/ptpwarp`). |
196+
| `maxInactiveTicks` | `int` | The cooldown time before a waypoint is deleted after its associated beacon is deactivated. |
197+
| `checkPeriodTicks` | `int` | The interval for checking waypoint-to-beacon matching. |
198+
| `warpMultiplier` | `double` | Waypoint teleport multiplier, e.g., 0.5 means half price. |
199+
170200
---
171201

172202
### Settings
@@ -176,6 +206,7 @@ It supports flexible teleportation modes, multi-language localization, and fully
176206
| Field | Type | Description |
177207
|------------------|-----------|-----------------------------------------------|
178208
| `particleEffect` | `boolean` | Enable particle effects during teleportation. |
209+
| `soundEffect` | `boolean` | Enable sound effects during teleportation. |
179210

180211
#### Feature Flags
181212

@@ -267,7 +298,7 @@ If the **Cloth Config API** is installed, all settings can be adjusted directly
267298

268299
## Credits
269300

270-
This mod is inspired by early economy-style teleport plugins. The request logic references the **Teleport Command** mod.
301+
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.
271302
Developed using Fabric API and fully compatible with vanilla saves.
272303
Feel free to submit issues or pull requests on GitHub to improve configuration and calculation algorithms.
273304

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ loom_version=1.11-SNAPSHOT
1616
fabric_version=0.136.0+1.21.10
1717

1818
# Mod Properties
19-
mod_version=1.1.0-1.21.10
19+
mod_version=1.2.0-1.21.10
2020
maven_group=com.flwolfy.paytp
2121
archives_base_name=pay-to-teleport
2222

src/main/java/com/flwolfy/paytp/PayTpMod.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
import com.flwolfy.paytp.command.PayTpBackManager;
44
import com.flwolfy.paytp.command.PayTpCommand;
5-
6-
import com.flwolfy.paytp.command.PayTpHomeManager;
7-
import com.flwolfy.paytp.command.PayTpRequestManager;
5+
import com.flwolfy.paytp.command.PayTpWarpManager;
86
import com.flwolfy.paytp.data.PayTpData;
9-
import com.flwolfy.paytp.data.config.PayTpConfigManager;
10-
import com.flwolfy.paytp.data.lang.PayTpLangManager;
7+
import com.flwolfy.paytp.util.PayTpMessageSender;
118

129
import net.fabricmc.api.ModInitializer;
1310
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
1411
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
12+
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
1513
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
1614

1715
import net.minecraft.server.network.ServerPlayerEntity;
16+
import net.minecraft.world.World;
1817

1918
import org.slf4j.Logger;
2019
import org.slf4j.LoggerFactory;
@@ -31,12 +30,8 @@ public class PayTpMod implements ModInitializer {
3130
*/
3231
@Override
3332
public void onInitialize() {
34-
// Init manager singletons
35-
PayTpConfigManager.getInstance();
36-
PayTpLangManager.getInstance();
37-
PayTpBackManager.getInstance();
38-
PayTpHomeManager.getInstance();
39-
PayTpRequestManager.getInstance();
33+
// Init command
34+
PayTpCommand.init();
4035

4136
// Register events
4237
registerEvents();
@@ -52,13 +47,24 @@ private void registerEvents() {
5247
});
5348

5449
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
55-
PayTpBackManager.getInstance().clearHistory(handler.player);
50+
if (handler.player != null) {
51+
PayTpBackManager.getInstance().clearHistory(handler.player);
52+
}
5653
});
5754

5855
ServerLivingEntityEvents.AFTER_DEATH.register((entity, livingEntity) -> {
5956
if (entity instanceof ServerPlayerEntity player) {
6057
PayTpBackManager.getInstance().pushSingle(player, new PayTpData(player.getEntityWorld().getRegistryKey(), player.getEntityPos()));
6158
}
6259
});
60+
61+
ServerTickEvents.END_WORLD_TICK.register(world -> {
62+
if (!world.getRegistryKey().equals(World.OVERWORLD)) return;
63+
PayTpWarpManager.getInstance().checkWarpState(world.getServer(), name -> {
64+
for (ServerPlayerEntity onlinePlayer : world.getServer().getPlayerManager().getPlayerList()) {
65+
PayTpMessageSender.msgWarpDeletedServer(onlinePlayer, name);
66+
}
67+
});
68+
});
6369
}
6470
}

0 commit comments

Comments
 (0)