Skip to content

About

Minecraft offline variables for folia

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

CustomOfflineVariables

中文 | English

中文

CustomOfflineVariables 是一个适用于 Paper/Folia 的 PlaceholderAPI 插件。它可以在玩家退出时保存配置的占位符值,并通过自定义占位符读取在线或离线玩家的数据。

支持版本

  • Minecraft / Paper / Folia:26.2
  • Java:25 或更高版本
  • PlaceholderAPI:2.12.3 或兼容版本
  • 数据库:MySQL 或 SQLite

构建步骤

Linux / macOS

./gradlew clean build

Windows

gradlew.bat clean build

构建完成后,插件位于:

build/libs/CustomOfflineVariables-1.2.0.jar

Gradle Wrapper 会自动下载所需的 Gradle 版本,无需单独安装 Gradle,但必须安装 JDK 25。

安装步骤

  1. 安装支持 Minecraft 26.2 的 Paper 或 Folia 服务端。
  2. 安装 PlaceholderAPI。
  3. 将构建出的 JAR 放入服务器的 plugins 文件夹。
  4. 启动服务器,使插件生成默认配置。
  5. 编辑 plugins/CustomOfflineVariables/config.yml。
  6. 重启服务器,或执行 /offlinevars reload 重新加载配置。

插件内置 PlaceholderAPI expansion,不需要执行 /papi ecloud download。可以使用以下命令确认和测试:

/papi list
/papi parse <玩家名> %offlinevars_金额%

数据库配置

MySQL

先在 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 表。

SQLite

database:
  type: sqlite
  table: player_variables

SQLite 数据文件路径:

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: 60

同步配置

sync 中的占位符会在玩家退出时解析并保存:

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 说明

插件使用以下规则根据玩家名称生成离线 UUID:

OfflinePlayer:<玩家名>

它适用于离线模式玩家数据。玩家名称及大小写发生变化时,生成的离线 UUID 也可能发生变化。


English

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.

Supported versions

  • Minecraft / Paper / Folia: 26.2
  • Java: 25 or newer
  • PlaceholderAPI: 2.12.3 or a compatible version
  • Databases: MySQL or SQLite

Build

Linux / macOS

./gradlew clean build

Windows

gradlew.bat clean build

The 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.

Installation

  1. Install a Paper or Folia server for Minecraft 26.2.
  2. Install PlaceholderAPI.
  3. Copy the built JAR into the server's plugins directory.
  4. Start the server to generate the default configuration.
  5. Edit plugins/CustomOfflineVariables/config.yml.
  6. 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_金额%

Database configuration

MySQL

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_variables

After connecting successfully, the plugin creates the player_variables table automatically.

SQLite

database:
  type: sqlite
  table: player_variables

The SQLite database is stored at:

plugins/CustomOfflineVariables/database.db

Custom variables

With target-key, the plugin generates the query automatically:

variables:
  金额:
    target-key: cloud_coin
    default: "0"
    cache-duration: 60

Placeholder:

%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: 60

Synchronization

Placeholders 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

Commands and permissions

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

UUID behavior

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.

About

Minecraft offline variables for folia

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages