Minecraft 工具

RText

API 包 路径: mcdreforged.api.rtext

Minecraft 高级文本组件库

感谢 Pandaria98stext API 库,这同时是此库的灵感来源

文本样式

class mcdreforged.minecraft.rtext.style.RItem[源代码]

Minecraft 文本样式

abstract property name: str

其在 Minecraft 文本容器中的 value 值

class mcdreforged.minecraft.rtext.style.RItemClassic(name: str, mc_code: str, console_code: str)[源代码]

基类:RItem, ABC

一种传统的 RItem 对象,可以使用以 "§" 为前缀的传统样式代码,或一个 "\033[31m" 风格的 ANSI 转义代码来表示

参见

Minecraft Wiki 格式化代码 页面

property mc_code: str

在 Minecraft 中的样式代码,以 "§" 为前缀

property console_code: str

在控制台中的样式代码,即 ANSI 转义代码

如果没有合适的转义代码,其值可能为空串

class mcdreforged.minecraft.rtext.style.RColor(rgb_code: int)[源代码]

Minecraft 文本颜色

black: ClassVar[RColorClassic] = RColorClassic(name='black', mc_code='§0', console_code='\x1b[30m')
dark_blue: ClassVar[RColorClassic] = RColorClassic(name='dark_blue', mc_code='§1', console_code='\x1b[34m')
dark_green: ClassVar[RColorClassic] = RColorClassic(name='dark_green', mc_code='§2', console_code='\x1b[32m')
dark_aqua: ClassVar[RColorClassic] = RColorClassic(name='dark_aqua', mc_code='§3', console_code='\x1b[36m')
dark_red: ClassVar[RColorClassic] = RColorClassic(name='dark_red', mc_code='§4', console_code='\x1b[31m')
dark_purple: ClassVar[RColorClassic] = RColorClassic(name='dark_purple', mc_code='§5', console_code='\x1b[35m')
gold: ClassVar[RColorClassic] = RColorClassic(name='gold', mc_code='§6', console_code='\x1b[33m')
gray: ClassVar[RColorClassic] = RColorClassic(name='gray', mc_code='§7', console_code='\x1b[37m\x1b[2m')
dark_gray: ClassVar[RColorClassic] = RColorClassic(name='dark_gray', mc_code='§8', console_code='\x1b[37m\x1b[2m')
blue: ClassVar[RColorClassic] = RColorClassic(name='blue', mc_code='§9', console_code='\x1b[94m')
green: ClassVar[RColorClassic] = RColorClassic(name='green', mc_code='§a', console_code='\x1b[92m')
aqua: ClassVar[RColorClassic] = RColorClassic(name='aqua', mc_code='§b', console_code='\x1b[96m')
red: ClassVar[RColorClassic] = RColorClassic(name='red', mc_code='§c', console_code='\x1b[91m')
light_purple: ClassVar[RColorClassic] = RColorClassic(name='light_purple', mc_code='§d', console_code='\x1b[95m')
yellow: ClassVar[RColorClassic] = RColorClassic(name='yellow', mc_code='§e', console_code='\x1b[93m')
white: ClassVar[RColorClassic] = RColorClassic(name='white', mc_code='§f', console_code='\x1b[37m')
reset: ClassVar[RColorClassic] = RColorClassic(name='reset', mc_code='§r', console_code='\x1b[0m')
classmethod from_mc_value(value: str) RColor[源代码]

一个工厂函数,从给定的 Minecraft 颜色值构造一个 RColor 对象

参数:

value -- Minecraft 文本容器 中 color 属性的值,如 "red""blue""#00AAFF"

返回:

与之对应的 RColor 对象

抛出:

ValueError -- 若给定的值不是一个合法的 Minecraft 颜色

property r: int

颜色的红色分量,范围为 [0, 255]

property g: int

颜色的绿色分量,范围为 [0, 255]

property b: int

颜色的蓝色分量,范围为 [0, 255]

class mcdreforged.minecraft.rtext.style.RColorClassic(name: str, rgb_code: int, mc_code: str, console_code: str)[源代码]

基类:RItemClassic, RColor

使用颜色名字定义的传统 Minecraft 文本颜色

注意

不要自己构造这个类。如果你想使用传统颜色,请使用 RColor 类的属性

