矩阵桥接

矩阵桥接

将Minecraft和Matrix聊天连接起来!

🎉 26.1/26.2 的测试版现已可用

👉 如果您需要任何帮助,请到我们的 Matrix 房间 联系我们

🔥 需要 Forge 版本?看看 MC Matrix Bridge!

⚠️ v1.5 及更高版本不再需要 Fabric Language Kotlin (FLK)。v1.4 及更早版本与高于 1.13.3+kotlin.2.1.21 的 FLK 版本不兼容

☕ 'Better Than Adventure' 版本需要 Java 11 或更高版本。v1.4 及更早版本需要为 Fabric Language Kotlin (FLK) 进行依赖覆盖。更多信息见下文。

Matrix Bridge

Matrix Bridge 允许用户将 Minecraft 服务器的聊天与 Matrix 房间桥接。此模组让 Matrix 用户无需登录 Minecraft 世界即可与 Minecraft 玩家交谈。

此桥接会发送服务器启动、服务器停止、玩家加入、玩家离开、玩家死亡和玩家聊天消息。此桥接还包含桥接命令 '!list'、'!ping' 和 '!invite',分别允许 Matrix 侧用户获取玩家列表、ping 服务器以及将玩家加入白名单。

此模组使用基于密码的登录,并支持加密房间和会话验证。此外,还提供基于 YAML 的配置文件,并支持多种数据库,包括 H2(默认)、SQLite、MariaDB 和 PostgreSQL。

此模组将根据请求移植到不同的游戏版本。如果您希望提交反馈、请求新的移植版本或需要一般帮助,请加入我们的支持房间。

Matrix Bridge 使用 Trixnity Matrix SDK,并依赖 Fabric Language Kotlin 模组。

配置

剧透

config.yaml

# +---------------------------------------------------+
# |                                                   |
# |            Matrix Bridge Configuration            |
# |                                                   |
# +---------------------------------------------------+
# Please ensure that all values follow the YAML standard.
# Indentation is important! Tabs are not allowed.
# Refer to "https://www.tutorialspoint.com/yaml/" for a detailed explanation.
# 
# Improperly set values will default. Integers -> 0, Booleans -> false, Verify Type -> DISABLED, Database Type -> H2.
# Please ensure your values are set properly!
# 
# This file is never modified. This file is only written to when it is being generated.
# This file is comment-safe. They will not disappear.
# 
# If you need assistance, please join our Matrix room "https://matrix.to/#/#sophie.projects:aenead.net".
# Thank you! <3

# DO NOT MODIFY. Used to detect when you need to update config.
version: 2

# Reveals Trixnity log messages. Useful for debugging.
verbose: false

# +---------------------------------------------------+
# |                                                   |
# |                      Account                      |
# |                                                   |
# +---------------------------------------------------+
# Settings used to sign in to the bot account.
account:
  
  # Synapse URL. Supports delegation.
  homeserver: "https://matrix.example.org"
  
  # Account login username. Localpart of user's MXID.
  username: "user"
  
  # Account login password. Does not support tokens or SSO.
  password: "pass"
  
  # Bridge session device name.
  device_name: "Matrix-Minecraft Bridge"
  
  # Internal ID of room to send messages to.
  room: "!sdfDsdfsA:matrix.example.org"

# +---------------------------------------------------+
# |                                                   |
# |                    Verification                   |
# |                                                   |
# +---------------------------------------------------+
# Settings used to enable session verification and encryption.
verification:
  
  # Either KEY, PASSPHRASE or DISABLED. All other values will be rejected.
  type: "KEY"
  
  # Token (either a key or passphrase) to verify bridge session.
  token: "AaAA aaAa AAaa..."

# +---------------------------------------------------+
# |                                                   |
# |                      Database                     |
# |                                                   |
# +---------------------------------------------------+
# Settings used for database configuration.
database:
  
  # Either H2, SQLITE, MARIADB or POSTGRESQL. All other values will be rejected. Default is H2.
  type: "H2"
  
  # Name of database. If type is H2 or SQLITE, represents file name. Otherwise, represents database to connect to.
  name: "database"
  
  # Host and port to connect to database.
  hostname: "localhost:3306"
  
  # Database login username. Only used with MARIADB and POSTGRESQL.
  username: "user"
  
  # Database login password. Only used with MARIADB and POSTGRESQL.
  password: "pass"

# +---------------------------------------------------+
# |                                                   |
# |                      Commands                     |
# |                                                   |
# +---------------------------------------------------+
# Settings for bridge commands.
commands:
  
  # '!list' command. Lists online players. Supported placeholders: %players%
  list:
    format: "📜 Online players: %players%"
    enabled: true
  
  # '!ping' command. Bridge prints message to ensure connection.
  ping:
    format: "🏓 Pong!"
    enabled: true
  
  # '!invite' command. Whitelists a player. Supported placeholders: %player%
  invite:
    format:
      success: "🔵 '%player%' has been whitelisted!"
      error: "🔵 '%player%' could not be found. Usage: !invite <username>"
      already: "🔵 '%player%' is already whitelisted!"
    enabled: false
  
  # Message sent to Matrix when a performed command is invalid. Supported placeholders: %commands%
  invalid_command: "⛔ Command not found! Available commands: %commands%"
  
  # Message sent to Matrix when a performed command is disabled.
  disabled_command: "⛔ Command disabled! Please contact an administrator."

# +---------------------------------------------------+
# |                                                   |
# |                      Messages                     |
# |                                                   |
# +---------------------------------------------------+
# Message formats! Some messages use placeholders. Available placeholders are stated in the comments.
# Available placeholders: %player%, %message%, %commands%
messages:
  
  # Message sent when the server starts.
  start:
    format: "❇ Server started"
    enabled: true
  
  # Message sent when the server stops.
  stop:
    format: "🛑 Server stopped"
    enabled: true
  
  # Chat message format as viewed in Minecraft. Supported placeholders: %player%
  chat_matrix_to_minecraft:
    format: "[§e%player%§r] "
    enabled: true
  
  # Chat message format as viewed on Matrix. Supported placeholders: %player%
  chat_minecraft_to_matrix:
    format: "<%player%> "
    enabled: true
  
  # Message sent to Matrix when a player joins the server. Supported placeholders: %player%
  player_join:
    format: "🔹 %player% joined the game"
    enabled: true
  
  # Message sent to Matrix when a player quits the server. Supported placeholders: %player%
  player_quit:
    format: "🔹 %player% left the game"
    enabled: true
  
  # Message sent to Matrix when a player dies. Supported placeholders: %message%
  player_death:
    format: "🪦 %message%"
    enabled: true
  
  # Message sent to Matrix when a player makes an advancement. Supported placeholders: %player%, %advancement%
  player_advancement:
    format: "🎉 %player% has made the advancement '%advancement%'!"
    enabled: true

Better Than Adventure

请确保您使用的是 Java 11 或更高版本,因为此模组在 Java 8 上会崩溃。

截至 2025-08-06,需要为 Fabric Language Kotlin (FLK) 进行依赖覆盖。FLK 需要 Fabric Loader 0.16.9+,而 BTA Babric 无法使用该版本。需要如此新版本的 FLK 才能支持最新的 Matrix 功能(例如房间 v12)。

请将以下文件放入服务器的 config 目录中。

剧透

fabric_loader_dependencies.json

{
  "version": 1,
  "overrides": {
    "fabric-language-kotlin": {
      "-depends": {
        "fabricloader": "IGNORED"
      }
    }
  }
}