# 资源包分发

**ItemsAdder** 本身提供了多种资源包分发方式，但在本教程笔者只介绍以下两种：

* 本地对外分发。
* 直链分发。

由于 **Dropbox、Onedrive** 等在国内要么无法访问要么速度不稳定，因此不是理想的资源包分发选择方式。

**两个方法各有优缺点：**

* 本地对外分发需要服务器本地有额外 **1** 个端口用于资源包分发。如果你购买的是面板服，那么通常这是受限的，而直链分发并不需要这一点。
* 本地对外分发本身会占用一些服务器带宽等资源，而直链分发不会占用。
* 每次服务器资源包更新，直链分发需要服主手动上传新的资源包，并修改新的直链地址。

在你的玩家数量没有太多，又有足够的服务器资源时，笔者仍推荐本地对外分发，特别是前期你的服务器玩家根本没有那么多，而此时服务器需要大量内容更新而资源包更新又因此十分频繁，这会让你省去很多事情。

无论你选择哪一个资源包分发方式，首次启动后都要求你修改 **config.yml** 内的内容。

### 本地对外分发

```
resource-pack:
  hosting:
    no-host:
      enabled: false
    auto-external-host:
      enabled: false
    self-host:
      enabled: true # <----- 如果你选择本地资源包分发，请将这里设置为 true。
      server-ip: '127.0.0.1' # <----- 请将这里设置为你的服务器的外网IP。
      pack-port: 8163 # <----- 请将这里设置为资源包分发的端口。
    external-host:
      enabled: false
      url: ''
```

按上示例进行修改，请注意：

* `pack-port` 指示的端口值，在非局域网条件下必须仍能访问到，也就是外网端口。很多 **VPS** 租赁商不是开放全端口，你往往需要手动修改这里的值。

修改完以后输入 `/iareload、/iazip` 指令后即可。

### 直链分发

什么？你跟我说不是有 `auto-external-host`（自动直链分发）吗？很抱歉，在国外，速度稳不稳定无法保证。

在你每次输入 `/iazip` 后（或者首次启动插件），**ItemsAdder** 都会在 `resource_pack` 文件夹下生成 `pack.zip` 的文件，请将它上传到你的对象存储（或者支持直链的网盘等等），并获取到直链地址，填入到 `external-host` 下的 `url` 选项中，并将 `enabled` 改为 true。

请注意：

* 百度网盘、阿里网盘等获取到的分享地址不是直链地址，尽管你是通过右键普通下载获得到的地址。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.superiormc.cn/itemsadder-doc/shou-ci-shi-yong/zi-yuan-bao-fen-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
