SMP 位置保存器
一个适用于 Minecraft 1.21.8 的 Bukkit 插件,用于在 SMP 世界中保存和恢复玩家的位置。
功能
- 自动保存:当玩家离开 SMP 世界时保存其位置
- 自动恢复:当玩家进入 SMP 世界时恢复上次保存的位置
- 灵活的配置:可配置被视为 SMP 的世界列表
- 多世界支持:同时处理多个 SMP 世界
- YAML 存储:位置数据存储在
positions.yml 中
安装
- 使用 Maven 编译插件:
mvn clean package
-
将生成的 JAR 文件从 target/ 目录复制到服务器的 plugins/ 文件夹中。
-
重启服务器或重新加载插件。
配置
config.yml 文件将在插件文件夹中自动生成:
# SMP 世界配置
smp-worlds:
- "world"
- "world_nether"
- "world_the_end"
- "survival"
- "survival_nether"
- "survival_the_end"
# 自定义消息
messages:
position-saved: "§a你的位置已在 {world} 中保存!"
position-restored: "§a你已被传送至你在 {world} 中的上一个位置!"
no-position-saved: "§c该世界没有已保存的位置。"
config-reloaded: "§a配置已成功重载!"
# 选项
options:
save-on-quit: true
restore-on-join: true
clear-on-death: true
debug: false
# 进入/退出 SMP 世界时执行的数据包函数
entry-function: "datapack:functions/enter_smp"
exit-function: "datapack:functions/exit_smp"
SMP 世界配置
在 smp-worlds 部分添加或删除世界名称,以定义哪些世界属于 SMP 组。
- 名称可以是精确匹配,也可以使用通配符
*。例如 world_* 将匹配 world_1、world_nether 等。
选项
save-on-quit: 当玩家离开服务器时保存位置
restore-on-join: 当玩家加入服务器时恢复位置
clear-on-death: 当玩家在 SMP 世界中死亡时清除已保存的坐标
debug: 启用调试日志
工作原理
当玩家进入 SMP 世界时:
- 插件检查该玩家在此世界中是否保存了位置
- 如果存在,则将玩家传送至上一次保存的位置
- 否则,会发送一条消息告知他们当前没有可用位置
当玩家离开 SMP 世界时:
- 插件自动保存玩家的当前位置
- 记录坐标(x, y, z)、方向(yaw, pitch)和世界名称
- 发送一条消息确认保存成功
数据存储
位置数据保存在 plugins/SMPPositionSaver/positions.yml 中,结构如下:
players:
<player-uuid>:
<world-name>:
x: 123.45
y: 64.0
z: -456.78
yaw: 90.0
pitch: 0.0
权限
smppositionsaver.use: 允许使用位置保存系统(默认:true)
命令
/smp: 将玩家传送至配置文件中定义的 SMP 坐标。
/smp reload: 重载配置文件;需要权限 smp.reload(默认为 op)。
此命令并非正常运行所必需,但在编辑 config.yml 后无需重启服务器时非常有用。
兼容性
- Minecraft: 1.21.8
- API: Spigot/Paper 1.21+
- Java: 21+
开发
插件包含以下组件:
SMPPositionSaver: 主插件类
ConfigManager: 配置管理器
PositionManager: 玩家位置管理器
PlayerWorldChangeListener: 监听世界变更事件
PlayerPosition: 表示已保存位置的模型
支持
如有任何问题或故障,请查看服务器日志或在配置中启用调试模式。
SMP Position Saver
A Bukkit plugin for Minecraft 1.21.8 that saves and restores player positions in SMP worlds.
Features
- Auto save: Saves player position when they leave an SMP world
- Auto restore: Restores the last saved position when a player enters an SMP world
- Flexible configuration: Configurable list of worlds treated as SMP
- Multi-world support: Handles multiple SMP worlds at once
- YAML storage: Positions stored in
positions.yml
Installation
- Compile the plugin with Maven:
mvn clean package
-
Copy the generated JAR from target/ to your server's plugins/ folder.
-
Restart the server or reload the plugins.
Configuration
The config.yml file will be generated automatically in the plugin folder:
# SMP worlds configuration
smp-worlds:
- "world"
- "world_nether"
- "world_the_end"
- "survival"
- "survival_nether"
- "survival_the_end"
# Customizable messages
messages:
position-saved: "§aYour position has been saved in {world}!"
position-restored: "§aYou have been teleported to your last position in {world}!"
no-position-saved: "§cNo saved position for this world."
config-reloaded: "§aConfiguration reloaded successfully!"
# Options
options:
save-on-quit: true
restore-on-join: true
clear-on-death: true
debug: false
# Datapack functions executed when entering/exiting an SMP world
entry-function: "datapack:functions/enter_smp"
exit-function: "datapack:functions/exit_smp"
SMP worlds configuration
Add or remove worlds in the smp-worlds section to define which worlds belong to the SMP group.
- Names may be exact or use the wildcard
*. For instance world_* will match world_1, world_nether, etc.
Options
save-on-quit: Save the position when the player leaves the server
restore-on-join: Restore the position when the player joins the server
clear-on-death: Remove saved coordinates when a player dies in an SMP world
debug: Enable debug logging
How it works
When a player enters an SMP world:
- The plugin checks if a position was saved for that player in this world
- If so, the player is teleported to their last saved position
- Otherwise a message informs them that no position is available
When a player leaves an SMP world:
- The plugin automatically saves the player's current position
- Coordinates (x, y, z), orientation (yaw, pitch) and world are recorded
- A message confirms the save
Data storage
Positions are saved in plugins/SMPPositionSaver/positions.yml with this structure:
players:
<player-uuid>:
<world-name>:
x: 123.45
y: 64.0
z: -456.78
yaw: 90.0
pitch: 0.0
Permissions
smppositionsaver.use: Allows use of the position saving system (default: true)
Commands
/smp: Teleports the player to the SMP coordinates defined in the configuration.
/smp reload: Reloads the configuration file; requires permission smp.reload (op by default).
This command isn't required for normal operation but can be useful after editing config.yml without restarting the server.
Compatibility
- Minecraft: 1.21.8
- API: Spigot/Paper 1.21+
- Java: 21+
Development
The plugin is structured with the following components:
SMPPositionSaver: Main plugin class
ConfigManager: Configuration manager
PositionManager: Player position manager
PlayerWorldChangeListener: Listener for world change events
PlayerPosition: Model representing a saved position
Support
For any questions or issues, please check the server logs or enable debug mode in the configuration.
评论 0
登录后参与评分
还没有评论,来抢沙发吧