Exemple #1
0
def command_register(server: ServerInterface):
    global config

    def get_literal_node(literal):
        return Literal(literal).requires(
            lambda src: src.has_permission(config['MinimumPermissionLevel']),
            failure_message_getter=lambda: '权限不足')

    server.register_command(
        Literal(PREFIX).runs(print_notice).on_error(
            UnknownArgument, print_unknown_argument_message,
            handled=True).then(
                get_literal_node('help').runs(
                    lambda src: print_help_message(src))).then(
                        get_literal_node('add').then(
                            QuotableText('title').then(
                                QuotableText('content').runs(
                                    lambda src, ctx: add_notice(
                                        src, ctx['title'], ctx['content']))))).
        then(
            get_literal_node('del').then(
                QuotableText('title').runs(
                    lambda src, ctx: del_notice(src, ctx['title'])))).then(
                        get_literal_node('reload').runs(
                            lambda src: reload_notice_data(server, src))).then(
                                get_literal_node('broadcast').runs(
                                    lambda src: broadcast_notice(server))).
        then(
            get_literal_node('setheader').then(
                QuotableText('header').runs(lambda src, ctx: set_header(
                    server, src, ctx['header'])))).then(
                        get_literal_node('autosend').then(
                            Text('switch').runs(lambda src, ctx: set_autosend(
                                server, src, ctx['switch'])))))
Exemple #2
0
def on_load(server: ServerInterface, old):
    global config, data, host, port
    from ConfigAPI import Config
    from JsonDataAPI import Json
    config = Config(PLUGIN_METADATA['name'], DEFAULT_CONFIG)
    data = Json(PLUGIN_METADATA['name'])
    host = server.get_plugin_instance('cool_q_api').get_config()['api_host']
    port = server.get_plugin_instance('cool_q_api').get_config()['api_port']

    def qq(src, ctx):
        if config['command']['qq']:
            player = src.player if src.is_player else 'Console'
            for i in config['group_id']:
                send_group_msg(f'[{player}] {ctx["message"]}', i)

    server.register_help_message('!!qq <msg>', '向QQ群发送消息')
    server.register_command(
        Literal('!!qq').
            then(
            GreedyText('message').runs(qq)
        )
    )
    server.register_event_listener('cool_q_api.on_qq_info', on_qq_info)
    server.register_event_listener('cool_q_api.on_qq_command', on_qq_command)
    server.register_event_listener('cool_q_api.on_qq_notice', on_qq_notice)
def on_load(server: ServerInterface, old):
    server.register_help_message('!!info', '获取服务器信息')
    server.register_command(
        Literal('!!info').runs(lambda src: src.reply(
            RTextList(
                '§7============ §6服务器信息 §7============\n',
                f'§7CPU利用率:§6 {average(*psutil.cpu_percent(percpu=True))}%\n',
                f'§7内存使用量:§6 {get_used_memory()} / {get_total_memory()}\n',
                f'§7服务器内存占用:§6 {get_this_used_memory(server)}\n',
                f'§7存档大小:§6 {get_world_size()}'))))
def on_load(server: ServerInterface, old):
    global host, port
    host = server.get_plugin_instance('cool_q_api').get_config()['api_host']
    port = server.get_plugin_instance('cool_q_api').get_config()['api_port']

    def qq(src, ctx):
        player = src.player if src.is_player else 'Console'
        for i in config['group_id']:
            send_group_msg(f'[{player}] {ctx["message"]}', i)

    server.register_help_message('!!qq <msg>', '向QQ群发送消息')
    server.register_command(
        Literal('!!qq').then(GreedyText('message').runs(qq)))
def on_load(server: ServerInterface, old):
    server.register_help_message('!!calc', '查看计算插件使用帮助')
    server.register_command(
        Literal('!!calc').requires(lambda src: src.is_player).runs(
            lambda src: src.reply(HELP_MSG)).then(
                Literal('item').then(
                    Integer('box/count').runs(calc_item).then(
                        Integer('stack').then(
                            Integer('single').runs(calc_item))))).
        then(
            Literal('color').then(
                Text('red/#HEX').runs(calc_color).then(
                    Integer('green').then(
                        Integer('blue').runs(calc_color))))).then(
                            GreedyText('expression').runs(calc_expression)))
