Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 committed Sep 28, 2024
1 parent dc4ffce commit 3c935d5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ MCSTAT_SHORTCUTS='
由于第一次测得的延迟一般不准,所以做了这个配置,
开启后每次查询时,会丢掉第一次的结果再查询一次,且使用第二次查询到的结果

### `MCSTAT_JAVA_PROTOCOL_VERSION` - Motd Java 服务器时向服务器发送的客户端协议版本

默认:`767`

## 🎉 使用

发送 `motd` 指令 查看使用指南
Expand Down Expand Up @@ -226,6 +230,10 @@ Telegram:[@lgc2333](https://t.me/lgc2333)

## 📝 更新日志

### 0.6.2

- 允许自定义向 Java 服务器发送的客户端协议版本,且提高默认协议版本以解决部分服务器 Motd 渐变显示异常的问题

### 0.6.1

- fix [#21](https://github.com/lgc-NB2Dev/nonebot-plugin-picmcstat/issues/21)
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_picmcstat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from . import __main__ as __main__ # noqa: E402
from .config import ConfigClass # noqa: E402

__version__ = "0.6.1"
__version__ = "0.6.2"
__plugin_meta__ = PluginMetadata(
name="PicMCStat",
description="将一个 Minecraft 服务器的 MOTD 信息绘制为一张图片",
Expand Down
1 change: 1 addition & 0 deletions nonebot_plugin_picmcstat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ConfigClass(BaseModel):
mcstat_shortcuts: List[ShortcutType] = Field(default_factory=list)
mcstat_resolve_dns: bool = True
mcstat_query_twice: bool = True
mcstat_java_protocol_version: int = 767


config = get_plugin_config(ConfigClass)
5 changes: 3 additions & 2 deletions nonebot_plugin_picmcstat/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,10 @@ async def draw(ip: str, svr_type: ServerType) -> BytesIO:
host, port = await resolve_ip(ip, is_java)

svr = JavaServer(host, port) if is_java else BedrockServer(host, port)
kw = {"version": config.mcstat_java_protocol_version} if is_java else {}
if config.mcstat_query_twice:
await svr.async_status() # 第一次延迟通常不准
resp = await svr.async_status()
await svr.async_status(**kw) # 第一次延迟通常不准
resp = await svr.async_status(**kw)
return draw_resp(resp, ip)

except Exception as e:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ dynamic = ["version"]
description = "A NoneBot2 plugin generates a pic from a Minecraft server's MOTD"
authors = [{ name = "student_2333", email = "[email protected]" }]
dependencies = [
"nonebot2>=2.3.1",
"nonebot-plugin-alconna>=0.48.0",
"nonebot2>=2.3.3",
"nonebot-plugin-alconna>=0.52.3",
"mcstatus>=11.1.1",
"pil-utils>=0.1.10",
"pil-utils>=0.1.12",
"punycode>=0.2.1",
"dnspython>=2.6.1",
]
Expand Down

0 comments on commit 3c935d5

Please sign in to comment.