コード例 #1
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)
コード例 #2
0
def broadcast_notice(server: ServerInterface):
    player_list = server.get_plugin_instance(
        'online_player_api').get_player_list()
    output_notice = get_output_rtext()
    for player in player_list:
        server.tell(player, output_notice)
        server.logger.info('Send notice to {} successfully.'.format(player))
コード例 #3
0
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)))
コード例 #4
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))
コード例 #5
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)
    )