Exemple #6
0
def on_load(server: ServerInterface, old):
    global mined_ranking
    from ConfigAPI import Config
    config = Config(PLUGIN_METADATA['name'], DEFAULT_CONFIG)
    mined_ranking = MinedRanking(server, config)
    mined_ranking.start()
    server.register_help_message('!!update mined', '更新挖掘榜')
    server.register_command(
        Literal('!!update').
            then(
            Literal('mined').
                requires(
                lambda src: src.has_permission(config['update_permission'])).
                runs(mined_ranking.update)
        )
    )
Exemple #7
0
def on_load(server: ServerInterface, old):
    global single

    @new_thread('SinglePlayerSleep')
    def sleep(src):
        get_time(src.get_server())
        if single.now_time >= 12542:
            fall_asleep = src.get_server().get_plugin_instance(
                'minecraft_data_api').get_player_info(src.player, 'SleepTimer')
            if fall_asleep != 100:
                return src.reply(single.config['not_fall_asleep'])
        else:
            return src.reply(single.config['is_daytime'])
        single.want_skip = True
        need_skip_time = 24000 - single.now_time
        for i in range(single.config['wait_before_skip'], 0, -1):
            if not single.want_skip:
                return
            msg = RText(single.config['waiting_for_skip'].format(
                src.player, i)).c(RAction.run_command, '!!sleep cancel')
            src.get_server().say(msg)
            time.sleep(1)
        for i in range(0, single.config['skip_wait_time']):
            if not single.want_skip:
                return
            jump_times = int(need_skip_time / single.config['skip_wait_time'])
            if src.get_server().is_rcon_running():
                src.get_server().rcon_query(f'time add {jump_times}')
            else:
                src.get_server().execute(f'time add {jump_times}')
            time.sleep(1)
        single.want_skip = False

    def cancel(src):
        if single.want_skip:
            single.want_skip = False
            src.reply(single.config['skip_abort'])
        else:
            src.reply(single.config['no_one_sleeping'])

    single = Single()
    server.register_help_message(
        '!!sleep',
        RText('单人睡觉跳过夜晚').c(RAction.run_command, '!!sleep').h('点我跳过夜晚'))
    server.register_help_message('!!sleep cancel', '取消跳过夜晚')
    server.register_command(
        Literal('!!sleep').runs(sleep).then(Literal('cancel').runs(cancel)))
def register_command(server: ServerInterface):
    """Register commands"""
    # ab
    server.register_command(
        Literal('!!ab').requires(
            lambda src: src.has_permission(PERMISSIONS['help']),
            lambda: '§c权限不足').runs(lambda src: src.reply(HELP_MESSAGE)))

    # kick
    server.register_command(
        Literal('!!kick').requires(
            lambda src: src.has_permission(PERMISSIONS['kick']),
            failure_message_getter=lambda: '§c权限不足').then(
                Text('player').runs(lambda src, ctx: kick(
                    src.get_server(), ctx['player'])).then(
                        GreedyText('reason').runs(lambda src, ctx: kick(
                            src.get_server(), ctx['player'], ctx['reason'])))))

    # ban
    def ban(src, ctx):
        player = ctx['player']
        if player in data.keys():
            return src.reply('§c该玩家已被封禁')
        data[player] = {
            'operator': src.player if src.is_player else None,
            'ban_time': int(time.time()),
            'unban_time': -1,
            'reason': ctx.get('reason', None)
        }
        data.save()
        baned_check(src.get_server(), player)
        src.reply(f'§c已封禁{player}')

    server.register_command(
        Literal('!!ban').requires(
            lambda src: src.has_permission(PERMISSIONS['ban']),
            failure_message_getter=lambda: '§c权限不足').then(
                Text('player').runs(ban).then(GreedyText('reason').runs(ban))))

    # tempban
    def tempban(src, ctx):
        player = ctx['player']
        if player in data.keys():
            return src.reply('§c该玩家已被封禁')
        ban_time = int(time.time())
        try:
            unban_time = ban_time + calc_time(ctx['time'])
        except ValueError:
            return src.reply('§c时间不合法')
        data[player] = {
            'operator': src.player if src.is_player else None,
            'ban_time': ban_time,
            'unban_time': unban_time,
            'reason': ctx.get('reason', None)
        }
        data.save()
        baned_check(server, player)
        src.reply(f'§c已封禁{player}')

    server.register_command(
        Literal('!!tempban').requires(
            lambda src: src.has_permission(PERMISSIONS['tempban']),
            failure_message_getter=lambda: '§c权限不足').then(
                Text('player').then(
                    Text('time').runs(tempban).then(
                        GreedyText('reason').runs(tempban)))))

    # unban
    def unban(src, ctx):
        player = ctx['player']
        if player in data.keys():
            del data[player]
            src.reply(f'§a已解禁{player}')
            data.save()
        else:
            src.reply('§c该玩家未被封禁')

    server.register_command(
        Literal('!!unban').requires(
            lambda src: src.has_permission(PERMISSIONS['unban']),
            failure_message_getter=lambda: '§c权限不足').then(
                Text('player').runs(unban)))

    # banlist
    def banlist(src):
        i = 0
        src.reply('§8>>> §7Banlist:')
        src.reply('§cPlayer §8| §e Duration §8| §7Banned by')
        src.reply('§cType §8> §7Reason')
        for player, info in data.items():
            i += 1
            if info['unban_time'] == -1:
                duration = 'permanent'
                ban_type = 'Ban'
            else:
                duration = f'{int(info["unban_time"] - time.time())}秒'
                ban_type = 'Tempban'
            src.reply('')
            src.reply('§8[§e{}§8]'.format(
                time.strftime('%Y.%m.%d-%H:%M',
                              time.localtime(info['ban_time']))))
            src.reply(f'§c{player} §8| §e{duration} §8| §7{info["operator"]}')
            src.reply(f'§c{ban_type} §8> §7{info["reason"]}')

    server.register_command(
        Literal('!!banlist').requires(
            lambda src: src.has_permission(PERMISSIONS['banlist']),
            failure_message_getter=lambda: '§c权限不足').runs(banlist))
Exemple #9
0
def on_load(server: ServerInterface, old):
    global api, data
    api = server.get_plugin_instance('minecraft_data_api')
    data = Json(PLUGIN_METADATA['name'])

    @new_thread('Gamemode switch mode')
    def change_mode(src):
        # Survival now
        if src.player not in data.keys():
            sur_to_spec(server, src.player)
            src.reply('§a已切换至旁观模式')
        # Spectator now
        elif src.player in data.keys():
            use_time = ceil((time.time() - data[src.player]['time']) / 60)
            src.reply(f'§a您使用了§e{use_time}min')
            spec_to_sur(server, src.player)

    @new_thread('Gamemode tp')
    def tp(src, ctx):
        if src.player not in data.keys():
            src.reply('§c您只能在旁观模式下传送')
        elif ctx['dimension'] not in DIMENSIONS.keys():
            src.reply('§c没有此维度')
        else:
            pos = ' '.join((str(ctx.get('x', '0')), str(ctx.get('y', '80')),
                            str(ctx.get('z', '0'))))
            dim = DIMENSIONS[ctx['dimension']]
            data[src.player]['back'] = {
                'dim': DIMENSIONS[api.get_player_info(src.player,
                                                      'Dimension')],
                'pos': api.get_player_info(src.player, 'Pos')
            }
            data.save()
            server.execute(f'execute in {dim} run tp {src.player} {pos}')
            src.reply(f'§a传送至§e{dim}§a, 坐标§e{dim}')

    @new_thread('Gamemode back')
    def back(src):
        if src.player not in data.keys():
            return server.reply('§c您只能在旁观模式下传送')
        else:
            dim = data[src.player]['back']['dim']
            pos = [str(x) for x in data[src.player]['back']['pos']]
            data[src.player]['back'] = {
                'dim': DIMENSIONS[api.get_player_info(src.player,
                                                      'Dimension')],
                'pos': api.get_player_info(src.player, 'Pos')
            }
            data.save()
            server.execute(
                f'execute in {dim} run tp {src.player} {" ".join(pos)}')
            src.reply('§a已将您传送至上个地点')

    server.register_help_message('!!spec help', 'Gamemode插件帮助')
    server.register_command(
        Literal('!!spec').requires(lambda src: src.is_player).runs(
            change_mode).then(
                Literal('help').runs(lambda src: src.reply(HELP_MESSAGE))))
    server.register_command(
        Literal('!!tp').requires(lambda src: src.is_player).then(
            Text('dimension').runs(tp).then(
                Float('x').then(Float('y').then(Float('z').runs(tp))))))
    server.register_command(
        Literal('!!back').requires(lambda src: src.is_player).runs(back))
Exemple #10
0
def on_load(server: ServerInterface, old):
    from ConfigAPI import Config
    from JsonDataAPI import Json
    global api, data
    api = server.get_plugin_instance('minecraft_data_api')
    config = Config(PLUGIN_METADATA['name'], DEFAULT_CONFIG)
    data = Json(PLUGIN_METADATA['name'])
    permissions = config['permissions']
    server.register_help_message('!!spec help', 'Gamemode插件帮助')

    @new_thread('Gamemode switch mode')
    def change_mode(src, ctx):
        if src.is_console:
            return src.reply('§c仅允许玩家使用')
        player = src.player if ctx == {} else ctx['player']
        if player not in data.keys():
            server.tell(player, '§a已切换至旁观模式')
            sur_to_spec(server, player)
        elif player in data.keys():
            use_time = ceil((time.time() - data[player]['time']) / 60)
            server.tell(player, f'§a您使用了§e{use_time}min')
            spec_to_sur(server, player)

    @new_thread('Gamemode tp')
    def tp(src, ctx):
        if src.is_console:
            return src.reply('§c仅允许玩家使用')
        if src.player not in data.keys():
            src.reply('§c您只能在旁观模式下传送')
        elif ctx['dimension'] not in DIMENSIONS.keys():
            src.reply('§c没有此维度')
        else:
            pos = ' '.join((
                str(ctx.get('x', '0')),
                str(ctx.get('y', '80')),
                str(ctx.get('z', '0'))
            ))
            dim = DIMENSIONS[ctx['dimension']]
            data[src.player]['back'] = {
                'dim': DIMENSIONS[api.get_player_info(src.player, 'Dimension')],
                'pos': api.get_player_info(src.player, 'Pos')
            }
            data.save()
            server.execute(f'execute in {dim} run tp {src.player} {pos}')
            src.reply(f'§a传送至§e{dim}§a, 坐标§e{dim}')

    @new_thread('Gamemode back')
    def back(src):
        if src.is_console:
            return src.reply('§c仅允许玩家使用')
        if src.player not in data.keys():
            return src.reply('§c您只能在旁观模式下传送')
        else:
            dim = data[src.player]['back']['dim']
            pos = [str(x) for x in data[src.player]['back']['pos']]
            data[src.player]['back'] = {
                'dim': DIMENSIONS[api.get_player_info(src.player, 'Dimension')],
                'pos': api.get_player_info(src.player, 'Pos')
            }
            data.save()
            server.execute(
                f'execute in {dim} run tp {src.player} {" ".join(pos)}')
            src.reply('§a已将您传送至上个地点')

    server.register_command(
        Literal('!!spec').
            requires(lambda src: src.has_permission(permissions['spec'])).
            runs(change_mode).
            then(
            Literal('help').
                runs(lambda src: src.reply(HELP_MESSAGE))
        ).
            then(
            Text('player').
                requires(
                lambda src: src.has_permission(permissions['spec_other'])
            ).
                runs(change_mode)
        )
    )
    server.register_command(
        Literal('!!tp').
            requires(lambda src: src.has_permission(permissions['tp'])).
            then(
            Text('dimension').
                runs(tp).
                then(
                Float('x').
                    then(
                    Float('y').
                        then(
                        Float('z').runs(tp)
                    )
                )
            )
        )
    )
    server.register_command(
        Literal('!!back').
            requires(lambda src: src.has_permission(permissions['back'])).
            runs(back)
    )
def on_load(server: ServerInterface, old):
    def abort():
        global abort_flag
        abort_flag = True

    @new_thread(PLUGIN_METADATA["name"])
    def stop(src):
        if wait(server, 'stop'):
            server.stop()

    @new_thread(PLUGIN_METADATA["name"])
    def stop_exit(src):
        if wait(server, 'stop'):
            server.stop_exit()

    @new_thread(PLUGIN_METADATA["name"])
    def restart(src):
        if wait(server, 'restart'):
            server.restart()

    server.register_command(
        Literal('!!abort').
            requires(lambda s: s.has_permission(PERMISSIONS['abort'])).
            runs(abort)
    )

    server.register_command(
        Literal('!!start').
            requires(lambda s: s.has_permission(PERMISSIONS['start'])).
            runs(lambda src: server.start())
    )
    server.register_command(
        Literal('!!stop').
            requires(lambda s: s.has_permission(PERMISSIONS['stop'])).
            runs(stop)
    )
    server.register_command(
        Literal('!!stop_exit').
            requires(lambda s: s.has_permission(PERMISSIONS['stop_exit'])).
            runs(stop_exit)
    )
    server.register_command(
        Literal('!!restart').
            requires(lambda s: s.has_permission(PERMISSIONS['restart'])).
            runs(restart)
    )
    server.register_command(
        Literal('!!exit').
            requires(lambda s: s.has_permission(PERMISSIONS['exit'])).
            runs(lambda src: server.exit())
    )
Exemple #12
0
def register_command(server: ServerInterface):
    def check_my(src):
        if src.is_player:
            src.reply(f'§a您的余额为: §e{vault.get_balance(src.player)}')
        else:
            src.reply(f'§a您没有账号')

    def top(src):
        i = 0
        for name, balance in vault.get_ranking().items():
            i += 1
            src.reply(f'§a{i}.§e{name}§a - §e{balance}')
            if i == config['MAXIMAL_TOPS']:
                break

    def check(src, ctx):
        try:
            amount = vault.get_balance(ctx['player'])
            src.reply(f'§e{ctx["player"]}§a的余额:§e {amount}')
        except vault.AccountNotExistsError:
            src.reply('§c账号不存在')

    def pay(src, ctx):
        try:
            if src.is_player:
                debit = src.player
                credit = ctx['player']
                amount = Decimal(str(round(ctx['amount'], 2)))
                vault.transfer(debit, credit, amount)
                src.reply(f'§a你向§e{credit}§a支付了§e{amount}')
                src.get_server().tell(credit, f'§e{debit}§a向你支付了§e{amount}')
            else:
                src.reply(f'§a您没有账号')
        except vault.AccountNotExistsError:
            src.reply('§c账号不存在')
        except vault.AmountIllegalError:
            src.reply('§c金额不合法')
        except vault.InsufficientBalanceError:
            src.reply('§c余额不足')

    def give(src, ctx):
        try:
            player = ctx['player']
            amount = Decimal(str(round(ctx['amount'], 2)))
            operator = f'Admin_{src.player}' if src.is_player else 'Admin'
            vault.give(player, amount, operator=operator)
            balance = vault.get_balance(player)
            src.reply(f'§a金钱已给予, §e{player}§a 现在有 §e{balance}')
            if REMINDER:
                src.get_server().tell(player, f'§a你被给予了金钱, 余额: §e{balance}')
        except vault.AccountNotExistsError:
            src.reply('§c账号不存在')
        except vault.AmountIllegalError:
            src.reply('§c金额不合法')

    def take(src, ctx):
        try:
            player = ctx['player']
            amount = Decimal(str(round(ctx['amount'], 2)))
            operator = f'Admin_{src.player}' if src.is_player else 'Admin'
            vault.take(player, amount, operator)
            balance = vault.get_balance(player)
            src.reply(f'§a金钱已拿取, §e{player}§a 现在有 §e{balance}')
            if REMINDER:
                src.get_server().tell(player, f'§a你被拿取了金钱, 余额: §e{balance}')
        except vault.AccountNotExistsError:
            src.reply('§c账号不存在')
        except vault.AmountIllegalError:
            src.reply('§c金额不合法')
        except vault.InsufficientBalanceError:
            src.reply('§c余额不足')

    def _set(src, ctx):
        try:
            player = ctx['player']
            amount = Decimal(str(round(ctx['amount'], 2)))
            operator = f'Admin_{src.player}' if src.is_player else 'Admin'
            vault.set(player, amount, operator)
            src.reply(f'§a金钱已设置, §e{player}§a 现在有 §e{amount}')
            if REMINDER:
                src.get_server().tell(player, f'§a你被设置了金钱, 余额: §e{amount}')
        except vault.AccountNotExistsError:
            src.reply('§c账号不存在')
        except vault.AmountIllegalError:
            src.reply('§c金额不合法')

    server.register_command(
        Literal('!!money').runs(check_my).then(
            Literal('help').runs(lambda src: src.reply(HELP_MESSAGE))).then(
                Literal('top').requires(lambda src: src.has_permission(
                    PERMISSIONS['top'])).runs(top)).
        then(
            Literal('check').requires(
                lambda src: src.has_permission(PERMISSIONS['check'])).then(
                    Text('player').runs(check))).then(
                        Literal('pay').then(
                            Text('player').then(Float('amount').runs(pay)))).
        then(
            Literal('give').requires(
                lambda src: src.has_permission(PERMISSIONS['give'])).then(
                    Text('player').then(Float('amount').runs(give)))
        ).then(
            Literal('take').requires(
                lambda src: src.has_permission(PERMISSIONS['take'])).then(
                    Text('player').then(Float('amount').runs(take)))).then(
                        Literal('set').requires(lambda src: src.has_permission(
                            PERMISSIONS['set'])).then(
                                Text('player').then(
                                    Float('amount').runs(_set)))))
Exemple #13
0
def on_load(server: ServerInterface, old):
    from ConfigAPI import Config
    from JsonDataAPI import Json
    config = Config(PLUGIN_METADATA['name'], DEFAULT_CONFIG)
    data = Json(PLUGIN_METADATA['name'])
    permissions = config['permissions']
    server.register_help_message('!!bot help', '显示Bot插件帮助')
    server.register_help_message(
        '!!bot',
        RText('显示机器人列表').c(RAction.run_command, '!!bot').h('点击显示机器人列表'))

    def show_list(src):
        c = []
        for a, b in data.items():
            bot_info = RTextList(
                '\n'
                f'§7----------- §6{a}§7 -----------\n',
                f'§7Dimension:§6 {b["dim"]}\n', f'§7Position:§6 {b["pos"]}\n',
                f'§7Facing:§6 {b["facing"]}\n',
                RText('§d点击放置\n').c(RAction.run_command,
                                    f'!!bot spawn {a}').h(f'放置§6{a}'),
                RText('§d点击移除\n').c(RAction.run_command,
                                    f'!!bot kill {a}').h(f'移除§6{a}'))
            c.append(bot_info)
        src.reply(RTextList(*c))

    def spawn(src, ctx):
        name = ctx['name']
        if name in data.keys():
            dim = data[name]['dim']
            pos = ' '.join([str(i) for i in data[name]['pos']])
            facing = data[name]['facing']
            command = f'player {name} spawn at {pos} facing {facing} in {dim}'
            src.get_server().execute(command)
            src.get_server().execute(f'gamemode {config["gamemode"]} {name}')
        else:
            src.reply('§c机器人名称不正确')

    def kill(src, ctx):
        name = ctx['name']
        if name in data.keys():
            server.execute(f'player {name} kill')
        else:
            src.reply('§c机器人名称不正确')

    def add(src, ctx):
        if ctx['dim'] in DIMENSIONS.keys():
            dim = DIMENSIONS[ctx['dim']]
            pos = [ctx['x'], ctx['y'], ctx['z']]
            facing = f'{ctx["facing_level"]} {ctx["facing_pitch"]}'
            data[ctx['name']] = {'dim': dim, 'pos': pos, 'facing': facing}
            data.save()
            src.reply(f'§a已添加机器人{ctx["name"]}')
        else:
            src.reply('§c无法识别的维度')

    def remove(src, ctx):
        name = ctx['name']
        if name in data.keys():
            del data[name]
            data.save()
            src.reply(f'§a已删除机器人{name}')
        else:
            src.reply('§c机器人名称不正确')

    server.register_command(
        Literal('!!bot').requires(lambda src: src.has_permission(permissions[
            'list'])).runs(show_list).
        then(Literal('help').runs(lambda src: src.reply(HELP_MESSAGE))).then(
            Literal('spawn').requires(lambda src: src.has_permission(
                permissions['spawn'])).then(Text('name').runs(spawn))).then(
                    Literal('kill').requires(lambda src: src.has_permission(
                        permissions['kill'])).then(Text('name').runs(kill))).
        then(
            Literal('add')
            .requires(lambda src: src.has_permission(permissions['add'])).then(
                Text('name').then(
                    Text('dim').then(
                        Integer('x').then(
                            Integer('y').then(
                                Integer('z').then(
                                    Float('facing_level').then(
                                        Float('facing_pitch').runs(add))))))))
        ).then(
            Literal('remove').requires(
                lambda src: src.has_permission(permissions['remove'])).then(
                    Text('name').runs(remove))))
def on_load(server: ServerInterface, old):
    def abort():
        global abort_flag
        abort_flag = True

    @new_thread(PLUGIN_METADATA['name'])
    def stop(src, ctx):
        if wait(server, 'stop', ctx.get('time', DEFAULT_WAIT_TIME)):
            server.stop()

    @new_thread(PLUGIN_METADATA['name'])
    def stop_exit(src, ctx):
        if wait(server, 'stop', ctx.get('time', DEFAULT_WAIT_TIME)):
            server.stop_exit()

    @new_thread(PLUGIN_METADATA['name'])
    def restart(src, ctx):
        if wait(server, 'restart', ctx.get('time', DEFAULT_WAIT_TIME)):
            server.restart()

    server.register_help_message('!!server', '服务器控制指令')
    server.register_command(
        Literal('!!server').
            requires(lambda src: src.has_permission(PERMISSIONS['help'])).
            runs(lambda src: src.reply(HELP_MESSAGE)).
            then(
            Literal('abort').
                requires(lambda src: src.has_permission(PERMISSIONS['abort'])).
                runs(abort)
        ).
            then(
            Literal('start').
                requires(lambda src: src.has_permission(PERMISSIONS['start'])).
                runs(lambda src: server.start())
        ).
            then(
            Literal('stop').
                requires(lambda src: src.has_permission(PERMISSIONS['stop'])).
                runs(stop).
                then(
                Integer('time').
                    runs(stop)
            )
        ).
            then(
            Literal('stop_exit').
                requires(
                lambda src: src.has_permission(PERMISSIONS['stop_exit'])).
                runs(stop_exit).
                then(
                Integer('time').
                    runs(stop_exit)
            )
        ).
            then(
            Literal('restart').
                requires(
                lambda src: src.has_permission(PERMISSIONS['restart'])).
                runs(restart).
                then(
                Integer('time').
                    runs(restart)
            )
        ).
            then(
            Literal('exit').
                requires(lambda src: src.has_permission(PERMISSIONS['exit'])).
                runs(lambda src: server.exit())
        )
    )