CustomOfflineVariables 是一个适用于 Paper/Folia 的 PlaceholderAPI 插件。它可以在玩家退出时保存配置的占位符值,并通过自定义占位符读取在线或离线玩家的数据。
- Minecraft / Paper / Folia:
26.2 - Java:
25或更高版本 - PlaceholderAPI:
2.12.3或兼容版本 - 数据库:MySQL 或 SQLite
./gradlew clean buildgradlew.bat clean build构建完成后,插件位于:
build/libs/CustomOfflineVariables-1.2.0.jar
Gradle Wrapper 会自动下载所需的 Gradle 版本,无需单独安装 Gradle,但必须安装 JDK 25。
- 安装支持 Minecraft 26.2 的 Paper 或 Folia 服务端。
- 安装 PlaceholderAPI。
- 将构建出的 JAR 放入服务器的
plugins文件夹。 - 启动服务器,使插件生成默认配置。
- 编辑
plugins/CustomOfflineVariables/config.yml。 - 重启服务器,或执行
/offlinevars reload重新加载配置。
插件内置 PlaceholderAPI expansion,不需要执行 /papi ecloud download。可以使用以下命令确认和测试:
/papi list
/papi parse <玩家名> %offlinevars_金额%
先在 MySQL 中创建配置对应的数据库:
CREATE DATABASE IF NOT EXISTS `minecraft-offline-papi`
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;然后配置连接信息:
database:
type: mysql
host: localhost
port: 3306
database: minecraft-offline-papi
username: root
password: password
table: player_variables插件连接成功后会自动创建 player_variables 表。
database:
type: sqlite
table: player_variablesSQLite 数据文件路径:
plugins/CustomOfflineVariables/database.db
使用 target-key 时,插件会自动生成查询:
variables:
金额:
target-key: cloud_coin
default: "0"
cache-duration: 60占位符:
%offlinevars_金额%
也可以配置自定义 SQL。查询中的 %uuid% 和 %name% 会被替换为目标玩家的离线 UUID 和名称:
variables:
example:
query: "SELECT value FROM custom_table WHERE uuid = '%uuid%'"
return-column: value
default: "N/A"
cache-duration: 60sync 中的占位符会在玩家退出时解析并保存:
sync:
save_cloud_coin:
placeholder: "%cmi_user_balance_formatted%"
target-key: cloud_coin
sync-on-quit: true| 命令 | 说明 | 权限 |
|---|---|---|
/offlinevars info |
显示插件信息 | 无 |
/offlinevars reload |
重新加载配置 | offlinevars.admin |
/offlinevars debug <玩家> <变量> |
调试变量查询 | offlinevars.admin |
插件使用以下规则根据玩家名称生成离线 UUID:
OfflinePlayer:<玩家名>
它适用于离线模式玩家数据。玩家名称及大小写发生变化时,生成的离线 UUID 也可能发生变化。
CustomOfflineVariables is a PlaceholderAPI plugin for Paper and Folia. It saves configured placeholder values when a player disconnects and exposes custom placeholders for online and offline player data.
- Minecraft / Paper / Folia:
26.2 - Java:
25or newer - PlaceholderAPI:
2.12.3or a compatible version - Databases: MySQL or SQLite
./gradlew clean buildgradlew.bat clean buildThe output JAR is created at:
build/libs/CustomOfflineVariables-1.2.0.jar
The Gradle Wrapper downloads the required Gradle version automatically. A JDK 25 installation is required.
- Install a Paper or Folia server for Minecraft 26.2.
- Install PlaceholderAPI.
- Copy the built JAR into the server's
pluginsdirectory. - Start the server to generate the default configuration.
- Edit
plugins/CustomOfflineVariables/config.yml. - Restart the server or run
/offlinevars reload.
The PlaceholderAPI expansion is bundled and registers automatically. Do not use /papi ecloud download. Check and test it with:
/papi list
/papi parse <player> %offlinevars_金额%
Create the configured database first:
CREATE DATABASE IF NOT EXISTS `minecraft-offline-papi`
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;Configure the connection:
database:
type: mysql
host: localhost
port: 3306
database: minecraft-offline-papi
username: root
password: password
table: player_variablesAfter connecting successfully, the plugin creates the player_variables table automatically.
database:
type: sqlite
table: player_variablesThe SQLite database is stored at:
plugins/CustomOfflineVariables/database.db
With target-key, the plugin generates the query automatically:
variables:
金额:
target-key: cloud_coin
default: "0"
cache-duration: 60Placeholder:
%offlinevars_金额%
Custom SQL is also supported. %uuid% and %name% are replaced with the target player's offline UUID and name:
variables:
example:
query: "SELECT value FROM custom_table WHERE uuid = '%uuid%'"
return-column: value
default: "N/A"
cache-duration: 60Placeholders under sync are parsed and saved when a player disconnects:
sync:
save_cloud_coin:
placeholder: "%cmi_user_balance_formatted%"
target-key: cloud_coin
sync-on-quit: true| Command | Description | Permission |
|---|---|---|
/offlinevars info |
Show plugin information | None |
/offlinevars reload |
Reload the configuration | offlinevars.admin |
/offlinevars debug <player> <variable> |
Debug a variable query | offlinevars.admin |
The plugin generates an offline UUID from the player name using:
OfflinePlayer:<player name>
This is intended for offline-mode player data. Changing the player name or its letter case may produce a different offline UUID.