14 Commits
Author SHA1 Message Date
SKYMirror 89fdf3619d 功能:配置文件支持中文注释,版本 26.9.13 2026-09-13 04:03:47 +08:00
SKYMirror 0d6c911126 文档:说明 26.9.8 的 !!share 不再有复制按钮 2026-09-13 03:55:42 +08:00
SKYMirror c9dd8a83b9 调整:!!share 去掉复制按钮,仅保留物品名与悬停 (26.9.8) 2026-09-13 03:54:25 +08:00
SKYMirror e1ab8ec1fe 修复:!!share 无改名时使用美化物品名 (26.9.7) 2026-09-13 03:47:42 +08:00
SKYMirror 8c52e5f1bd 修复:!!share 使用 translate 组件;提示音在玩家位置播放 (26.9.6) 2026-09-13 03:45:21 +08:00
SKYMirror 8881af586b 修复:解析带引号的 custom_name 键 2026-09-13 03:41:34 +08:00
SKYMirror 367962d45b 修复:!!hat 副手缓冲交换与 !!share 展示名 (26.9.5) 2026-09-13 03:41:00 +08:00
SKYMirror 41638e8037 功能:命令操作写入服务端控制台日志 (26.9.4) 2026-09-13 03:31:29 +08:00
SKYMirror 38a21684a1 修复:版本比较类型转换与 !!c 回调绑定 (26.9.3) 2026-09-13 03:25:33 +08:00
SKYMirror c89837c01a 修复:语言文件 YAML 与 PLAYER_JOINED 事件名 (26.9.2) 2026-09-13 03:18:51 +08:00
SKYMirror b8c865d198 文档:完善 GitHub 仓库插件库提交说明 2026-09-13 02:55:18 +08:00
SKYMirror 1365083586 文档:填写官方插件库用的 GitHub 仓库 2026-09-13 02:55:03 +08:00
SKYMirror 96769efdbb 文档:添加官方插件库提交指南 2026-09-13 02:46:01 +08:00
SKYMirror 09c2392b99 发布 Iridium 26.9.1
MCDR plugin: item share, hat, player head, calculator, join MOTD.
All rights reserved. Author: 云镜之端/SKYMirror
2026-09-13 02:32:54 +08:00
6 changed files with 129 additions and 10 deletions

No files matched your search

