Created
April 7, 2026 01:49
-
-
Save unex/448caef4400a6af903eab2b0621fd4d9 to your computer and use it in GitHub Desktop.
keepalive.sc fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // re-logs fake players upon server restart | |
| // must need to place it directly in the world scripts folder | |
| __config() -> {'scope' -> 'global'}; | |
| __spawn_players() -> ( | |
| data = load_app_data(); | |
| if (data && data:'players', | |
| data = parse_nbt(data:'players'); | |
| for (data, | |
| for([str('player %s spawn at %f %f %f facing %f %f in %s in %s', | |
| _:'name', _:'x', _:'y', _:'z', _:'yaw', _:'pitch', _:'dim', _:'gm')], | |
| logger('warn', _); | |
| run(_); | |
| if (player(_:'name'), | |
| modify(player(_:'name'), 'flying', _:'fly') | |
| ) | |
| ); | |
| ); | |
| ); | |
| ); | |
| __on_server_starts() -> ( | |
| sleep(200); // wait ~4 ticks after server start | |
| task('__spawn_players'); | |
| ); | |
| __on_server_shuts_down() -> ( | |
| data = nbt('{players:[]}'); | |
| saved = []; | |
| for (filter(player('all'), _~'player_type' == 'fake'), | |
| pdata = nbt('{}'); | |
| pdata:'name' = _~'name'; | |
| pdata:'dim' = _~'dimension'; | |
| pdata:'x' = _~'x'; | |
| pdata:'y' = _~'y'; | |
| pdata:'z' = _~'z'; | |
| pdata:'yaw' = _~'yaw'; | |
| pdata:'pitch' = _~'pitch'; | |
| pdata:'gm' = _~'gamemode'; | |
| pdata:'fly' = _~'flying'; | |
| put(data, 'players', pdata, -1); | |
| saved += _~'name'; | |
| ); | |
| store_app_data(data); | |
| if (saved, logger('warn', 'saved '+saved+' for next startup')); | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment