2.2 pre1
This commit is contained in:
parent
41b2cf8fcc
commit
8cab44655a
18
CHANGELOG.md
18
CHANGELOG.md
@ -2,6 +2,24 @@
|
||||
|
||||
>所有可查阅的更改记录皆可在此处找到
|
||||
|
||||
### v2.2 pre1
|
||||
|
||||
- `census`地毯脚本更新至1.3.1版本
|
||||
- 修复一些显示bug
|
||||
- 现在基本可以正常使用**仍然不能保证稳定性(数据安全性)**
|
||||
- 添加了可以用来`迁移`数据的Python脚本 `score_move`
|
||||
- 使用时与`server`文件夹同级
|
||||
- `score_move.py`
|
||||
- `server`
|
||||
- `server.jar`
|
||||
- ······
|
||||
- ······
|
||||
- ······
|
||||
- 更改了文件结构,将地毯脚本移动到`脚本`文件夹中
|
||||
- 可能会有release
|
||||
- 以后准备要重写整个Datapack了
|
||||
- 3.0!
|
||||
|
||||
### v2.1.3 pre1
|
||||
|
||||
- 添加`census`地毯脚本
|
||||
|
11
README.md
11
README.md
@ -42,11 +42,17 @@ A Minecraft Datapack
|
||||
| fz.aviate1m | 滑翔距离 |
|
||||
|
||||
- 提供一些[地毯脚本](#地毯脚本)(`.sc` 文件):***请在升级数据包的同时替换这些工具!!!***
|
||||
- 还有一个用于`census`脚本转移数据的python脚本`score_move`
|
||||
|
||||
## 更新记录
|
||||
|
||||
更新记录可在[此处](./CHANGELOG.md)找到
|
||||
|
||||
- 目前稳定版
|
||||
- 2.1.2 & 2.0.10
|
||||
- 目前测试版
|
||||
- 2.2 pre1
|
||||
|
||||
## 使用
|
||||
|
||||
### 注意事项
|
||||
@ -124,3 +130,8 @@ A Minecraft Datapack
|
||||
- 输入 `/restore_scores by_whitelist` 开始数据迁移
|
||||
- 输入 `/script unload restore_scores` 卸载工具
|
||||
- 记得用完就删掉它!
|
||||
|
||||
### `Census.sc`
|
||||
|
||||
- `/census`
|
||||
- 一个还在测试的脚本,可以输出挖掘榜
|
||||
|
56
脚本/score_move.py
Normal file
56
脚本/score_move.py
Normal file
@ -0,0 +1,56 @@
|
||||
"""
|
||||
writen by shenjackyuanjie
|
||||
mail: 3695888@qq.com
|
||||
github: @shenjackyuanjie
|
||||
gitee: @shenjackyuanjie
|
||||
"""
|
||||
|
||||
# -------------------------------
|
||||
# Census loader
|
||||
# Copyright © 2021 by shenjackyuanjie
|
||||
# All rights reserved
|
||||
# -------------------------------
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
USERCACHE_PATH = os.path.join('server', 'usercache.json')
|
||||
STATS_DIR = os.path.join('server', 'world', 'stats')
|
||||
DATA_DIR = os.path.join('server', 'world', 'scripts')
|
||||
CENSUS_DIR = os.path.join('server', 'world', 'scripts', 'shared', 'census')
|
||||
|
||||
# 引号内字符匹配错误
|
||||
# text in the quote is not matched
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 加载玩家名列表
|
||||
with open(USERCACHE_PATH, 'r') as cache_file:
|
||||
uuid_cache = json.load(cache_file) # type: list
|
||||
uuid_list = {}
|
||||
# 如果玩家名称不是bot就存进列表里
|
||||
for name in uuid_cache:
|
||||
if name['name'][:3].lower() == 'bot':
|
||||
continue
|
||||
uuid_list[name['name']] = name['uuid']
|
||||
# 检测是否存在census的文件夹
|
||||
if 'shared' not in os.listdir(DATA_DIR):
|
||||
os.mkdir(DATA_DIR + '/shared')
|
||||
if 'census' not in os.listdir(DATA_DIR + '/shared'):
|
||||
os.mkdir(CENSUS_DIR)
|
||||
for uuid in uuid_list:
|
||||
# 加载玩家的统计数据
|
||||
with open(os.path.join(STATS_DIR, uuid_list[uuid] + '.json'), 'r') as stats_file:
|
||||
stats = json.load(stats_file) # type: dict
|
||||
# 计算玩家的分数
|
||||
player_score = {}
|
||||
for score_type in stats['stats']: # 类型,比如 mined
|
||||
player_score[score_type[10:]] = {} # 创建字典套娃
|
||||
count = 0
|
||||
for score in stats['stats'][score_type]: # 类型中的每一种"东西"
|
||||
count += stats['stats'][score_type][score] # 统计每种东西的数量
|
||||
player_score[score_type[10:]][score[10:]] = stats['stats'][score_type][score]
|
||||
player_score[score_type[10:]]['total'] = count
|
||||
# pprint(player_score)
|
||||
file_name = f'{CENSUS_DIR}/{uuid}.json'
|
||||
with open(file_name, 'w') as census_file:
|
||||
json.dump(player_score, census_file)
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user