适用于 Bukkit/Minecraft 的虚拟主机命令插件
是否想过为同一个 Minecraft/Bukkit 服务器设置不同的域名/子域名,并根据玩家加入时使用的域名提供不同的设置?
此插件类似于 Apache 的虚拟主机功能,它会检测玩家连接时使用的 Minecraft 服务器主机名(CNAME)。你可以根据主机名配置玩家加入服务器时执行的命令。例如,你可以拥有一个运行 Multiverse 的服务器,并设有 hub.example.com 和 pvp.example.com 两个子域名,然后根据玩家连接时使用的域名,直接将玩家传送到大厅世界或竞技场世界。
注意: 使用 Geyser 的基岩版代理在加入时不会提供主机名——因此虚拟主机功能对 Geyser 无效。它仅提供 IP 地址,因此你需要为每个通过 Geyser/代理连接的域名单独分配一个 IP 地址。
修复 请在你的 geyser config.yml 中添加以下内容:
# 转发基岩客户端用于连接的原始主机名到 Java 服务器
# 此设置旨在配合代理上的强制主机名使用
forward-hostname: true
注意: 我们严重依赖所提供的主机名。这在 PingServerList 事件中并不总是可用,因此 MOTD 和 图标 按虚拟主机配置的功能在所有服务器实现中并不总能正常工作。对于 PaperMC,我们添加了一个变通方法以获取用于 ping 请求的主机名。
以下是四个虚拟主机在同一服务器上运行且使用相同 IP 地址但通过不同 CNAME 访问的示例:

更新 0.9.2
- 小修复、清理、维护
- 添加了 ifInWorld 和 ifNotInWorld 条件(参见示例配置)
更新 0.9.3
- 小修复
- 为虚拟主机添加了 motd 和 icon 配置选项(参见示例配置)
示例配置
请参阅 plugins/VirtualHostCommandPlugin/config.yml 中的最新文件
# VirtualHostCommand bukkit 插件的示例配置文件
# 位置:plugins/VirtualHostCommandPlugin/config.yml
vhosts:
host_example:
# 主机名通过“startsWith”方式与加入时的主机名进行匹配,因此部分匹配也有效
# 你也可以添加端口,例如 sub.domain.com:port
# 此为必填项,且不区分大小写
hostname: example.com
# (可选)仅当玩家加入指定世界(s)时才执行
ifInWorld: "world_some_regex"
# (可选)仅当玩家未加入指定世界(s)时才执行
# 如果同时存在 ifInWorld 和 ifNotInWorld,则两者都必须为真
ifNotInWorld: "world_some_regex"
# (可选)此虚拟主机的 MOTD
# 注意:这仅在服务器实现在 ping 事件中返回主机名时才有效,许多实现并不会这样做 :(
# 对于 paper-mc,我们通过反射添加了一个变通方法来获取 ping 的虚拟主机主机名。
motd: "some colorfull MOTD server message\nmultiline if you like!"
# (可选)服务器图标文件名,格式如 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
参见
源码
源代码可在 找到
下载
- 构建版本位于
- Spigot
- Bukkit
- Modrinth
Virtual Host Command Plugin for Bukkit/Minecraft
Ever thought of having different domains/subdomains for the same Minecraft/Bukkit server and depending on the domain a player joins offer different settings?
This plugin is a bit like apache virtual hosts, detecting the host name of the Minecraft server the player used (CNAMEs). You can configure what commands to run on joining the server depending on the host name. E.g. you can have a server with multiverse and subdomains hub.example.com and pvp.example.com and then send the player directly to the hub-world or the arena-world depending on the domain they used to connect to the server.
Note: Bedrock proxy with geyser does not supply the host name on join – so it's not working for vhosts. It only supplies the IP address, so you need a different IP address for each domain connecting via geyser/proxy.
FIX add the following to you geyser config.yml:
# Forward the hostname that the Bedrock client used to connect over to the Java server
# This is designed to be used for forced hosts on proxies
forward-hostname: true
Note: We heavily rely on the supplied hostname. This is not always given in PingServerList list event, so motd and icon per vhost does not always work on all server implementations. For paper-mc we added a workaround to get the hostname used for the ping.
Here is an example of four vhosts running on the same server with the same IP address but accessed using different vhosts via different CNAMEs:

Update 0.9.2
- minor fixes, cleanup, housekeeping
- added ifInWorld and ifNotInWorld conditions (see example config)
Update 0.9.3
- small fixes
- added motd and icon config for vhosts (see example config)
Example Config
see up2date file in plugins/VirtualHostCommandPlugin/config.yml
# Example config file for VirtualHostCommand bukkit plugin
# Location: plugins/VirtualHostCommandPlugin/config.yml
vhosts:
host_example:
# the hoostname is matched agains the joining hostname via starts-with, so parts work as well
# you can also add the port, sub.domain.com:port
# it's mandatory, and always case-insensitive
hostname: example.com
# (optional) only run if player joined this world(s)
ifInWorld: "world_some_regex"
# (optional) only run if player did not join this world(s)
# if ifInWorld and ifNotInWorld present, they must be both true
ifNotInWorld: "world_some_regex"
# (optional) MOTD for this vhost
# NOTE: this only works if you server implementation returns a hostname in the ping event, many don't :(
# for paper-mc we have added a workaround to fetch the vhost hostname pinged via reflection.
motd: "some colorfull MOTD server message\nmultiline if you like!"
# (optional) server icon filename, format like server-icon.png, same root directory
# NOTE: same restrictions as for 'motd' config option apply
icon: server-icon-example.png
# List of commands to be executed if joining via this hostname
commands:
# he following placeholders are allowd:
# %player% , %hostname% and %port%
- some command ...
- another cmmand with %player% to replace with player name
- msg %player% haha it works from %hostname%
host_example2:
# example with an 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
see
Source
Source code can be found at
Download
- Builds in
- Spigot
- Bukkit
- Modrinth
评论 0
登录后参与评分
还没有评论,来抢沙发吧