fix scripts/fzsd_score.sc. (重写)
Signed-off-by: 延皓 <harvey_husky@foxmail.com>
This commit is contained in:
parent
d81d0a530a
commit
96f2320257
@ -43,6 +43,24 @@ global_current_scoreboard_list = [
|
||||
'fzsd.module.scoreboard.display.aviating_distance',
|
||||
'fzsd.module.scoreboard.display.placement_count'
|
||||
];
|
||||
global_generals_old = {
|
||||
'fzsd.module.scoreboard.display.damage_taken' -> '总受伤害量',
|
||||
'fzsd.module.scoreboard.display.dig_count' -> '总挖掘量',
|
||||
'fzsd.module.scoreboard.display.placement_count' -> '总放置方块数',
|
||||
'fzsd.module.scoreboard.display.trade_count' -> '总交易量'
|
||||
};
|
||||
global_current_generals = {
|
||||
'fzsd.module.scoreboard.display.activation' -> '总活跃时间',
|
||||
'fzsd.module.scoreboard.display.damage_taken' -> '总受伤害数',
|
||||
'fzsd.module.scoreboard.display.death_count' -> '总死亡数',
|
||||
'fzsd.module.scoreboard.display.dig_count' -> '总挖掘数',
|
||||
'fzsd.module.scoreboard.display.fishing_count' -> '总钓鱼数',
|
||||
'fzsd.module.scoreboard.display.kill_count' -> '总击杀数',
|
||||
'fzsd.module.scoreboard.display.trade_count' -> '总交易数',
|
||||
'fzsd.module.scoreboard.display.bedrock_broken_count' -> '总破基岩数',
|
||||
'fzsd.module.scoreboard.display.aviating_distance' -> '总飞行距离',
|
||||
'fzsd.module.scoreboard.display.placement_count' -> '总建造数'
|
||||
};
|
||||
|
||||
__config() -> {
|
||||
'scope' -> 'global',
|
||||
@ -54,26 +72,18 @@ __config() -> {
|
||||
'commands' -> {
|
||||
// '' -> 'help',
|
||||
// 'help' -> 'help',
|
||||
'delete <version>' -> 'command_delete',
|
||||
'update <version>' -> 'command_update',
|
||||
'restore whitelist' -> ['command_restore', null, null],
|
||||
'restore whitelist <scoreboardID>' -> _(scoreboardID) -> command_restore(null, scoreboardID),
|
||||
'restore player <playerName>' -> ['command_restore', null],
|
||||
'restore player <playerName> <scoreboardID>' -> 'command_restore',
|
||||
'restore <custom> whitelist <trade_count>' -> _(custom, trade_count) -> command_restore_trade_count_confirm(custom, null, trade_count),
|
||||
'restore <custom> player <playerName> <trade_count>' -> 'command_restore_trade_count_confirm',
|
||||
'recalculate <scoreboardID>' -> 'command_recalculate_total_score',
|
||||
'recalculate' -> ['command_recalculate_total_score', null],
|
||||
'commandPlayer <permissionType>' -> 'carpet_command_player',
|
||||
'restore whitelist' -> ['command_restore_whitelist', null],
|
||||
'restore whitelist <scoreboardID>' -> 'command_restore_whitelist',
|
||||
'restore player <playerName>' -> ['command_restore_player', null],
|
||||
'restore player <playerName> <scoreboardID>' -> 'command_restore_player',
|
||||
'recalculate <scoreboardID>' -> 'command_recalculate',
|
||||
'recalculate' -> ['command_recalculate', null],
|
||||
'commandPlayer <permissionType>' -> 'command_carpet_command_player',
|
||||
'reset <scoreboardPlayer> <scoreboardID>' -> 'command_reset',
|
||||
'reset <scoreboardPlayer>' -> ['command_reset', null],
|
||||
'set <playerName> <scoreboardID> <score>' -> 'command_set'
|
||||
},
|
||||
'arguments' -> {
|
||||
'trade_count' -> {
|
||||
'type' -> 'term',
|
||||
'suggest' -> ['fzsd.module.scoreboard.display.trade_count']
|
||||
},
|
||||
'playerName' -> {
|
||||
'type' -> 'term',
|
||||
'suggester' -> _(args) -> player('all')
|
||||
@ -94,22 +104,9 @@ __config() -> {
|
||||
'ops'
|
||||
]
|
||||
},
|
||||
'version' -> {
|
||||
'type' -> 'term',
|
||||
'suggest' -> [
|
||||
'2.x',
|
||||
'3.0-beta.4',
|
||||
'3.0-beta.9',
|
||||
'3.0-beta.10'
|
||||
]
|
||||
},
|
||||
'score' -> {
|
||||
'type' -> 'int',
|
||||
'suggest' -> []
|
||||
},
|
||||
'custom' -> {
|
||||
'type' -> 'term',
|
||||
'suggest' -> []
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -128,7 +125,7 @@ __on_close() -> (
|
||||
write_file('team_cache', 'json', global_team_cache);
|
||||
);
|
||||
|
||||
if(require_version('1.4.999'), // 待支持
|
||||
if(require_version('1.4.999'), // 暂时无效
|
||||
__on_player_command(player, command) -> (
|
||||
l = length(command);
|
||||
if(l > 13
|
||||
@ -199,7 +196,7 @@ reload_configs() -> (
|
||||
global_config:'config_version' = '1.0.0'; // 占位用,无实际作用
|
||||
config_changed = true;
|
||||
);
|
||||
// 待支持
|
||||
// 暂时无效
|
||||
if(require_version('1.4.999') && !contains(global_config, 'allow_spawn_whitelist_player'),
|
||||
global_config:'allow_spawn_whitelist_player' = false;
|
||||
config_changed = true;
|
||||
@ -223,297 +220,146 @@ get_scoreboard_player_list() -> (
|
||||
return(keys(set));
|
||||
);
|
||||
|
||||
// 重置玩家计分板分数
|
||||
command_reset(player, scoreboard) -> (
|
||||
if(scoreboard == null,
|
||||
for(scoreboard(),
|
||||
scoreboard_remove(_, player);
|
||||
);
|
||||
command_recalculate_total_score(null);
|
||||
print('已重置' + player + '的所有分数');
|
||||
return();
|
||||
);
|
||||
scoreboard_remove(scoreboard, player);
|
||||
command_recalculate_total_score(scoreboard);
|
||||
print('已重置' + player + '的' + scoreboard + '分数');
|
||||
return();
|
||||
);
|
||||
|
||||
// 尝试从缓存恢复玩家队伍,玩家/假人上下线时执行
|
||||
try_restore_team_from_cache(player) -> (
|
||||
player_team = player ~ 'team';
|
||||
player_name = player ~ 'name';
|
||||
debug('restore_team_from_cache');
|
||||
if(player_team == 'fzsd.module.scoreboard.fake'
|
||||
|| player_team == 'fzsd.module.scoreboard.shadow',
|
||||
if(global_team_cache:player_name == null,
|
||||
(
|
||||
team_leave(player);
|
||||
),
|
||||
team_add(global_team_cache:player_name , player);
|
||||
delete(global_team_cache:player_name);
|
||||
);
|
||||
if(player_team != 'fzsd.module.scoreboard.fake'
|
||||
&& player_team != 'fzsd.module.scoreboard.shadow',
|
||||
return();
|
||||
);
|
||||
if(global_team_cache:player_name == null,
|
||||
team_leave(player);
|
||||
,
|
||||
team_add(global_team_cache:player_name , player);
|
||||
delete(global_team_cache:player_name);
|
||||
);
|
||||
);
|
||||
|
||||
help() -> (
|
||||
print('暂未开发');
|
||||
return();
|
||||
);
|
||||
|
||||
// 删除旧版的计分板
|
||||
command_delete(fzsd_version) -> (
|
||||
if(fzsd_version == '3.0-beta.10',
|
||||
(
|
||||
scoreboard_remove('fzsd.module.scoreboard.display.bedrock_broke_count');
|
||||
),
|
||||
fzsd_version == '3.0-beta.9',
|
||||
(
|
||||
scoreboard_remove('fzsd.extra.bbl.display');
|
||||
),
|
||||
fzsd_version == '2.x',
|
||||
(
|
||||
old_scoreboards = ['usedDiaAxe', 'usedDiaPickaxe', 'usedDiaShovel', 'usedDiaHoe', 'usedIroAxe','usedIroPickaxe', 'usedIroShovel', 'usedIroHoe', 'usedStoAxe', 'usedStoPickaxe', 'usedStoShovel', 'usedStoHoe', 'usedWooAxe', 'usedWooPickaxe', 'usedWooShovel', 'usedWooHoe', 'usedGolAxe', 'usedGolPickaxe', 'usedGolShovel', 'usedGolHoe', 'usedNetAxe', 'usedNetPickaxe', 'usedNetShovel', 'usedNetHoe', 'usedShears', 'damageTaken', '10xDamageTaken', 'deathCounter', 'deathTester', 'digCounter', 'fishingCounter', 'fishingTester', 'killCounter', 'tradingCounter', 'totalList', 'bedrockBreaked', 'fz.bbl', 'fz.aviate1m', 'fz.aviateCounter', 'fz.aviateOneTime', 'Health', 'carpetBot', 'parameter'];
|
||||
team_remove('carpetBot');
|
||||
team_remove('shadowedPlayer');
|
||||
for(old_scoreboards, scoreboard_remove(_));
|
||||
),
|
||||
fzsd_version == '3.0-beta.4',
|
||||
(
|
||||
old_scoreboards = ['fz.module.scoreboard.display.activation', 'fz.module.scoreboard.display.damage_taken', 'fz.module.scoreboard.display.death_count', 'fz.module.scoreboard.display.dig_count', 'fz.module.scoreboard.display.fishing_count', 'fz.module.scoreboard.display.kill_count', 'fz.module.scoreboard.display.trade_count', 'fz.module.scoreboard.display.bedrock_broke_count', 'fz.module.scoreboard.display.aviating_distance', 'fz.module.scoreboard.display.placement_count', 'fz.module.scoreboard.assign.general', 'fz.module.scoreboard.display.general', 'fz.module.scoreboard.interactor'];
|
||||
team_remove('fz.module.scoreboard.fake');
|
||||
team_remove('fz.module.scoreboard.shadow');
|
||||
for(old_scoreboards, scoreboard_remove(_));
|
||||
),
|
||||
print('参数错误!');
|
||||
// 重置玩家计分板分数
|
||||
command_reset(player, scoreboard_id) -> (
|
||||
if(scoreboard_id == null,
|
||||
run('scoreboard players reset ' + player);
|
||||
print('已重置' + player + '的所有分数');
|
||||
return();
|
||||
);
|
||||
print('已清除旧版计分板!');
|
||||
return();
|
||||
);
|
||||
|
||||
// 从某一旧版升级
|
||||
command_update(fzsd_version) -> (
|
||||
if(fzsd_version == '3.0-beta.10',
|
||||
(
|
||||
merge_score('fzsd.module.scoreboard.display.bedrock_broke_count', 'fzsd.module.scoreboard.display.bedrock_broken_count', fzsd_version);
|
||||
command_delete(fzsd_version);
|
||||
scoreboard_remove('fzsd.module.scoreboard.display.placement_count', '总放置方块数');
|
||||
scoreboard_remove('fzsd.module.scoreboard.display.general', '总放置方块数');
|
||||
),
|
||||
fzsd_version == '3.0-beta.9',
|
||||
(
|
||||
merge_score('fzsd.extra.bbl.display', 'fzsd.module.scoreboard.display.bedrock_broken_count', fzsd_version);
|
||||
command_delete(fzsd_version);
|
||||
),
|
||||
fzsd_version == '2.x',
|
||||
(
|
||||
params = [
|
||||
['activation', 'fzsd.module.scoreboard.display.activation'],
|
||||
['damageTaken', 'fzsd.module.scoreboard.display.damage_taken'],
|
||||
['deathCounter', 'fzsd.module.scoreboard.display.death_count'],
|
||||
['digCounter', 'fzsd.module.scoreboard.display.dig_count'],
|
||||
['fishingCounter', 'fzsd.module.scoreboard.display.fishing_count'],
|
||||
['killCounter', 'fzsd.module.scoreboard.display.kill_count'],
|
||||
['tradingCounter', 'fzsd.module.scoreboard.display.trade_count'],
|
||||
['bedrockBreaked', 'fzsd.module.scoreboard.display.bedrock_broken_count'],
|
||||
['fz.aviate1m', 'fzsd.module.scoreboard.display.aviating_distance']
|
||||
];
|
||||
for(params, merge_score(..._, fzsd_version));
|
||||
command_delete(fzsd_version);
|
||||
),
|
||||
fzsd_version == '3.0-beta.4',
|
||||
(
|
||||
params = [
|
||||
['fz.module.scoreboard.display.activation', 'fzsd.module.scoreboard.display.activation'],
|
||||
['fz.module.scoreboard.display.damage_taken', 'fzsd.module.scoreboard.display.damage_taken'],
|
||||
['fz.module.scoreboard.display.death_count', 'fzsd.module.scoreboard.display.death_count'],
|
||||
['fz.module.scoreboard.display.dig_count', 'fzsd.module.scoreboard.display.dig_count'],
|
||||
['fz.module.scoreboard.display.fishing_count', 'fzsd.module.scoreboard.display.fishing_count'],
|
||||
['fz.module.scoreboard.display.kill_count', 'fzsd.module.scoreboard.display.kill_count'],
|
||||
['fz.module.scoreboard.display.trade_count', 'fzsd.module.scoreboard.display.trade_count'],
|
||||
['fz.module.scoreboard.display.bedrock_broke_count', 'fzsd.module.scoreboard.display.bedrock_broken_count'],
|
||||
['fz.module.scoreboard.display.aviating_distance', 'fzsd.module.scoreboard.display.aviating_distance'],
|
||||
['fz.module.scoreboard.display.placement_count', 'fzsd.module.scoreboard.display.placement_count']
|
||||
];
|
||||
for(params, merge_score(..._, fzsd_version));
|
||||
command_delete(fzsd_version);
|
||||
),
|
||||
print('参数错误!');
|
||||
return();
|
||||
);
|
||||
command_recalculate_total_score(null);
|
||||
print('已从' + fzsd_version + '升级!');
|
||||
return();
|
||||
);
|
||||
|
||||
// 将两计分板分数合并到后者
|
||||
merge_score(from, to, fzsd_version) -> (
|
||||
// 如果目标计分板不存在则创建
|
||||
if(scoreboard() ~ to == null, scoreboard_add(to));
|
||||
|
||||
// new_players = [];
|
||||
|
||||
if(fzsd_version == '2.x',
|
||||
(
|
||||
// 2.x数据包的假人列表
|
||||
fake_players = team_list('carpetBot');
|
||||
|
||||
// 新数据包的计分板中存储的玩家列表
|
||||
new_players = scoreboard('fzsd.module.interactor.trigger');
|
||||
|
||||
for(fake_players, delete(new_players, _));
|
||||
),
|
||||
fzsd_version == '3.0-beta.4',
|
||||
(
|
||||
new_players = scoreboard('fz.module.interactor.trigger');
|
||||
)
|
||||
);
|
||||
|
||||
for(scoreboard(from),
|
||||
if(!(_ ~ '\\W'),
|
||||
scoreboard(to, _, scoreboard(to, _) + scoreboard(from, _));
|
||||
);
|
||||
);
|
||||
|
||||
print('已合并:' + to);
|
||||
return();
|
||||
);
|
||||
|
||||
// 获取承载总览数据的玩家名
|
||||
// 因为新计分板允许玩家自定义显示的总览名称,故做复杂判断才能使脚本确定用来承载总览数据的玩家名
|
||||
get_total_score_name_new(scoreboard) -> (
|
||||
// 系统总览id
|
||||
sys_total_name = replace(scoreboard, 'display', 'total');
|
||||
|
||||
// 当前总分
|
||||
current_score = scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name);
|
||||
|
||||
// 将系统总览分数设为INT_MIN,使其成为最低分
|
||||
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, -2147483648);
|
||||
|
||||
// 将总分赋值到显示计分板上
|
||||
display_total_score(scoreboard);
|
||||
|
||||
// 查找显示计分板内的最低分玩家名
|
||||
last_min_player = null;
|
||||
for(scoreboard(scoreboard),
|
||||
if(last_min_player == null,
|
||||
(
|
||||
last_min_player = _;
|
||||
),
|
||||
if(scoreboard(scoreboard, _) < scoreboard(scoreboard, last_min_player),
|
||||
last_min_player = _;
|
||||
)
|
||||
);
|
||||
);
|
||||
|
||||
// 恢复总览分数
|
||||
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, current_score);
|
||||
display_total_score(scoreboard);
|
||||
|
||||
// 返回榜内最低分的玩家名(承载总览数据的玩家名)
|
||||
return(last_min_player);
|
||||
scoreboard_remove(scoreboard_id, player);
|
||||
print('已重置' + player + '的' + scoreboard_id + '分数');
|
||||
);
|
||||
|
||||
// 重算总分,scoreboard == null 时重算所有总分
|
||||
command_recalculate_total_score(scoreboard) -> (
|
||||
if(scoreboard == null,
|
||||
for(global_current_scoreboard_list, command_recalculate_total_score(_));
|
||||
return();
|
||||
);
|
||||
total_score_name_new = get_total_score_name_new(scoreboard);
|
||||
// 计算总分
|
||||
command_recalculate(scoreboard_id) -> (
|
||||
recalculate_general(scoreboard_id);
|
||||
);
|
||||
|
||||
// 设置玩家的计分板分数
|
||||
command_set(player, scoreboard_id, score) -> (
|
||||
i = scoreboard(scoreboard_id, player, score);
|
||||
print('玩家' + player + '修改前的分数为:' + i);
|
||||
recalculate_general(scoreboard_id);
|
||||
return(i);
|
||||
);
|
||||
|
||||
command_carpet_command_player(level) -> (
|
||||
print(run('carpet setDefault commandPlayer ' + level):1:0);
|
||||
);
|
||||
|
||||
command_restore_whitelist(scoreboard_id) -> (
|
||||
restore_scores_of_whitelist_players(scoreboard_id);
|
||||
);
|
||||
|
||||
command_restore_player(player_name, scoreboard_id) -> (
|
||||
restore_score(player_name, scoreboard_id);
|
||||
);
|
||||
|
||||
// impls...
|
||||
|
||||
recalculate_general(scoreboard_id) -> (
|
||||
if(scoreboard_id == null,
|
||||
(
|
||||
for(global_current_scoreboard_list, _recalculate_general(_));
|
||||
),( // else
|
||||
_recalculate_general(scoreboard_id);
|
||||
));
|
||||
display_generals();
|
||||
);
|
||||
|
||||
_recalculate_general(scoreboard_id) -> (
|
||||
require_not_null(scoreboard_id);
|
||||
scoreboard_remove(scoreboard_id, global_generals_old:scoreboard_id); // shit compat...
|
||||
scoreboard_remove(scoreboard_id, global_current_generals:scoreboard_id); // shit compat...
|
||||
total_score = 0;
|
||||
for(scoreboard(scoreboard),
|
||||
if(_ != total_score_name_new,
|
||||
current_player_score = scoreboard(scoreboard, _);
|
||||
if(current_player_score < -1000000000, // 避免溢出
|
||||
current_player_score = 2147483647;
|
||||
scoreboard(scoreboard, _, 2147483647);
|
||||
);
|
||||
total_score += current_player_score;
|
||||
);
|
||||
if(total_score < 0, // 避免溢出
|
||||
total_score = 2147483647;
|
||||
);
|
||||
);
|
||||
// 赋值总分到系统总分计分板
|
||||
scoreboard(
|
||||
'fzsd.module.scoreboard.assign.general',
|
||||
replace(scoreboard, 'display', 'total'),
|
||||
total_score
|
||||
);
|
||||
display_total_score(scoreboard);
|
||||
return();
|
||||
for(scoreboard(scoreboard_id),
|
||||
( // _ = player_name
|
||||
score = scoreboard(scoreboard_id, _);
|
||||
if(score <= 0,(
|
||||
scoreboard_remove(scoreboard_id, _);
|
||||
continue();
|
||||
));
|
||||
total_score += scoreboard(scoreboard_id, _);
|
||||
if(total_score < 0,(
|
||||
total_score = 2147483647; // INT_MAX
|
||||
break();
|
||||
));
|
||||
));
|
||||
scoreboard('fzsd.module.scoreboard.assign.general', replace(scoreboard_id, 'display', 'total'), total_score); // shit... must call display_generals() later.
|
||||
return(total_score);
|
||||
);
|
||||
|
||||
// 使用数据包函数标签将总分赋值到显示计分板上
|
||||
display_total_score(scoreboard) -> (
|
||||
// 获取计算总览的函数标签名
|
||||
str_1 = split('\\.', scoreboard);
|
||||
function_name = str_1:(length(str_1) - 1);
|
||||
display_generals() -> (
|
||||
// 运行函数,将分数赋值到显示计分板上
|
||||
run('function #fzsd:module/scoreboard/assign/scoreboard/general/' + function_name);
|
||||
return();
|
||||
run('function #fzsd:module/scoreboard/assign/scoreboard/general');
|
||||
);
|
||||
|
||||
// 恢复计分板分数,player == null 时恢复所有玩家分数,scoreboard == null 时恢复所有计分板分数
|
||||
command_restore(player, scoreboard) -> (
|
||||
if(player == null,
|
||||
i = 0;
|
||||
for(keys(system_info('server_whitelist')),
|
||||
i += 1;
|
||||
if(i > 10,
|
||||
game_tick(50);
|
||||
i = 0;
|
||||
);
|
||||
restore_score(_, scoreboard);
|
||||
);
|
||||
if(scoreboard == null,
|
||||
(
|
||||
print('重置交易榜会丢失猪灵交易分数,请输入\n“/' + global_app_name + ' restore confirm whitelist fzsd.module.scoreboard.display.trade_count”继续执行');
|
||||
print('无法还原破基岩榜,已忽略');
|
||||
print('已恢复所有玩家的所有分数');
|
||||
),
|
||||
if(scoreboard == 'fzsd.module.scoreboard.display.trade_count',
|
||||
print('重置交易榜会丢失猪灵交易分数,请输入\n“/' + global_app_name + ' restore confirm whitelist fzsd.module.scoreboard.display.trade_count”继续执行');
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.bedrock_broken_count',
|
||||
print('无法还原破基岩榜,已忽略');
|
||||
,
|
||||
print('已恢复所有玩家的' + scoreboard + '分数');
|
||||
);
|
||||
);
|
||||
restore_scores_of_whitelist_players(scoreboard_id) -> ( // whitelist players only!
|
||||
whitelist = get_server_whitelist();
|
||||
|
||||
if(scoreboard_id != null,
|
||||
(
|
||||
for(whitelist,
|
||||
( // _ = player_name
|
||||
_restore_score(_, scoreboard_id);
|
||||
));
|
||||
recalculate_general(scoreboard_id);
|
||||
return();
|
||||
);
|
||||
if(scoreboard == null,
|
||||
for(global_current_scoreboard_list, restore_score(player, _));
|
||||
print('重置交易榜会丢失猪灵交易分数,请输入\n“/' + global_app_name + ' restore confirm player <playerName> fzsd.module.scoreboard.display.trade_count”继续执行');
|
||||
print('无法还原破基岩榜,已忽略');
|
||||
print('已恢复' + player + '的所有分数');
|
||||
return();
|
||||
);
|
||||
if(restore_score(player, scoreboard),
|
||||
print('已恢复' + player + '的' + scoreboard + '分数');
|
||||
,
|
||||
if(scoreboard == 'fzsd.module.scoreboard.display.trade_count',
|
||||
print('重置交易榜会丢失猪灵交易分数,请输入\n“/' + global_app_name + ' restore confirm whitelist fzsd.module.scoreboard.display.trade_count”继续执行');
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.bedrock_broken_count',
|
||||
print('无法还原破基岩榜,已忽略');
|
||||
);
|
||||
);
|
||||
return();
|
||||
));
|
||||
|
||||
for(global_current_scoreboard_list,
|
||||
(
|
||||
scoreboard_id = _;
|
||||
for(whitelist,
|
||||
( // _ = player_name
|
||||
_restore_score(_, scoreboard_id);
|
||||
));
|
||||
));
|
||||
recalculate_general(null);
|
||||
);
|
||||
|
||||
// 恢复玩家的计分板分数
|
||||
restore_score(player_name, scoreboard) -> (
|
||||
restore_score(player_name, scoreboard_id) -> (
|
||||
require_not_null(player_name);
|
||||
if(scoreboard == null,
|
||||
for(global_current_scoreboard_list, restore_score(player_name, _));
|
||||
if(scoreboard_id == null || scoreboard_id == '',
|
||||
(
|
||||
for(global_current_scoreboard_list, _restore_score(player_name, _));
|
||||
recalculate_general(null);
|
||||
return(true);
|
||||
);
|
||||
));
|
||||
if(_restore_score(player_name, scoreboard_id),
|
||||
(
|
||||
recalculate_general(scoreboard_id);
|
||||
return(true);
|
||||
));
|
||||
return(false);
|
||||
);
|
||||
|
||||
_restore_score(player_name, scoreboard_id) -> (
|
||||
require_not_null(scoreboard_id);
|
||||
player = player(player_name);
|
||||
player_is_offline = false;
|
||||
if(player == null,
|
||||
@ -523,55 +369,49 @@ restore_score(player_name, scoreboard) -> (
|
||||
player = player(player_name);
|
||||
)
|
||||
);
|
||||
if(scoreboard == 'fzsd.module.scoreboard.display.activation',
|
||||
if(scoreboard_id == 'fzsd.module.scoreboard.display.activation',
|
||||
(
|
||||
play_ticks = statistic(player, 'custom', 'play_time');
|
||||
scoreboard('fzsd.event.play_ticks', player, play_ticks%72000);
|
||||
scoreboard(scoreboard, player, play_ticks/72000);
|
||||
scoreboard(scoreboard_id, player, play_ticks/72000);
|
||||
),
|
||||
scoreboard == 'fzsd.module.scoreboard.display.damage_taken',
|
||||
scoreboard(scoreboard, player, statistic(player, 'custom', 'damage_taken')/10);
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.damage_taken',
|
||||
scoreboard(scoreboard_id, player, statistic(player, 'custom', 'damage_taken')/10);
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.death_count',
|
||||
restore_from_stat(scoreboard, player, 'custom', 'deaths');
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.death_count',
|
||||
scoreboard(scoreboard_id, player, statistic(player, 'custom', 'deaths'));
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.dig_count',
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.dig_count',
|
||||
(
|
||||
scoreboard(scoreboard, player, 0);
|
||||
for(block_list(),
|
||||
append_from_stat(scoreboard, player, 'mined', _);
|
||||
);
|
||||
scoreboard(scoreboard_id, player, 0);
|
||||
for(block_list(), append_from_stat(scoreboard_id, player, 'mined', _));
|
||||
),
|
||||
scoreboard == 'fzsd.module.scoreboard.display.fishing_count',
|
||||
scoreboard(scoreboard, player, statistic(player, 'custom', 'fish_caught'));
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.fishing_count',
|
||||
scoreboard(scoreboard_id, player, statistic(player, 'custom', 'fish_caught'));
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.kill_count',
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.kill_count',
|
||||
(
|
||||
scoreboard(scoreboard, player, 0);
|
||||
for(entity_types('living'),
|
||||
append_from_stat(scoreboard, player, 'killed', _);
|
||||
);
|
||||
scoreboard(scoreboard_id, player, 0);
|
||||
for(entity_types('living'), append_from_stat(scoreboard_id, player, 'killed', _));
|
||||
),
|
||||
scoreboard == 'fzsd.module.scoreboard.display.trade_count',
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.trade_count',
|
||||
scoreboard(scoreboard_id, player, statistic(player, 'custom', 'traded_with_villager'));
|
||||
return(false);
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.bedrock_broken_count',
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.bedrock_broken_count',
|
||||
return(false);
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.aviating_distance',
|
||||
scoreboard(scoreboard, player, statistic(player, 'custom', 'aviate_one_cm')/200);
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.aviating_distance',
|
||||
scoreboard(scoreboard_id, player, statistic(player, 'custom', 'aviate_one_cm')/200);
|
||||
,
|
||||
scoreboard == 'fzsd.module.scoreboard.display.placement_count',
|
||||
scoreboard_id == 'fzsd.module.scoreboard.display.placement_count',
|
||||
(
|
||||
scoreboard(scoreboard, player, 0);
|
||||
for(block_list(),
|
||||
append_from_stat(scoreboard, player, 'used', _);
|
||||
);
|
||||
scoreboard(scoreboard_id, player, 0);
|
||||
for(block_list(), append_from_stat(scoreboard_id, player, 'used', _));
|
||||
),
|
||||
print('未识别的计分板ID!' + scoreboard);
|
||||
print('未识别的计分板ID!' + scoreboard_id);
|
||||
return(false);
|
||||
);
|
||||
command_recalculate_total_score(scoreboard);
|
||||
if(player_is_offline,
|
||||
world_spawn = system_info('world_spawn_point');
|
||||
run('spreadplayers ' + world_spawn:0 + ' ' + world_spawn:2 + ' 0 10 false ' + player);
|
||||
@ -580,42 +420,9 @@ restore_score(player_name, scoreboard) -> (
|
||||
return(true);
|
||||
);
|
||||
|
||||
// 确定恢复交易榜
|
||||
command_restore_trade_count_confirm(confirm, player, trade_count) -> (
|
||||
if(confirm != 'confirm' || trade_count != 'fzsd.module.scoreboard.display.trade_count',
|
||||
print('命令格式错误!');
|
||||
return();
|
||||
);
|
||||
if(player == null,
|
||||
for(keys(system_info('server_whitelist')),
|
||||
restore_from_stat(scoreboard, _, 'custom', 'traded_with_villager');
|
||||
);
|
||||
return();
|
||||
);
|
||||
restore_from_stat(scoreboard, player, 'custom', 'traded_with_villager');
|
||||
return();
|
||||
);
|
||||
|
||||
restore_from_stat(scoreboard, player, category, entry) -> (
|
||||
scoreboard(scoreboard, player, statistic(player, category, entry));
|
||||
);
|
||||
|
||||
append_from_stat(scoreboard, player, category, entry) -> (
|
||||
scoreboard(scoreboard, player,
|
||||
statistic(player, category, entry) + scoreboard(scoreboard, player)
|
||||
);
|
||||
);
|
||||
|
||||
// 修改地毯假人规则
|
||||
carpet_command_player(level) -> (
|
||||
print(run('carpet setDefault commandPlayer ' + level):1:0);
|
||||
return();
|
||||
);
|
||||
|
||||
// 设置玩家的计分板分数
|
||||
command_set(player, scoreboard, score) -> (
|
||||
i = scoreboard(scoreboard, player, score);
|
||||
print('玩家' + player + '修改前的分数为:' + i);
|
||||
command_recalculate_total_score(scoreboard);
|
||||
return(i);
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user