Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 committed Jan 11, 2025
1 parent 15a37bd commit 5efd6f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ plugins = [
### 字体

字体文件请自行去自行去 [这里](http://ftp.gnu.org/gnu/unifont/unifont-15.0.01/unifont-15.0.01.ttf) 下载
如需将英文部分变为游戏内字体,请另外下载安装 [这个](https://resources.download.minecraft.net/3d/3d009535ec7860c29603cd66cdb4db5c8b4aefd2) 字体(请自行修改文件扩展名为 `.ttf`

将字体文件直接安装在系统中即可
如果不行,请尝试右键字体文件点击 `为所有用户安装`
Expand All @@ -139,7 +140,7 @@ plugins = [

### `MCSTAT_FONT` - 使用的字体名称 / 路径

默认:`["unifont"]`
默认:`["Minecraft Seven", "unifont"]`

请按需自行更改

Expand Down Expand Up @@ -230,6 +231,10 @@ Telegram:[@lgc2333](https://t.me/lgc2333)

## 📝 更新日志

### 0.7.1

- 修复文字下对齐的 Bug

### 0.7.0

- 适配 pil-utils 0.2
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.7.0"
__version__ = "0.7.1"
__plugin_meta__ = PluginMetadata(
name="PicMCStat",
description="将一个 Minecraft 服务器的 MOTD 信息绘制为一张图片",
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_picmcstat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ShortcutType(BaseModel):


class ConfigClass(BaseModel):
mcstat_font: list[str] = ["unifont"]
mcstat_font: list[str] = ["Minecraft Seven", "unifont"]
mcstat_show_addr: bool = False
mcstat_show_delay: bool = True
mcstat_show_mods: bool = False
Expand Down
20 changes: 7 additions & 13 deletions nonebot_plugin_picmcstat/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
EXTRA_STROKE_WIDTH = 2
STROKE_RATIO = 0.0625
SPACING = 12
LIST_GAP = 32
LIST_GAP = 12

JE_HEADER = "[MCJE服务器信息]"
BE_HEADER = "[MCBE服务器信息]"
Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(
self,
left: Union[ImageType, str],
right: Union[ImageType, str, None] = None,
gap: int = 0,
gap: int = LIST_GAP,
):
self.left = ex_default_style(left) if isinstance(left, str) else left
self.right = (
Expand Down Expand Up @@ -135,13 +135,8 @@ def from_list(cls, li: Sequence[Union[ImageType, str]], **kwargs) -> "ImageGrid"

@property
def width(self) -> float:
return (
(
max(width(x.left) for x in self)
+ max((width(x.right) + x.gap if x.right else 0) for x in self)
)
if self.align_items
else max(x.width for x in self)
return max(width(x.left) for x in self) + max(
(width(x.right) + x.gap if x.right else 0) for x in self
)

@property
Expand All @@ -166,7 +161,7 @@ def draw_on(self, bg: BuildImage, offset_pos: tuple[float, float]) -> None:
calc_offset(
offset_pos,
(0, y_offset),
(0, (line_height - line.left.height)),
# (0, (line_height - line.left.height)),
),
)
if line.right:
Expand All @@ -176,7 +171,7 @@ def draw_on(self, bg: BuildImage, offset_pos: tuple[float, float]) -> None:
calc_offset(
offset_pos,
((max_lw or width(line.left)) + line.gap, y_offset),
(0, (line_height - line.right.height)),
# (0, (line_height - line.right.height)),
),
)
y_offset += line_height + self.spacing
Expand Down Expand Up @@ -341,7 +336,7 @@ def draw_java(res: JavaStatusResponse, addr: str) -> BytesIO:
if mod_list and config.mcstat_show_mods:
grid.append_line(
l_style("Mod 列表: "),
ImageGrid.from_list(mod_list, gap=LIST_GAP),
ImageGrid.from_list(mod_list),
)
if res.players.sample:
grid.append_line(
Expand All @@ -351,7 +346,6 @@ def draw_java(res: JavaStatusResponse, addr: str) -> BytesIO:
transformer.transform(Motd.parse(x.name).parsed)
for x in res.players.sample
],
gap=LIST_GAP,
),
)

Expand Down

0 comments on commit 5efd6f8

Please sign in to comment.