From da15dfeec6afca915cdb4e82ba55f34b2f79b486 Mon Sep 17 00:00:00 2001 From: Alex3236 <45303195+eagle3236@users.noreply.github.com> Date: Mon, 10 May 2021 12:49:45 +0800 Subject: [PATCH] 4.1 --- daycount.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/daycount.py b/daycount.py index 1a64334..5f39230 100644 --- a/daycount.py +++ b/daycount.py @@ -5,11 +5,12 @@ # ----------------------------------------- nbt_file = 'server/world/level.dat' # NBT 文件位置,设置为 -1 以使用日期模式 start_date = '2021-01-01' # 开服日期 +day_text = '这是服务器开服的第 $day 天' # 显示文字 # ----------------------------------------- PLUGIN_METADATA = { 'id': 'daycount_nbt', - 'version': '4.0', + 'version': '4.1', 'name': 'DayCount-NBT', 'description': '通过读取 NBT 文件,获取服务器总运行时间。', 'author': 'Alex3236', @@ -18,7 +19,6 @@ def getday(): try: - global nbt_file, start_date if isinstance(nbt_file, str): import nbtlib return floor(nbtlib.load(nbt_file)['']['Data']['Time'] / 1728000) @@ -26,10 +26,11 @@ def getday(): except Exception: return 0 +def get_day_text(): + return day_text.replace('$day', str(getday())) def display_days(source: CommandSource): - source.reply(f'这是服务器开服的第 {getday()} 天') - + source.reply(get_day_text()) def on_load(server: ServerInterface, old): server.register_command(Literal('!!day').runs(display_days))