2022-07-26 07:57:04 +08:00
|
|
|
|
// 计分板模块扩展插件
|
|
|
|
|
// 忽略假人分数
|
|
|
|
|
// **请勿修改文件名!!**
|
2022-12-28 07:28:06 +08:00
|
|
|
|
|
|
|
|
|
//** 工具函数 **//
|
|
|
|
|
|
|
|
|
|
contains(list, value) -> (
|
|
|
|
|
return(list ~ value != null);
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
debug(msg) -> (
|
|
|
|
|
logger('debug', msg);
|
|
|
|
|
return();
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
require_not_null(value) -> (
|
|
|
|
|
if(value == null, throw('空指针异常!'));
|
|
|
|
|
return(value);
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
require_version(requirement) -> (
|
2023-06-08 17:44:31 +08:00
|
|
|
|
req_ver = split('\\.', requirement);
|
|
|
|
|
cur_ver = split('\\.', global_carpet_version);
|
|
|
|
|
return(number(cur_ver:0) >= number(req_ver:0)
|
|
|
|
|
&& number(cur_ver:1) >= number(req_ver:1)
|
|
|
|
|
&& number(cur_ver:2) >= number(req_ver:2));
|
2022-12-28 07:28:06 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//** 主要逻辑 **//
|
|
|
|
|
|
|
|
|
|
global_app_name = system_info('app_name');
|
|
|
|
|
global_app_version = '1.1-beta.1';
|
|
|
|
|
global_carpet_version = split('\\+', system_info('scarpet_version')):0;
|
2022-09-12 21:53:54 +08:00
|
|
|
|
global_current_scoreboard_list = [
|
|
|
|
|
'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'
|
|
|
|
|
];
|
2022-07-26 07:57:04 +08:00
|
|
|
|
|
|
|
|
|
__config() -> {
|
|
|
|
|
'scope' -> 'global',
|
|
|
|
|
'requires' -> {
|
|
|
|
|
'carpet' -> '>=1.4.45',
|
2022-12-28 07:28:06 +08:00
|
|
|
|
'minecraft' -> '>=1.18'
|
2022-07-26 07:57:04 +08:00
|
|
|
|
},
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'command_permission' -> 2,
|
2022-07-26 07:57:04 +08:00
|
|
|
|
'commands' -> {
|
|
|
|
|
'' -> 'help',
|
|
|
|
|
'help' -> 'help',
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'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',
|
2022-12-28 07:28:06 +08:00
|
|
|
|
'recalculate <scoreboardID>' -> 'command_recalculate_total_score',
|
|
|
|
|
'recalculate' -> ['command_recalculate_total_score', null],
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'commandPlayer <permissionType>' -> 'carpet_command_player',
|
|
|
|
|
'reset <scoreboardPlayer> <scoreboardID>' -> 'command_reset',
|
|
|
|
|
'reset <scoreboardPlayer>' -> ['command_reset', null],
|
|
|
|
|
'set <playerName> <scoreboardID> <score>' -> 'command_set'
|
2022-08-02 00:36:38 +08:00
|
|
|
|
},
|
|
|
|
|
'arguments' -> {
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'trade_count' -> {
|
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggest' -> ['fzsd.module.scoreboard.display.trade_count']
|
|
|
|
|
},
|
|
|
|
|
'playerName' -> {
|
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggester' -> _(args) -> player('all')
|
|
|
|
|
},
|
2022-09-12 21:53:54 +08:00
|
|
|
|
'scoreboardID' -> {
|
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggest' -> global_current_scoreboard_list
|
|
|
|
|
},
|
|
|
|
|
'scoreboardPlayer' -> {
|
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggester' -> _(args) -> get_scoreboard_player_list()
|
|
|
|
|
},
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'permissionType' -> {
|
2022-09-02 06:03:24 +08:00
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggest' -> [
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'true',
|
|
|
|
|
'false',
|
|
|
|
|
'ops'
|
2022-09-02 06:03:24 +08:00
|
|
|
|
]
|
|
|
|
|
},
|
2022-09-21 08:20:01 +08:00
|
|
|
|
'version' -> {
|
2022-08-02 00:36:38 +08:00
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggest' -> [
|
|
|
|
|
'2.x',
|
2022-09-01 03:01:02 +08:00
|
|
|
|
'3.0-beta.4',
|
2022-09-02 07:30:25 +08:00
|
|
|
|
'3.0-beta.9',
|
|
|
|
|
'3.0-beta.10'
|
2022-08-02 00:36:38 +08:00
|
|
|
|
]
|
2022-09-21 08:20:01 +08:00
|
|
|
|
},
|
|
|
|
|
'score' -> {
|
|
|
|
|
'type' -> 'int',
|
|
|
|
|
'suggest' -> []
|
|
|
|
|
},
|
|
|
|
|
'custom' -> {
|
|
|
|
|
'type' -> 'term',
|
|
|
|
|
'suggest' -> []
|
2022-08-02 00:36:38 +08:00
|
|
|
|
}
|
2022-07-26 07:57:04 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
__on_start() -> (
|
2023-06-08 17:44:31 +08:00
|
|
|
|
reload_configs();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
global_team_cache = read_file('team_cache', 'json');
|
2022-08-02 00:36:38 +08:00
|
|
|
|
if(global_team_cache == null, // carpet 1.4.69 兼容
|
|
|
|
|
global_team_cache = {};
|
|
|
|
|
);
|
2022-07-30 16:34:38 +08:00
|
|
|
|
print(player('all'), 'fzsd_score.sc已加载!');
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
__on_close() -> (
|
|
|
|
|
delete_file('team_cache', 'json');
|
|
|
|
|
write_file('team_cache', 'json', global_team_cache);
|
|
|
|
|
);
|
|
|
|
|
|
2023-06-08 17:44:31 +08:00
|
|
|
|
if(require_version('1.4.112'), // 新功能支持
|
|
|
|
|
__on_player_command(player, command) -> (
|
|
|
|
|
l = length(command);
|
|
|
|
|
if(l > 13
|
|
|
|
|
&& slice(command, 0, 6) == 'player'
|
|
|
|
|
&& slice(command, l - 5, l) == 'spawn'
|
|
|
|
|
&& !(global_config:'allow_spawn_whitelist_player')
|
|
|
|
|
&& contains(get_server_whitelist(), slice(command, 7, l - 6)),
|
2022-12-28 07:28:06 +08:00
|
|
|
|
return('cancel');
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
2022-07-26 07:57:04 +08:00
|
|
|
|
__on_player_connects(player) -> (
|
2022-08-02 00:36:38 +08:00
|
|
|
|
player_type = player ~ 'player_type';
|
2022-09-29 22:57:00 +08:00
|
|
|
|
if(player_type == 'fake',
|
2022-07-26 07:57:04 +08:00
|
|
|
|
(
|
2023-06-08 17:44:31 +08:00
|
|
|
|
player_team = player ~ 'team';
|
2022-09-29 22:57:00 +08:00
|
|
|
|
if(player_team != 'fzsd.module.scoreboard.fake',
|
2023-06-08 17:44:31 +08:00
|
|
|
|
player_name = player ~ 'name';
|
2022-09-29 22:57:00 +08:00
|
|
|
|
global_team_cache:player_name = player_team;
|
|
|
|
|
);
|
2022-08-02 00:36:38 +08:00
|
|
|
|
team_add('fzsd.module.scoreboard.fake', player);
|
2022-09-29 22:57:00 +08:00
|
|
|
|
print(player('all'), '↑假的');
|
2022-07-26 07:57:04 +08:00
|
|
|
|
),
|
2022-09-29 22:57:00 +08:00
|
|
|
|
player_type == 'shadow',
|
2022-07-26 07:57:04 +08:00
|
|
|
|
(
|
2023-06-08 17:44:31 +08:00
|
|
|
|
player_team = player ~ 'team';
|
2022-09-29 22:57:00 +08:00
|
|
|
|
if(player_team != 'fzsd.module.scoreboard.shadow',
|
2023-06-08 17:44:31 +08:00
|
|
|
|
player_name = player ~ 'name';
|
2022-09-29 22:57:00 +08:00
|
|
|
|
global_team_cache:player_name = player_team;
|
|
|
|
|
);
|
2022-08-02 00:36:38 +08:00
|
|
|
|
team_add('fzsd.module.scoreboard.shadow', player);
|
2022-09-29 22:57:00 +08:00
|
|
|
|
print(player('all'), '↑挂机');
|
2022-07-26 07:57:04 +08:00
|
|
|
|
),
|
|
|
|
|
try_restore_team_from_cache(player);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
__on_player_disconnects(player, reason) -> (
|
2022-09-29 22:57:00 +08:00
|
|
|
|
player_type = player ~ 'player_type';
|
|
|
|
|
if(player_type == 'fake' && player_team != 'fzsd.module.scoreboard.fake',
|
|
|
|
|
(
|
|
|
|
|
print(player('all'), '↓假的');
|
|
|
|
|
),
|
|
|
|
|
player_type == 'shadow' && player_team != 'fzsd.module.scoreboard.shadow',
|
|
|
|
|
(
|
|
|
|
|
print(player('all'), '↓挂机');
|
|
|
|
|
)
|
|
|
|
|
);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
try_restore_team_from_cache(player);
|
|
|
|
|
);
|
|
|
|
|
|
2023-06-08 17:44:31 +08:00
|
|
|
|
// 获取服务器白名单
|
|
|
|
|
get_server_whitelist() -> (
|
2023-07-24 19:46:24 +08:00
|
|
|
|
return(keys(system_info('server_whitelist')));
|
2023-06-08 17:44:31 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 重载配置文件
|
|
|
|
|
reload_configs() -> (
|
|
|
|
|
// 读取配置文件
|
|
|
|
|
global_config = read_file('config', 'json');
|
|
|
|
|
if(global_config == null, // carpet 1.4.69 兼容
|
|
|
|
|
global_config = {};
|
|
|
|
|
);
|
|
|
|
|
config_changed = false;
|
|
|
|
|
// 读取失败或不存在
|
|
|
|
|
if(length(global_config) == 0,
|
|
|
|
|
global_config:'config_version' = '1.0.0'; // 占位用,无实际作用
|
|
|
|
|
config_changed = true;
|
|
|
|
|
);
|
|
|
|
|
// 新功能支持
|
|
|
|
|
if(require_version('1.4.112') && !contains(global_config, 'allow_spawn_whitelist_player'),
|
|
|
|
|
global_config:'allow_spawn_whitelist_player' = false;
|
|
|
|
|
config_changed = true;
|
|
|
|
|
);
|
|
|
|
|
if(config_changed == true,
|
|
|
|
|
delete_file('config', 'json'); // 避免一些意外的问题
|
|
|
|
|
write_file('config', 'json', global_config);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 获取所有计分板下的所有玩家列表
|
2022-09-12 21:53:54 +08:00
|
|
|
|
get_scoreboard_player_list() -> (
|
|
|
|
|
set = m();
|
|
|
|
|
for(global_current_scoreboard_list,
|
|
|
|
|
for(scoreboard(_),
|
|
|
|
|
if(_ ~ '\\w',
|
|
|
|
|
put(set:_, null);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
return(keys(set));
|
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 重置玩家计分板分数
|
|
|
|
|
command_reset(player, scoreboard) -> (
|
2022-09-12 21:53:54 +08:00
|
|
|
|
if(scoreboard == null,
|
2022-09-21 08:20:01 +08:00
|
|
|
|
for(scoreboard(),
|
|
|
|
|
scoreboard_remove(_, player);
|
|
|
|
|
);
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(null);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
print('已重置' + player + '的所有分数');
|
|
|
|
|
return();
|
2022-09-12 21:53:54 +08:00
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
scoreboard_remove(scoreboard, player);
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(scoreboard);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
print('已重置' + player + '的' + scoreboard + '分数');
|
2022-09-12 21:53:54 +08:00
|
|
|
|
return();
|
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 尝试从缓存恢复玩家队伍,玩家/假人上下线时执行
|
2022-07-26 07:57:04 +08:00
|
|
|
|
try_restore_team_from_cache(player) -> (
|
2022-08-02 00:36:38 +08:00
|
|
|
|
player_team = player ~ 'team';
|
|
|
|
|
player_name = player ~ 'name';
|
2022-07-26 07:57:04 +08:00
|
|
|
|
debug('restore_team_from_cache');
|
2022-08-02 00:36:38 +08:00
|
|
|
|
if(player_team == 'fzsd.module.scoreboard.fake'
|
|
|
|
|
|| player_team == 'fzsd.module.scoreboard.shadow',
|
|
|
|
|
if(global_team_cache:player_name == null,
|
2022-07-26 07:57:04 +08:00
|
|
|
|
(
|
|
|
|
|
team_leave(player);
|
|
|
|
|
),
|
2022-08-02 00:36:38 +08:00
|
|
|
|
team_add(global_team_cache:player_name , player);
|
|
|
|
|
delete(global_team_cache:player_name);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
help() -> (
|
2022-08-02 00:36:38 +08:00
|
|
|
|
print('暂未开发');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 删除旧版的计分板
|
|
|
|
|
command_delete(fzsd_version) -> (
|
2022-09-02 07:30:25 +08:00
|
|
|
|
if(fzsd_version == '3.0-beta.10',
|
2022-09-01 03:01:02 +08:00
|
|
|
|
(
|
2022-09-02 07:30:25 +08:00
|
|
|
|
scoreboard_remove('fzsd.module.scoreboard.display.bedrock_broke_count');
|
|
|
|
|
),
|
|
|
|
|
fzsd_version == '3.0-beta.9',
|
|
|
|
|
(
|
|
|
|
|
scoreboard_remove('fzsd.extra.bbl.display');
|
2022-09-01 03:01:02 +08:00
|
|
|
|
),
|
|
|
|
|
fzsd_version == '2.x',
|
2022-08-02 00:36:38 +08:00
|
|
|
|
(
|
|
|
|
|
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');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
for(old_scoreboards, scoreboard_remove(_));
|
2022-08-02 00:36:38 +08:00
|
|
|
|
),
|
|
|
|
|
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');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
for(old_scoreboards, scoreboard_remove(_));
|
|
|
|
|
),
|
|
|
|
|
print('参数错误!');
|
|
|
|
|
return();
|
2022-08-02 00:36:38 +08:00
|
|
|
|
);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
print('已清除旧版计分板!');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 从某一旧版升级
|
|
|
|
|
command_update(fzsd_version) -> (
|
2022-09-02 06:03:24 +08:00
|
|
|
|
if(fzsd_version == '3.0-beta.10',
|
|
|
|
|
(
|
2022-09-02 07:30:25 +08:00
|
|
|
|
merge_score('fzsd.module.scoreboard.display.bedrock_broke_count', 'fzsd.module.scoreboard.display.bedrock_broken_count', fzsd_version);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
command_delete(fzsd_version);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
scoreboard_remove('fzsd.module.scoreboard.display.placement_count', '总放置方块数');
|
2022-09-02 10:53:30 +08:00
|
|
|
|
scoreboard_remove('fzsd.module.scoreboard.display.general', '总放置方块数');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
),
|
|
|
|
|
fzsd_version == '3.0-beta.9',
|
2022-09-01 03:01:02 +08:00
|
|
|
|
(
|
2022-09-02 07:30:25 +08:00
|
|
|
|
merge_score('fzsd.extra.bbl.display', 'fzsd.module.scoreboard.display.bedrock_broken_count', fzsd_version);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
command_delete(fzsd_version);
|
2022-09-01 03:01:02 +08:00
|
|
|
|
),
|
|
|
|
|
fzsd_version == '2.x',
|
2022-08-02 00:36:38 +08:00
|
|
|
|
(
|
|
|
|
|
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'],
|
2022-09-02 07:30:25 +08:00
|
|
|
|
['bedrockBreaked', 'fzsd.module.scoreboard.display.bedrock_broken_count'],
|
2022-08-02 00:36:38 +08:00
|
|
|
|
['fz.aviate1m', 'fzsd.module.scoreboard.display.aviating_distance']
|
2022-09-02 06:03:24 +08:00
|
|
|
|
];
|
|
|
|
|
for(params, merge_score(..._, fzsd_version));
|
2022-09-21 08:20:01 +08:00
|
|
|
|
command_delete(fzsd_version);
|
2022-08-02 00:36:38 +08:00
|
|
|
|
),
|
|
|
|
|
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'],
|
2022-09-02 07:30:25 +08:00
|
|
|
|
['fz.module.scoreboard.display.bedrock_broke_count', 'fzsd.module.scoreboard.display.bedrock_broken_count'],
|
2022-08-02 00:36:38 +08:00
|
|
|
|
['fz.module.scoreboard.display.aviating_distance', 'fzsd.module.scoreboard.display.aviating_distance'],
|
|
|
|
|
['fz.module.scoreboard.display.placement_count', 'fzsd.module.scoreboard.display.placement_count']
|
2022-09-02 06:03:24 +08:00
|
|
|
|
];
|
|
|
|
|
for(params, merge_score(..._, fzsd_version));
|
2022-09-21 08:20:01 +08:00
|
|
|
|
command_delete(fzsd_version);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
),
|
|
|
|
|
print('参数错误!');
|
|
|
|
|
return();
|
2022-08-02 00:36:38 +08:00
|
|
|
|
);
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(null);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
print('已从' + fzsd_version + '升级!');
|
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 将两计分板分数合并到后者
|
2022-08-02 00:36:38 +08:00
|
|
|
|
merge_score(from, to, fzsd_version) -> (
|
2022-07-26 07:57:04 +08:00
|
|
|
|
// 如果目标计分板不存在则创建
|
|
|
|
|
if(scoreboard() ~ to == null, scoreboard_add(to));
|
|
|
|
|
|
2022-08-02 01:21:45 +08:00
|
|
|
|
// new_players = [];
|
|
|
|
|
|
2022-08-02 00:36:38 +08:00
|
|
|
|
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');
|
|
|
|
|
)
|
|
|
|
|
);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
|
|
|
|
|
for(scoreboard(from),
|
2022-08-02 01:21:45 +08:00
|
|
|
|
if(!(_ ~ '\\W'),
|
2022-07-26 07:57:04 +08:00
|
|
|
|
scoreboard(to, _, scoreboard(to, _) + scoreboard(from, _));
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
2022-08-02 00:36:38 +08:00
|
|
|
|
print('已合并:' + to);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 获取承载总榜数据的玩家名
|
|
|
|
|
// 因为新计分板允许玩家自定义显示的总榜名称,故做复杂判断才能使脚本确定用来承载总榜数据的玩家名
|
2022-07-26 07:57:04 +08:00
|
|
|
|
get_total_score_name_new(scoreboard) -> (
|
2023-07-24 19:46:24 +08:00
|
|
|
|
// 系统总榜id
|
|
|
|
|
sys_total_name = replace(scoreboard, 'display', 'total');
|
2022-07-26 07:57:04 +08:00
|
|
|
|
|
2023-07-24 19:46:24 +08:00
|
|
|
|
// 当前总分
|
|
|
|
|
current_score = scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
|
2023-07-24 19:46:24 +08:00
|
|
|
|
// 将系统总榜分数设为INT_MIN,使其成为最低分
|
|
|
|
|
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, -2147483648);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
|
|
|
|
|
// 将总分赋值到显示计分板上
|
|
|
|
|
display_total_score(scoreboard);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 查找显示计分板内的最低分玩家名
|
2022-07-26 07:57:04 +08:00
|
|
|
|
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 = _;
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 恢复总榜分数
|
2023-07-24 19:46:24 +08:00
|
|
|
|
scoreboard('fzsd.module.scoreboard.assign.general', sys_total_name, current_score);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
display_total_score(scoreboard);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 返回榜内最低分的玩家名(承载总榜数据的玩家名)
|
2022-07-26 07:57:04 +08:00
|
|
|
|
return(last_min_player);
|
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 重算总分,scoreboard == null 时重算所有总分
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(scoreboard) -> (
|
2022-09-21 08:20:01 +08:00
|
|
|
|
if(scoreboard == null,
|
2022-12-28 07:28:06 +08:00
|
|
|
|
for(global_current_scoreboard_list, command_recalculate_total_score(_));
|
2022-09-21 08:20:01 +08:00
|
|
|
|
return();
|
|
|
|
|
);
|
2022-09-12 21:53:54 +08:00
|
|
|
|
total_score_name_new = get_total_score_name_new(scoreboard);
|
2022-07-26 07:57:04 +08:00
|
|
|
|
// 计算总分
|
|
|
|
|
total_score = 0;
|
|
|
|
|
for(scoreboard(scoreboard),
|
|
|
|
|
if(_ != total_score_name_new,
|
2023-07-24 19:46:24 +08:00
|
|
|
|
current_player_score = scoreboard(scoreboard, _);
|
|
|
|
|
if(current_player_score < 0, // 避免溢出
|
|
|
|
|
current_player_score = 2147483647;
|
|
|
|
|
scoreboard(scoreboard, _, 2147483647);
|
|
|
|
|
);
|
|
|
|
|
total_score += current_player_score;
|
|
|
|
|
);
|
|
|
|
|
if(total_score < 0, // 避免溢出
|
|
|
|
|
total_score = 2147483647;
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
// 赋值总分到系统总分计分板
|
|
|
|
|
scoreboard(
|
2022-08-02 00:36:38 +08:00
|
|
|
|
'fzsd.module.scoreboard.assign.general',
|
2022-07-26 07:57:04 +08:00
|
|
|
|
replace(scoreboard, 'display', 'total'),
|
|
|
|
|
total_score
|
|
|
|
|
);
|
|
|
|
|
display_total_score(scoreboard);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 使用数据包函数标签将总分赋值到显示计分板上
|
2022-07-26 07:57:04 +08:00
|
|
|
|
display_total_score(scoreboard) -> (
|
|
|
|
|
// 获取计算总榜的函数标签名
|
|
|
|
|
str_1 = split('\\.', scoreboard);
|
|
|
|
|
function_name = str_1:(length(str_1) - 1);
|
|
|
|
|
// 运行函数,将分数赋值到显示计分板上
|
2022-08-02 00:36:38 +08:00
|
|
|
|
run('function #fzsd:module/scoreboard/assign/scoreboard/general/' + function_name);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 恢复计分板分数,player == null 时恢复所有玩家分数,scoreboard == null 时恢复所有计分板分数
|
|
|
|
|
command_restore(player, scoreboard) -> (
|
|
|
|
|
if(player == null,
|
2022-09-29 22:57:00 +08:00
|
|
|
|
i = 0;
|
|
|
|
|
for(keys(system_info('server_whitelist')),
|
|
|
|
|
i += 1;
|
|
|
|
|
if(i > 10,
|
|
|
|
|
game_tick(50);
|
|
|
|
|
i = 0;
|
|
|
|
|
);
|
|
|
|
|
restore_score(_, scoreboard);
|
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
if(scoreboard == null,
|
2022-09-29 22:57:00 +08:00
|
|
|
|
(
|
|
|
|
|
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 + '分数');
|
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
);
|
|
|
|
|
return();
|
|
|
|
|
);
|
|
|
|
|
if(scoreboard == null,
|
|
|
|
|
for(global_current_scoreboard_list, restore_score(player, _));
|
2022-09-29 22:57:00 +08:00
|
|
|
|
print('重置交易榜会丢失猪灵交易分数,请输入\n“/' + global_app_name + ' restore confirm player <playerName> fzsd.module.scoreboard.display.trade_count”继续执行');
|
|
|
|
|
print('无法还原破基岩榜,已忽略');
|
2022-09-21 08:20:01 +08:00
|
|
|
|
print('已恢复' + player + '的所有分数');
|
|
|
|
|
return();
|
|
|
|
|
);
|
|
|
|
|
if(restore_score(player, scoreboard),
|
|
|
|
|
print('已恢复' + player + '的' + scoreboard + '分数');
|
2022-09-29 22:57:00 +08:00
|
|
|
|
,
|
|
|
|
|
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('无法还原破基岩榜,已忽略');
|
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
);
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 恢复玩家的计分板分数
|
2022-09-29 22:57:00 +08:00
|
|
|
|
restore_score(player_name, scoreboard) -> (
|
|
|
|
|
require_not_null(player_name);
|
|
|
|
|
if(scoreboard == null,
|
|
|
|
|
for(global_current_scoreboard_list, restore_score(player_name, _));
|
2023-07-24 19:46:24 +08:00
|
|
|
|
return(true);
|
2022-09-29 22:57:00 +08:00
|
|
|
|
);
|
|
|
|
|
player = player(player_name);
|
|
|
|
|
player_is_offline = false;
|
|
|
|
|
if(player == null,
|
|
|
|
|
(
|
|
|
|
|
run('player ' + player_name + ' spawn at ~ ~ ~ facing 0 0 in minecraft:overworld in survival');
|
|
|
|
|
player_is_offline = true;
|
|
|
|
|
player = player(player_name);
|
|
|
|
|
)
|
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
if(scoreboard == '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 == 'fzsd.module.scoreboard.display.damage_taken',
|
2022-09-29 22:57:00 +08:00
|
|
|
|
scoreboard(scoreboard, player, statistic(player, 'custom', 'damage_taken')/10);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
,
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.death_count',
|
|
|
|
|
restore_from_stat(scoreboard, player, 'custom', 'deaths');
|
|
|
|
|
,
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.dig_count',
|
|
|
|
|
(
|
|
|
|
|
scoreboard(scoreboard, player, 0);
|
|
|
|
|
for(block_list(),
|
|
|
|
|
append_from_stat(scoreboard, player, 'mined', _);
|
|
|
|
|
);
|
|
|
|
|
),
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.fishing_count',
|
|
|
|
|
scoreboard(scoreboard, player, statistic(player, 'custom', 'fish_caught'));
|
|
|
|
|
,
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.kill_count',
|
|
|
|
|
(
|
|
|
|
|
scoreboard(scoreboard, player, 0);
|
|
|
|
|
for(entity_types('living'),
|
|
|
|
|
append_from_stat(scoreboard, player, 'killed', _);
|
|
|
|
|
);
|
|
|
|
|
),
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.trade_count',
|
2022-09-29 22:57:00 +08:00
|
|
|
|
return(false);
|
|
|
|
|
,
|
2022-09-21 08:20:01 +08:00
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.bedrock_broken_count',
|
2022-09-29 22:57:00 +08:00
|
|
|
|
return(false);
|
|
|
|
|
,
|
2022-09-21 08:20:01 +08:00
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.aviating_distance',
|
|
|
|
|
scoreboard(scoreboard, player, statistic(player, 'custom', 'aviate_one_cm')/200);
|
|
|
|
|
,
|
|
|
|
|
scoreboard == 'fzsd.module.scoreboard.display.placement_count',
|
|
|
|
|
(
|
|
|
|
|
scoreboard(scoreboard, player, 0);
|
|
|
|
|
for(block_list(),
|
|
|
|
|
append_from_stat(scoreboard, player, 'used', _);
|
|
|
|
|
);
|
|
|
|
|
),
|
2022-09-29 22:57:00 +08:00
|
|
|
|
print('未识别的计分板ID!' + scoreboard);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
return(false);
|
|
|
|
|
);
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(scoreboard);
|
2022-09-29 22:57:00 +08:00
|
|
|
|
if(player_is_offline,
|
|
|
|
|
world_spawn = system_info('world_spawn_point');
|
|
|
|
|
run('spreadplayers ' + world_spawn:0 + ' ' + world_spawn:2 + ' 0 10 false ' + player);
|
|
|
|
|
run('player ' + player + ' kill');
|
|
|
|
|
);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
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');
|
2022-09-02 06:03:24 +08:00
|
|
|
|
return();
|
2022-07-26 07:57:04 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
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);
|
2022-09-12 21:53:54 +08:00
|
|
|
|
return();
|
2022-08-02 00:36:38 +08:00
|
|
|
|
);
|
|
|
|
|
|
2022-09-21 08:20:01 +08:00
|
|
|
|
// 设置玩家的计分板分数
|
|
|
|
|
command_set(player, scoreboard, score) -> (
|
|
|
|
|
i = scoreboard(scoreboard, player, score);
|
|
|
|
|
print('玩家' + player + '修改前的分数为:' + i);
|
2022-12-28 07:28:06 +08:00
|
|
|
|
command_recalculate_total_score(scoreboard);
|
2022-09-21 08:20:01 +08:00
|
|
|
|
return(i);
|
|
|
|
|
);
|