Virtual Host Command Plugin

你有没有想过为同一个 Minecraft/Bukkit 服务器拥有不同的域名/子域名,并且根据域名为玩家提供不同的设置?这个插件有点像 Apache 虚拟主机,用于 Minecraft 服务器。

资源图片
# Bukkit/Minecraft 虚拟主机命令插件 你是否想过使用相同的 Minecraft/Bukkit 服务器拥有不同的域名/子域名,并根据域名来提供不同的设置? 这个插件有点像 apache 虚拟主机,它检测玩家使用的 Minecraft 服务器主机名 (CNAME)。你可以配置根据主机名在玩家加入服务器时运行哪些命令。 例如,你可以拥有一个带有 multiverse 和子域名的服务器 hub.example.com 和 pvp.example.com,然后根据玩家用于连接服务器的域名,直接将他们发送到 hub-world 或 arena-world。 > **注意:** **geyser** 代理的 Bedrock 版本在加入时不会提供主机名 - 因此它不适用于 vhost。 它只提供 IP 地址,所以你需要为通过 geyser/代理连接的每个域名使用不同的 IP 地址。 > **修复**:将以下内容添加到你的 geyser config.yml 中: # 转发 Bedrock 客户端用于连接的 hostname 到 Java 服务器 # 这旨在用于代理上的强制主机 forward-hostname: true > **注意:** 我们严重依赖提供的主机名。 这并非总是能在 PingServerList 事件中给出,因此对于所有服务器实现,**motd** 和 **icon** 每 vhost 不一定总是有效。 对于 paper-mc,我们添加了一个解决方法来获取用于 ping 的主机名。 以下是一个示例,显示了同一 IP 地址上运行的四个 vhost,但通过不同的 CNAME 使用不同的 vhost 访问: ![Minecraft 服务器列表示例](docs/example-server-list.png?raw=true "Minecraft 服务器列表示例") ### 更新 0.9.2 - 进行了次要修复、清理和维护 - 添加了 *ifInWorld* 和 *ifNotInWorld* 条件 (请参见示例配置) ### 更新 0.9.3 - 进行了小幅修复 - 为 vhosts 添加了 *motd* 和 *icon* 配置 (请参见示例配置) ## 示例配置 参见 *plugins/VirtualHostCommandPlugin/config.yml* 中的 up2date 文件 # VirtualHostCommand bukkit 插件的示例配置文件 # 位置: plugins/VirtualHostCommandPlugin/config.yml vhosts: host_example: # 主机名将使用 starts-with 方式再次与加入的主机名匹配,因此也支持部分匹配 # 您也可以添加端口,sub.domain.com:port # 它是强制性的,并且始终不区分大小写 hostname: example.com # (可选) 仅在玩家加入此世界(们)时才运行 ifInWorld: "world_some_regex" # (可选) 仅当玩家未加入此世界(们)时才运行 # 如果 ifInWorld 和 ifNotInWorld 都存在,则它们必须都为 true ifNotInWorld: "world_some_regex" # (可选) 此 vhost 的 MOTD # 注意:这只有在你的服务器实现返回 ping 事件中的主机名时才有效,很多服务器都没有 :( # 对于 paper-mc,我们添加了一个解决方法来通过反射获取通过 ping 的 vhost 主机名。 motd: "一些色彩鲜艳的 MOTD 服务器消息\n如果喜欢可以多行!" # (可选) 服务器图标文件名,格式如 server-icon.png,相同根目录 # 注意:对于 'motd' 配置选项,同样适用上述限制 icon: server-icon-example.png # 如果通过此主机名加入时要执行的命令列表 commands: # 以下占位符允许使用: # %player% , %hostname% 和 %port% - some command ... - another cmmand with %player% to replace with player name - msg %player% haha it works from %hostname% host_example2: # 示例采用 IP hostname: "123.45.67.89" commands: - some command ... - another cmmand with %player% to replace with player name - msg %player% haha it works host_hub: hostname: hub.myworld.com ifNotInWorld: "^world_hub" commands: - gamemode %player% survival - msg %player% crazy shit - mv tp %player% world_hub 参见 https://github.com/cgaffga/mc-vhost/tree/main/docs ## 源代码 源代码可在 https://github.com/cgaffga/mc-vhost/ 上找到 ## 下载 * 构建在 https://github.com/cgaffga/mc-vhost/tree/main/dist/ * Spigot https://www.spigotmc.org/resources/virtualhostcommandplugin.113311/ * Bukkit https://legacy.curseforge.com/minecraft/bukkit-plugins/virtualhostcommandplugin * Modrinth https://modrinth.com/mod/virtual-host-command-plugin