新功能:
- fzsd_score.sc:禁止生成白名单玩家,可能在carpet1.4.112可用
This commit is contained in:
parent
5ea4c7461f
commit
05853884de
@ -19,41 +19,11 @@ require_not_null(value) -> (
|
|||||||
);
|
);
|
||||||
|
|
||||||
require_version(requirement) -> (
|
require_version(requirement) -> (
|
||||||
req_0 = slice(requirement, 0, 1);
|
req_ver = split('\\.', requirement);
|
||||||
req_1 = slice(requirement, 1, 2);
|
cur_ver = split('\\.', global_carpet_version);
|
||||||
if(req_0 == '>',
|
return(number(cur_ver:0) >= number(req_ver:0)
|
||||||
if(req_1 == '=',
|
&& number(cur_ver:1) >= number(req_ver:1)
|
||||||
req_ver = split('>=|\\.', requirement);
|
&& number(cur_ver:2) >= number(req_ver:2));
|
||||||
print(player('all'), req_ver);
|
|
||||||
cur_ver = split('\\.', global_carpet_version);
|
|
||||||
return(number(req_ver:1) >= number(cur_ver:0)
|
|
||||||
&& number(req_ver:2) >= number(cur_ver:1)
|
|
||||||
&& number(req_ver:3) >= number(cur_ver:2));
|
|
||||||
);
|
|
||||||
req_ver = split('>|\\.', requirement);
|
|
||||||
print(player('all'), req_ver);
|
|
||||||
cur_ver = split('\\.', global_carpet_version);
|
|
||||||
return(number(req_ver:1) > number(cur_ver:0)
|
|
||||||
&& number(req_ver:2) > number(cur_ver:1)
|
|
||||||
&& number(req_ver:3) > number(cur_ver:2));
|
|
||||||
);
|
|
||||||
if(req_0 == '<',
|
|
||||||
if(req_1 == '=',
|
|
||||||
req_ver = split('<=|\\.', requirement);
|
|
||||||
print(player('all'), req_ver);
|
|
||||||
cur_ver = split('\\.', global_carpet_version);
|
|
||||||
return(number(req_ver:1) <= number(cur_ver:0)
|
|
||||||
&& number(req_ver:2) <= number(cur_ver:1)
|
|
||||||
&& number(req_ver:3) <= number(cur_ver:2));
|
|
||||||
);
|
|
||||||
req_ver = split('<|\\.', requirement);
|
|
||||||
print(player('all'), req_ver);
|
|
||||||
cur_ver = split('\\.', global_carpet_version);
|
|
||||||
return(number(req_ver:1) < number(cur_ver:0)
|
|
||||||
&& number(req_ver:2) < number(cur_ver:1)
|
|
||||||
&& number(req_ver:3) < number(cur_ver:2));
|
|
||||||
);
|
|
||||||
return(false);
|
|
||||||
);
|
);
|
||||||
|
|
||||||
//** 主要逻辑 **//
|
//** 主要逻辑 **//
|
||||||
@ -73,6 +43,7 @@ global_current_scoreboard_list = [
|
|||||||
'fzsd.module.scoreboard.display.aviating_distance',
|
'fzsd.module.scoreboard.display.aviating_distance',
|
||||||
'fzsd.module.scoreboard.display.placement_count'
|
'fzsd.module.scoreboard.display.placement_count'
|
||||||
];
|
];
|
||||||
|
global_server_whitelist_cache = null;
|
||||||
|
|
||||||
__config() -> {
|
__config() -> {
|
||||||
'scope' -> 'global',
|
'scope' -> 'global',
|
||||||
@ -145,22 +116,7 @@ __config() -> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
__on_start() -> (
|
__on_start() -> (
|
||||||
// 读取配置文件
|
reload_configs();
|
||||||
global_config = read_file('config', 'json');
|
|
||||||
if(global_config == null, // carpet 1.4.69 兼容
|
|
||||||
global_config = {};
|
|
||||||
);
|
|
||||||
if(length(global_config) == 0, // 读取失败或不存在
|
|
||||||
delete_file('config', 'json'); // 避免一些意外的问题
|
|
||||||
global_config:'config_version' = '1.0.0'; // 占位用,无实际作用
|
|
||||||
if(require_version('>=1.99.99'), // 等待新功能支持
|
|
||||||
global_config:'allow_spawn_whitelist_player' = false;
|
|
||||||
write_file('config', 'json', global_config);
|
|
||||||
,
|
|
||||||
// else
|
|
||||||
write_file('config', 'json', global_config);
|
|
||||||
);
|
|
||||||
);
|
|
||||||
global_team_cache = read_file('team_cache', 'json');
|
global_team_cache = read_file('team_cache', 'json');
|
||||||
if(global_team_cache == null, // carpet 1.4.69 兼容
|
if(global_team_cache == null, // carpet 1.4.69 兼容
|
||||||
global_team_cache = {};
|
global_team_cache = {};
|
||||||
@ -173,12 +129,14 @@ __on_close() -> (
|
|||||||
write_file('team_cache', 'json', global_team_cache);
|
write_file('team_cache', 'json', global_team_cache);
|
||||||
);
|
);
|
||||||
|
|
||||||
if(require_version('>=1.99.99'), // 等待新功能支持
|
if(require_version('1.4.112'), // 新功能支持
|
||||||
__on_player_command(player, message) -> (
|
__on_player_command(player, command) -> (
|
||||||
print(player('all'), 'command!');
|
l = length(command);
|
||||||
if(length(message) > 7
|
if(l > 13
|
||||||
&& slice(message, 0, 7) == '/player'
|
&& slice(command, 0, 6) == 'player'
|
||||||
&& !(global_config:'allow_spawn_whitelist_player'),
|
&& slice(command, l - 5, l) == 'spawn'
|
||||||
|
&& !(global_config:'allow_spawn_whitelist_player')
|
||||||
|
&& contains(get_server_whitelist(), slice(command, 7, l - 6)),
|
||||||
return('cancel');
|
return('cancel');
|
||||||
);
|
);
|
||||||
);
|
);
|
||||||
@ -186,11 +144,11 @@ if(require_version('>=1.99.99'), // 等待新功能支持
|
|||||||
|
|
||||||
__on_player_connects(player) -> (
|
__on_player_connects(player) -> (
|
||||||
player_type = player ~ 'player_type';
|
player_type = player ~ 'player_type';
|
||||||
player_team = player ~ 'team';
|
|
||||||
player_name = player ~ 'name';
|
|
||||||
if(player_type == 'fake',
|
if(player_type == 'fake',
|
||||||
(
|
(
|
||||||
|
player_team = player ~ 'team';
|
||||||
if(player_team != 'fzsd.module.scoreboard.fake',
|
if(player_team != 'fzsd.module.scoreboard.fake',
|
||||||
|
player_name = player ~ 'name';
|
||||||
global_team_cache:player_name = player_team;
|
global_team_cache:player_name = player_team;
|
||||||
);
|
);
|
||||||
team_add('fzsd.module.scoreboard.fake', player);
|
team_add('fzsd.module.scoreboard.fake', player);
|
||||||
@ -198,7 +156,9 @@ __on_player_connects(player) -> (
|
|||||||
),
|
),
|
||||||
player_type == 'shadow',
|
player_type == 'shadow',
|
||||||
(
|
(
|
||||||
|
player_team = player ~ 'team';
|
||||||
if(player_team != 'fzsd.module.scoreboard.shadow',
|
if(player_team != 'fzsd.module.scoreboard.shadow',
|
||||||
|
player_name = player ~ 'name';
|
||||||
global_team_cache:player_name = player_team;
|
global_team_cache:player_name = player_team;
|
||||||
);
|
);
|
||||||
team_add('fzsd.module.scoreboard.shadow', player);
|
team_add('fzsd.module.scoreboard.shadow', player);
|
||||||
@ -222,6 +182,38 @@ __on_player_disconnects(player, reason) -> (
|
|||||||
try_restore_team_from_cache(player);
|
try_restore_team_from_cache(player);
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 获取服务器白名单
|
||||||
|
get_server_whitelist() -> (
|
||||||
|
if(global_server_whitelist_cache == null,
|
||||||
|
global_server_whitelist_cache = keys(system_info('server_whitelist'));
|
||||||
|
);
|
||||||
|
return(global_server_whitelist_cache);
|
||||||
|
);
|
||||||
|
|
||||||
|
// 重载配置文件
|
||||||
|
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);
|
||||||
|
);
|
||||||
|
);
|
||||||
|
|
||||||
// 获取所有计分板下的所有玩家列表
|
// 获取所有计分板下的所有玩家列表
|
||||||
get_scoreboard_player_list() -> (
|
get_scoreboard_player_list() -> (
|
||||||
set = m();
|
set = m();
|
||||||
|
Loading…
Reference in New Issue
Block a user