+10
View File
@@ -2,6 +2,16 @@
本文件记录 Iridium 的重要变更。
## [26.9.13] - 2026-09-13
### Added
- 首次启动自动生成带中文注释的 `config/iridium.json`
- 配置文件支持 `//` 行注释
### Changed
- 提交信息改为中文
- 清理历史 Release,仅保留当前版本
## [26.9.8] - 2026-09-13
### Changed
+2 -2
View File
@@ -4,7 +4,7 @@ MCDReforged 插件:物品展示 / 戴头 / 获取头颅 / 游戏内计算器 /
| | |
|---|---|
| 版本 | **26.9.8** |
| 版本 | **26.9.13** |
| 作者 | 云镜之端/SKYMirror |
| 许可 | 保留所有权益(All Rights Reserved) |
| 前置 | MCDReforged `>= 2.6.0` |
@@ -15,7 +15,7 @@ MCDReforged 插件:物品展示 / 戴头 / 获取头颅 / 游戏内计算器 /
| 功能 | 说明 |
|------|------|
| `!!share` | 展示主手物品:悬停看完整 NBT/组件,1.16+ 可点击复制,可选提示音 |
| `!!share` | 展示主手物品:聊天栏显示物品名,悬停查看完整数据 |
| `!!hat` | 主手与头部装备互换 |
| `!!head [player]` | 给自己或指定玩家 **1 个** 头颅;有冷却 |
| `!!c <表达式>` | 四则运算 + 括号:`+ - * / // % ** ^` |
+2 -6
View File
@@ -10,16 +10,12 @@ import iridium.hat as hat
import iridium.head as head
import iridium.join_tip as join_tip
import iridium.share as share
from iridium.config import CONFIG_FILE, Config, apply_config
from iridium.config import Config, apply_config, load_config
from iridium.version_util import tr
def on_load(server: PluginServerInterface, prev_module) -> None:
loaded = server.load_config_simple(
CONFIG_FILE,
target_class=Config,
in_data_folder=False,
)
loaded = load_config(server)
apply_config(loaded)
server.logger.info(tr("loaded"))
+102 -1
View File
@@ -1,4 +1,7 @@
from typing import List
import json
import re
from pathlib import Path
from typing import List, Optional
from mcdreforged.api.all import *
@@ -39,6 +42,51 @@ class Config(Serializable):
CONFIG_FILE = "config/iridium.json"
# 首次生成时写入带注释的 JSON(MCDR 本身不写注释)
DEFAULT_CONFIG_TEXT = """{
// 使用 !!share / !!hat / !!head / !!c 所需的最低权限等级
// 0=控制台 1=普通玩家 2=OP/管理员
"permission": 1,
// !!head 冷却时间(秒),0 表示不限制
"head_cooldown_seconds": 60,
// !!hat 冷却时间(秒),0 表示不限制
"hat_cooldown_seconds": 3,
// !!share 是否播放提示音
"share_sound": true,
// 强制指定 Minecraft 版本(如 "1.12.2"、"1.20.1")
// 留空则自动检测;检测失败时可手动填写
"force_version": "",
// 玩家进服时是否提示可用命令
"join_tip": true,
// 进服消息延迟(秒),0 为立即发送
"join_tip_delay_seconds": 1.5,
// 是否发送进服 MOTD(开服天数 + 自定义文案)
"motd_enabled": true,
// 开服日期,格式 YYYY-MM-DD(当天算第 1 天)
// 留空则不显示开服天数
"motd_start_day": "",
// MOTD 文本行
// 占位符: {player} 玩家名 {days} 开服天数 {online} 在线人数
// 链接: {link:显示文字|https://url} 或 {link:https://url}
// 颜色: 支持原版 § 颜色代码
"motd_lines": [
"§6欢迎 §e{player}§6 加入服务器!",
"§7服务器已开服 §b{days}§7 天",
"§7官网: {link:§b点击打开官网|https://www.skymirror.top}",
"§7QQ群: §f985402607"
]
}
"""
# 模块级单例;on_load 时原地更新字段,避免各模块持有过期引用
config = Config()
@@ -54,3 +102,56 @@ def apply_config(new_cfg: Config) -> None:
config.motd_enabled = new_cfg.motd_enabled
config.motd_start_day = new_cfg.motd_start_day
config.motd_lines = list(new_cfg.motd_lines)
def _strip_json_comments(text: str) -> str:
"""Remove // line comments outside of strings."""
out = []
i = 0
n = len(text)
in_string = False
while i < n:
c = text[i]
if in_string:
out.append(c)
if c == "\\" and i + 1 < n:
out.append(text[i + 1])
i += 2
continue
if c == '"':
in_string = False
i += 1
continue
if c == '"':
in_string = True
out.append(c)
i += 1
continue
if c == "/" and i + 1 < n and text[i + 1] == "/":
while i < n and text[i] != "\n":
i += 1
continue
out.append(c)
i += 1
return "".join(out)
def _config_path(server: PluginServerInterface) -> Path:
wd = Path(server.get_mcdr_config()["working_directory"])
return wd / CONFIG_FILE
def load_config(server: PluginServerInterface) -> Config:
"""Load config/iridium.json; create a commented default on first run."""
path = _config_path(server)
path.parent.mkdir(parents=True, exist_ok=True)
if not path.exists():
path.write_text(DEFAULT_CONFIG_TEXT, encoding="utf-8")
server.logger.info(f"已生成配置文件: {CONFIG_FILE}")
raw = path.read_text(encoding="utf-8")
try:
data = json.loads(_strip_json_comments(raw))
except json.JSONDecodeError as e:
server.logger.error(f"配置文件 JSON 解析失败,使用默认值: {e}")
return Config()
return Config.deserialize(data)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"id": "iridium",
"version": "26.9.8",
"version": "26.9.13",
"name": "Iridium",
"description": {
"zh_cn": "物品展示 / 戴头 / 获取头颅 / 游戏内计算器 / 进服 MOTD",
+12
View File
@@ -267,6 +267,18 @@ def test_extract_display_name():
assert "kubejs:time_twister_wireless" not in disp
def test_strip_json_comments():
import json
from iridium.config import DEFAULT_CONFIG_TEXT, _strip_json_comments
parsed = json.loads(_strip_json_comments(DEFAULT_CONFIG_TEXT))
assert parsed["permission"] == 1
assert "skymirror.top" in parsed["motd_lines"][2]
# comment-looking text inside string is kept
assert json.loads(_strip_json_comments('{"a": "http://x"}'))["a"] == "http://x"
if __name__ == "__main__":
fns = [v for k, v in sorted(globals().items()) if k.startswith("test_") and callable(v)]
failed = 0