to_rgb() RColorRGB[源代码]

转换为与之对应的,颜色值完全一致的 RColorRGB 对象

class mcdreforged.minecraft.rtext.style.RColorRGB(rgb_code: int)[源代码]

使用十六进制 RGB 颜色格式定义的 Minecraft 文本颜色。借助它你可以精准地指定颜色的 RGB 值

备注

在 Minecraft 1.16+ 中可用

__init__(rgb_code: int)[源代码]
参数:

rgb_code -- 一个 int,其值在十六进制下为 0xRRGGBB 格式,或者一个形如 "RRGGBB""0xRRGGBB""#RRGGBB" 的字符串

classmethod from_code(rgb_code: str | int) RColorRGB[源代码]

一个工厂函数,使用 RGB 颜色代码构造一个 RColorRGB 对象

参数:

rgb_code -- 一个 int,其值在十六进制下为 0xRRGGBB 格式,或者一个形如 "RRGGBB""0xRRGGBB""#RRGGBB" 的字符串

classmethod from_rgb(red: int, green: int, blue: int) RColorRGB[源代码]

一个工厂函数,使用 3 个 RGB 颜色值构造一个 RColorRGB 对象

参数:
  • red -- 颜色的红色分量

  • green -- 颜色的绿色分量

  • blue -- 颜色的蓝色分量

to_classic() RColorClassic[源代码]

转换为在 RGB 颜色空间中与之欧氏距离最近的 RColorClassic 对象

class mcdreforged.minecraft.rtext.style.RStyle[源代码]

Minecraft 文本样式

bold: ClassVar[RStyleClassic] = RStyleClassic(name='bold', mc_code='§l', console_code='\x1b[1m')
italic: ClassVar[RStyleClassic] = RStyleClassic(name='italic', mc_code='§o', console_code='')
underlined: ClassVar[RStyleClassic] = RStyleClassic(name='underlined', mc_code='§n', console_code='')
strikethrough: ClassVar[RStyleClassic] = RStyleClassic(name='strikethrough', mc_code='§m', console_code='')
obfuscated: ClassVar[RStyleClassic] = RStyleClassic(name='obfuscated', mc_code='§k', console_code='')
class mcdreforged.minecraft.rtext.style.RStyleClassic(name: str, mc_code: str, console_code: str)[源代码]

基类:RItemClassic, RStyle

传统 Minecraft 文本样式,拥有着对应的以 "§" 为前缀的样式代码

文本点击事件

class mcdreforged.minecraft.rtext.click_event.RClickAction[源代码]

Minecraft 文本点击事件行为

在 v2.15.0 版本加入.

备注

对于 v2.15.0 以前的版本,请使用 RAction 作为替代。如需最大的兼容性,继续用 RAction 即可

