Compare commits

...

2 Commits

Author SHA1 Message Date
neveler
077b92be1d
支持 GitHub 风格的 Markdown 提示块(Alert)语法 (#344)
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-06 14:26:53 +08:00
neveler
e3717d0ebe
优化整合包制作教程 (#371) 2025-12-06 14:26:45 +08:00
13 changed files with 75 additions and 16 deletions

View File

@ -0,0 +1,15 @@
note:
title: 注意
class_name: notice--info
tip:
title: 提示
class_name: notice--success
important:
title: 重要
class_name: notice--primary
warning:
title: 警告
class_name: notice--warning
caution:
title: 谨慎
class_name: notice--danger

View File

@ -1,25 +1,28 @@
---
title: 服务端自动更新整合包制作教程
excerpt: 创建可自动更新的服务器整合包
date: 2021-08-22 23:18:02 +0800
date: 2021-08-22T23:18:02+08:00
last_modified_at: 2025-12-06T09:37:00+08:00
author: huanghongxun
---
HMCL 允许服务器管理员借助服务端自动更新整合包来实现自动分发整合包更新,这将大大方便有需要频繁更新游戏客户端 Mod、配置等信息的服务器管理员。
HMCL 需要服务器管理员额外提供一个 HTTP 服务器(只需要能提供静态文件服务,比如 Apache 和 Nginx 皆可)来提供检查整合包更新并允许 HMCL 下载更新文件。
## 第一步:导出整合包
在 HMCL 中右键做好的客户端版本,选择`导出整合包`
![](/assets/img/docs/serverpack/1.png)
![](/assets/img/docs/serverpack/img1.png)
选择导出为`服务器自动更新整合包`
![](/assets/img/docs/serverpack/1-1.png)
![](/assets/img/docs/serverpack/img2.png)
填写整合包信息,整合包下载链接前缀如何填写请看下文
![](/assets/img/docs/serverpack/1-2.png)
![](/assets/img/docs/serverpack/img3.png)
选择需要包含在整合包内的文件后将产生整合包压缩文件
@ -27,21 +30,22 @@ HMCL 需要服务器管理员额外提供一个 HTTP 服务器(只需要能提
接着创建一个全新的空文件夹,将启动器复制进去
![](/assets/img/docs/serverpack/1-3.png)
![](/assets/img/docs/serverpack/img4.png)
运行启动器,并导入刚才导出的整合包,导入完成后,这个文件夹(这里叫“新整合包”)可以打包发给玩家。
## 第三步,部署整合包更新服务器
## 第三步:部署整合包更新服务器
你可以借助 Apache、Nginx 等支持静态文件的 HTTP 服务器软件提供文件。首先,决定好整合包下载链接前缀,比如我希望 HMCL 从远程服务器的 http://www.site.com/modpack 目录下存放整合包的更新信息,则在之前导出整合包的整合包下载前缀中填写 http://www.site.com/modpack。
![](/assets/img/docs/serverpack/1-4.png)
![](/assets/img/docs/serverpack/img5.png)
上图为导出的服务器自动更新整合包压缩文件的内容,你需要将这个整合包解压到 http://www.site.com/modpack 下。也就是说,从 http://www.site.com/modpack/server-manifest.json 这个链接下载下来的文件必须和上图中整合包压缩文件中的 server-manifest.json 文件一致并且http://www.site.com/modpack/overrides 是一个文件夹,里面存放了整合包文件,比如:
![](/assets/img/docs/serverpack/1-6.png)
![](/assets/img/docs/serverpack/img6.png)
整合包压缩文件 test.zip/overrides/mods/Advancement_Book-1.12-1.0.3.jar 文件必须可以从 http://www.site.com/modpack/overrides/mods/Advancement_Book-1.12-1.0.3.jar 该目录下载下来,且文件内容一致。那么至此更新服务器就部署完成了。
## 第四步更新整合包
## 第四步更新整合包
如果你需要更新整合包,那么将新的整合包经过第一步导出新的整合包压缩文件,并解压到类似 http://www.site.com/modpack 文件夹下即可完成新整合包的部署。

45
_plugins/auto-alert.rb Normal file
View File

@ -0,0 +1,45 @@
require "nokogiri"
Jekyll::Hooks.register [:pages, :documents], :post_convert do |doc|
next unless doc.output_ext == ".html"
site = doc.site
next unless site.data["plugins"]
alert_type = site.data["plugins"]["auto_alert"]
next unless alert_type
fragment = Nokogiri::HTML::DocumentFragment.parse(doc.content)
# 遍历 HTML 中的所有 blockquote 标签
fragment.css("blockquote").each do |item|
# 找出第一个子节点,用于判断是否含有 [!type] 标记
first_child = item.at_css("*:first-child")
next unless first_child
next unless first_child.name == "p"
text = first_child.text.downcase
# 遍历所有 alert 类型
alert_type.each do |type, data|
# 情况一:完整匹配 [!type] 形式 <p>[!NOTE]</p>
if text == "[!#{type}]"
# 将 alert 类型对应的 class 加入 blockquote
item['class'] = [item['class'], data["class_name"]].compact.join(" ")
# 将 <p> 替换为 <div> 并插入标题
first_child.name = "div"
first_child.inner_html = "<strong>#{data["title"]}</strong>"
break
# 情况二:段落以 [!type]\n 开头 <p>[!NOTE]\n\n other content</p>
elsif text.start_with? "[!#{type}]\n"
# 将 alert 类型对应的 class 加入 blockquote
item['class'] = [item['class'], data["class_name"]].compact.join(" ")
# 在原段落前插入标题 <div><strong>提示</strong></div><p>[!NOTE]\n\n other content</p>
first_child.add_previous_sibling "<div><strong>#{data["title"]}</strong></div>"
# 移除段落内容开头的 [!type]\n <div><strong>提示</strong></div><p>\n other content</p>
first_child.content = first_child.content.sub(/\A#{Regexp.escape("[!#{type}]\n")}/i, "")
break
end
end
end
doc.content = fragment.to_html
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -13,13 +13,8 @@ author: wifi-left
> You can also submit your suggestions here.
<!----{{ '>' }}
{: .notice--info }
<!---->
<!--{% comment %}-->
> [!NOTE]
> <!--{% endcomment %}-->
> <!----{{ '>' }} **注意** <br> {{ '<' }}!---->
> 如果您遇到 BUG请及时在 [HMCL/issues](https://github.com/HMCL-dev/HMCL/issues) 发送反馈。\
> 您也可以在这里提交您的建议。
<!----{{ '>' }}
{: .notice--info }
<!---->