suggest_command: ClassVar[RClickAction[RClickSuggestCommand]] = _RClickActionImpl(action='suggest_command', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickSuggestCommand'>)

使用给定的文本填充聊天栏

run_command: ClassVar[RClickAction[RClickRunCommand]] = _RClickActionImpl(action='run_command', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickRunCommand'>)

将给定的文本作为命令运行

(Minecraft <1.19.1) 如果给定的文本不以 "/" 开头,给定的文本将会被当做聊天信息发送至服务端。借此,玩家在点击被修饰的文本后可以自动执行 MCDR 命令

注意

在原版 Minecraft >=1.19.1 中,只有以 "/" 开头的字符串,即代表命令的字符串,可以被用作 run_command 动作的值

对于其他不以 "/" 开头的字符串,客户端将拒接发送对应的聊天消息

Issue #203

open_url: ClassVar[RClickAction[RClickOpenUrl]] = _RClickActionImpl(action='open_url', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickOpenUrl'>)

打开给定链接

open_file: ClassVar[RClickAction[RClickOpenFile]] = _RClickActionImpl(action='open_file', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickOpenFile'>)

从给定路径打开文件

备注

事实上原版 Minecraft 并不允许命令中的文本包含 open_file 动作,因此当你发现这个 open_file 不起作用时别太惊讶

copy_to_clipboard: ClassVar[RClickAction[RClickCopyToClipboard]] = _RClickActionImpl(action='copy_to_clipboard', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickCopyToClipboard'>)

将给定文本复制到剪切板

备注

在 Minecraft 1.15+ 中可用

change_page: ClassVar[RClickAction[RClickChangePage]] = _RClickActionImpl(action='change_page', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickChangePage'>)

要跳转到当前打开的书本页数

备注

仅在成书中的有效

show_dialog: ClassVar[RClickAction[RClickShowDialog]] = _RClickActionImpl(action='show_dialog', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickShowDialog'>)

打开一个对话框

备注

在 Minecraft 1.21.6+ 中可用

在 v2.15.0 版本加入.

custom: ClassVar[RClickAction[RClickCustom]] = _RClickActionImpl(action='custom', class=<class 'mcdreforged.minecraft.rtext.click_event.RClickCustom'>)

在服务端触发一个自定义文本事件,后续表现取决于服务端的 mod / 插件,原版服务端对此不会有任何响应

备注

在 Minecraft 1.21.6+ 中可用

在 v2.15.0 版本加入.

mcdreforged.minecraft.rtext.click_event.RAction

RClickAction 的别名

在 v1.0.0 版本加入.

class mcdreforged.minecraft.rtext.click_event.RClickEvent[源代码]

Minecraft 文本点击事件组件的抽象基类

在 v2.15.0 版本加入.

abstract property action: RClickAction

返回该组件的点击事件行为

final to_json_object(json_format: RTextJsonFormat) dict[源代码]

将自身序列化成一个 json dict

参数:

json_format -- 目标 json 格式

final classmethod from_json_object(click_event: dict, json_format: RTextJsonFormat) RClickEvent[源代码]

将一个 json dict 反序列化回一个点击事件组件

参数:
  • click_event -- 要反序列化的 json dict

  • json_format -- 源 json 格式

class mcdreforged.minecraft.rtext.click_event.RClickEventSingleValue[源代码]

那些只包含 1 个值的点击事件组件的抽象基类

在 v2.15.0 版本加入.

class mcdreforged.minecraft.rtext.click_event.RClickSuggestCommand(command: str)[源代码]

表示 RClickAction.suggest_command 的点击事件组件

在 v2.15.0 版本加入.

command: str

用于填充聊天栏的文本

class mcdreforged.minecraft.rtext.click_event.RClickRunCommand(command: str)[源代码]

表示 RClickAction.run_command 的点击事件组件

在 v2.15.0 版本加入.

command: str

用于作为命令运行的文本

class mcdreforged.minecraft.rtext.click_event.RClickOpenUrl(url: str)[源代码]

表示 RClickAction.open_url 的点击事件组件

在 v2.15.0 版本加入.

url: str

要打开的 url

class mcdreforged.minecraft.rtext.click_event.RClickOpenFile(path: str)[源代码]

表示 RClickAction.open_file 的点击事件组件

在 v2.15.0 版本加入.

path: str

要打开的文件路径

class mcdreforged.minecraft.rtext.click_event.RClickCopyToClipboard(value: str)[源代码]

表示 RClickAction.copy_to_clipboard 的点击事件组件

在 v2.15.0 版本加入.

value: str

要复制到剪切板的内容

class mcdreforged.minecraft.rtext.click_event.RClickShowDialog(dialog: str | dict)[源代码]

表示 RClickAction.show_dialog 的点击事件组件

备注

在 Minecraft 1.21.6+ 中可用

在 v2.15.0 版本加入.

dialog: str | dict

对话框的数据。它可以是(任选其一):

  1. 对话框唯一标识符,如 minecraft:server_links

  2. 对话框的 NBT 数据

class mcdreforged.minecraft.rtext.click_event.RClickChangePage(page: int)[源代码]

表示 RClickAction.change_page 的点击事件组件

在 v2.15.0 版本加入.

page: int

要跳转到的页数

class mcdreforged.minecraft.rtext.click_event.RClickCustom(id: str, payload: str | dict | None = None)[源代码]

表示 RClickAction.custom 的点击事件组件

备注

在 Minecraft 1.21.6+ 中可用

在 v2.15.0 版本加入.

id: str

唯一标识符

payload: str | dict | None = None

数据

文本悬浮事件

class mcdreforged.minecraft.rtext.hover_event.RHoverAction[源代码]

Minecraft 文本悬浮事件行为

在 v2.15.0 版本加入.

show_text: ClassVar[RHoverAction[RHoverText]] = _RHoverActionImpl(action='show_text', class=<class 'mcdreforged.minecraft.rtext.hover_event.RHoverText'>)

展示悬浮文本

show_entity: ClassVar[RHoverAction[RHoverEntity]] = _RHoverActionImpl(action='show_entity', class=<class 'mcdreforged.minecraft.rtext.hover_event.RHoverEntity'>)

展示实体信息

show_item: ClassVar[RHoverAction[RHoverItem]] = _RHoverActionImpl(action='show_item', class=<class 'mcdreforged.minecraft.rtext.hover_event.RHoverItem'>)

展示物品信息

class mcdreforged.minecraft.rtext.hover_event.RHoverEvent[源代码]

Minecraft 文本悬浮事件组件的抽象基类

在 v2.15.0 版本加入.

abstract property action: RHoverAction

返回该组件的悬浮事件行为

final to_json_object(json_format: RTextJsonFormat) dict[源代码]

将自身序列化成一个 json dict

参数:

json_format -- 目标 json 格式

final classmethod from_json_object(hover_event: dict, json_format: RTextJsonFormat) RHoverEvent[源代码]

将一个 json dict 反序列化回一个悬浮事件组件

参数:
  • hover_event -- 要反序列化的 json dict

  • json_format -- 源 json 格式

class mcdreforged.minecraft.rtext.hover_event.RHoverText(text: RTextBase)[源代码]

表示 RHoverAction.show_text 的悬浮事件组件

在 v2.15.0 版本加入.

text: RTextBase

用于展示的文本

class mcdreforged.minecraft.rtext.hover_event.RHoverEntity(id: str, uuid: UUID, name: str | RTextBase | None = None)[源代码]

表示 RHoverAction.show_entity 的悬浮事件组件

在 v2.15.0 版本加入.

id: str

对话框唯一标识符,如 minecraft:creeper

uuid: UUID

实体的 UUID

name: str | RTextBase | None = None

(可选)实体的自定义名字

class mcdreforged.minecraft.rtext.hover_event.RHoverItem(id: str, count: int | None = None, components: dict | None = None)[源代码]

表示 RHoverAction.show_item 的悬浮事件组件

在 v2.15.0 版本加入.

id: str

物品类型的唯一标识符,如 minecraft:stone

count: int | None = None

(可选)物品的数量。尽管这是可选的,仍建议提供一个合法取值(如 1)

components: dict | None = None

(可选)物品的额外 NBT 标签 / 组件

文本组件

class mcdreforged.minecraft.rtext.text.RTextBase[源代码]

Minecraft 文本组件的抽象基类

abstractmethod to_json_object(**kwargs: Unpack[ToJsonKwargs]) dict | list[源代码]

返回一个代表其数据的对象,该对象可以被序列化为 json 字符串

to_json_str(**kwargs: Unpack[ToJsonKwargs]) str[源代码]

返回一个代表其数据的 json 格式字符串

它可以作为如 Minecraft 命令 /tellraw <target> <message> 中的第二个参数

abstractmethod to_plain_text() str[源代码]

返回纯文本以供控制台显示

点击事件和悬停事件将被忽略

abstractmethod to_colored_text() str[源代码]

返回由 ANSI 转移代码染色的带颜色文本,以供控制台显示

点击事件和悬停事件将被忽略

abstractmethod to_legacy_text() str[源代码]

返回由以 "§" 为前缀的传统 Minecraft 样式代码染色的带颜色文本

点击事件和悬停事件将被忽略

abstractmethod copy() Self[源代码]

返回自身的一个深拷贝副本

abstractmethod set_color(color: RColor) Self[源代码]

设置文本的颜色,并返回文本组件本身

abstractmethod set_styles(styles: RStyle | Iterable[RStyle]) Self[源代码]

设置文本的样式,并返回文本组件本身

final set_click_event(event: RClickEvent, /) Self[源代码]
final set_click_event(*, event: RClickEvent) Self
final set_click_event(action: RClickAction[RClickEventSingleValue[_T]], value: _T, /) Self
final set_click_event(*, action: RClickAction[RClickEventSingleValue[_T]], value: _T) Self

设置点击事件

你既可以直接提供一个点击事件组件,也可以提供点击事件组件类型和组件的值

text = RText('example')

text.set_click_event(RClickSuggestCommand('/say something'))  # directly
text.set_click_event(event=RClickSuggestCommand('/say something'))  # directly (kwarg)
text.set_click_event(RClickAction.suggest_command, '/say something')  # action + value
text.set_click_event(action=RClickAction.suggest_command, value='/say something')  # action + value (kwarg)

方法 c() 是方法 set_click_event() 的简写

abstractmethod set_hover_event(hover_event: RHoverEvent) Self[源代码]

设置悬浮事件

set_hover_text(*args) Self[源代码]

设置悬浮文本

方法 h() 是方法 set_hover_text() 的简写

参数:

args -- 用于创建 RTextList 实例的元素。RTextList 实例将作为实际的悬浮文本

返回:

自身

c(arg1: RClickEvent | RClickAction[RClickEventSingleValue[_T]] = <unset>, arg2: _T = <unset>, /, *, event: RClickEvent = <unset>, action: RClickAction[RClickEventSingleValue[_T]] = <unset>, value: _T = <unset>) Self

方法 set_click_event() 的别名

h(*args) Self

方法 set_hover_text() 的别名

static from_any(text) RTextBase[源代码]

将任意对象转换为一个 RText 组件

static join(divider: Any, iterable: Iterable[Any]) RTextBase[源代码]

就像 str.join() 方法一样,它使用 divider 连接任意数量的文本

例子:

>>> text = RTextBase.join(',', [RText('1'), '2', 3])
>>> text.to_plain_text()
'1,2,3'
参数:
  • divider -- 元素间的分隔符。这个分隔符对象将被复用

  • iterable -- 将被 join 的元素

static format(fmt: str, *args, **kwargs) RTextBase[源代码]

就像 str.format() 方法一样,它使用 *args**kwargsfmt 的基础上进行格式化并生成一个 RText 组件

例子:

>>> text = RTextBase.format('a={},b={},c={c}', RText('1', color=RColor.blue), '2', c=3)
>>> text.to_plain_text()
'a=1,b=2,c=3'
参数:
  • fmt -- 格式字符串

  • args -- 用于格式化的参数

  • kwargs -- 用于格式化的关键字参数

classmethod from_json_object(data: str | list | dict, **kwargs: Unpack[FromJsonKwargs]) RTextBase[源代码]

将一个 json 对象转换为一个 RText 组件

例子:

>>> text = RTextBase.from_json_object({'text': 'my text', 'color': 'red'})
>>> text.to_plain_text()
'my text'
>>> text.to_json_object()['color']
'red'
参数:

data -- 一个 json 对象

在 v2.4.0 版本加入.

class mcdreforged.minecraft.rtext.text.RText(text: Any, color: RColor | None = None, styles: RStyle | Iterable[RStyle] | None = None)[源代码]

基类:RTextBase

常规文本组件类

__init__(text: Any, color: RColor | None = None, styles: RStyle | Iterable[RStyle] | None = None)[源代码]

给定文本创建一个 RText 对象,可选文本颜色及样式

参数:
  • text -- 文本内容。它将被转换为 str

  • color -- 可选参数,文本的颜色

  • styles -- 可选参数,文本的样式。它可以是单一一个 RStyle,也可以是 RStyle 的一个可迭代对象

class mcdreforged.minecraft.rtext.text.RTextList(*args: Any)[源代码]

基类:RTextBase

一个储存着若干个 RTextBase 对象的列表,即一个复合文本组件

__init__(*args: Any)[源代码]

使用给定的 *args 创建一个 RTextList

参数:

args -- 此 RTextList 中的元素。它们可以是 strRTextBase 或任何实现了 __str__ 方法的类。所有的非 RTextBase 元素都将被转换为 RText

class mcdreforged.minecraft.rtext.text.RTextTranslation(translation_key: str, color: RColor = RColorClassic(name='reset', mc_code='§r', console_code='\x1b[0m'), styles: RStyle | Iterable[RStyle] | None = None)[源代码]

基类:RText

翻译文本组件类。几乎和 RText 相同

__init__(translation_key: str, color: RColor = RColorClassic(name='reset', mc_code='§r', console_code='\x1b[0m'), styles: RStyle | Iterable[RStyle] | None = None)[源代码]

使用特定的翻译键创建一个 RTextTranslation 对象。其余参数与 RText 相同

如果这个翻译需要一些参数,你可以使用方法 arg() 来设置

例子:

RTextTranslation('advancements.nether.root.title', color=RColor.red)
参数:
  • translation_key -- 翻译键

  • color -- 可选参数,文本的颜色

  • styles -- 可选参数,文本的样式。它可以是单一一个 RStyle,也可以是 RStyle 的一个可迭代对象

arg(*args: Any) Self[源代码]

设置翻译参数

参数:

args -- 翻译的参数

fallback(fallback: str) Self[源代码]

设置翻译缺省文本

注意

仅适用于 Minecraft >= 1.19.4

参数:

fallback -- 用于在翻译键未被识别时显示的缺省文本

class mcdreforged.translation.translation_text.RTextMCDRTranslation(translation_key: str, *args, **kwargs)[源代码]

基类:RTextBase

MCDR 翻译文本组件类

当 MCDR 正在运行时,它将使用 ServerInterface 类中的 tr() 方法作为翻译的方法,并使用 MCDR 的语言作为默认语言

在 v2.1.0 版本加入.

__init__(translation_key: str, *args, **kwargs)[源代码]

使用与翻译相关的必要参数创建一个 RTextMCDRTranslation 组件

参数:
  • translation_key -- 翻译键

  • args -- 翻译的参数

  • kwargs -- 翻译的关键字参数

classmethod language_context(language: str)[源代码]

创建一个上下文,在其中所有的 RTextMCDRTranslation 将会使用给定的语言来进行翻译

它主要在你想要在特定语言下,获得该文本组件对应的翻译后的字符串或翻译后的 Minecraft json 文本时使用

MCDR 将自动地于发送信息至玩家或控制台前,使用 用户的偏好语言 应用该上下文管理器

例子:

def log_message_line_by_line(server: ServerInterface):
        with RTextMCDRTranslation.language_context('en_us'):
                text: RTextMCDRTranslation = server.rtr('my_plugin.some_message')
                text_as_str: str = text.to_plain_text()  # The translation operation happens here
                server.logger.info('Lines of my translation')
                for line in text_as_str.splitlines():
                        server.logger.info('- {}'.format(line))
参数:

language -- 在上下文中进行翻译时所用的语言

杂项

class mcdreforged.minecraft.rtext.schema.RTextJsonFormat(*values)[源代码]

为不同的 Minecraft 版本定义的 RText 组件的序列化格式

V_1_7 = RTextJsonFormatItem(click_event_key='clickEvent', hover_event_key='hoverEvent')

适用于 Minecraft [1.7, 1.21.5)

V_1_21_5 = RTextJsonFormatItem(click_event_key='click_event', hover_event_key='hover_event')

适用于 Minecraft [1.21.5, ~)

Rcon

API 包 路径: mcdreforged.api.rcon

class mcdreforged.minecraft.rcon.rcon_connection.RconConnection(address: str, port: int, password: str, *, logger: Logger | None = None)[源代码]

一个简单的 rcon 客户端,用于连接到任何支持 rcon 协议的 Minecraft 服务端

__init__(address: str, port: int, password: str, *, logger: Logger | None = None)[源代码]

创建一个 rcon 客户端实例

参数:
  • address -- rcon 服务器的地址

  • port -- rcon 服务器的端口

  • password -- rcon 服务器的密码

关键字参数:

logger -- 可选参数,一个 logging.Logger 实例。它用于输出一些警告信息,例如接受数据包失败

connect() bool[源代码]

启动与 rcon 服务器的连接并尝试登录

返回:

连接与登录是否成功

disconnect()[源代码]

断开与服务器的连接

send_command(command: str, max_retry_time: int = 3) str | None[源代码]

将命令发送到 rcon 服务器

参数:
  • command -- 要发送到服务器的命令

  • max_retry_time -- 操作的最大重试次数

返回:

服务器的命令执行结果。如果重试次数超过 max_retry_time,则将返回 None