Git Product home page Git Product logo

mc-repeater's Introduction

MC-Repeater

A chat relay between Minecraft server and IRC with no mods.

Features

  • No mods needed
  • Support Java and Bedrock servers, vanilla and modded servers
  • Can be run on Windows, Linux and macOS

Minecraft server support

Java Edition:

Bedrock Edition:

Chat bot support

Messages can be forwarded

  • Chat
  • /say message
  • Server start up / shutdown
  • Player join / leave
  • Player death
  • Achievement

Usage

  1. Install NodeJS.
  2. Install MC-Repeater globally using npm install -g mcrepeater.
  3. In your Minecraft server directory, create a bash / batch file (e.g. start.sh or start.bat), then write your Minecraft start command in it. For Java servers, it looks like:
    java -Xmx1024M -Xms1024M -jar server.jar nogui
    
    For Bedrock servers, it's usually:
    LD_LIBRARY_PATH=. ./bedrock_server
    
  4. Create config.json in the same directory and write configurations in it.
  5. Run MC-Repeater using the command mcrepeater. You don't need to start Minecraft server manually because it's automatically started by MC-Repeater.

Configurations

Examples

Here's some simple config.json examples:

Zulip

{
  "serverStart": "start.sh",
  "serverType": "java",
  "bots": [
    {
      "botType": "zulip",
      "botHost": "example-org.example.com",
      "botName": "[email protected]",
      "channel": "example-stream/example-topic",
      "key": "your-bot-api-key"
    }
  ],
  "language": "en-us"
}

Koishi

{
  "serverStart": "start.sh",
  "serverType": "java",
  "bots": [
    {
      "botType": "koishi",
      "botHost": "bot.your-host.com",
      "channel": "your-channel",
      "key": "your-secret-key"
    }
  ],
  "language": "en-us"
}

Parameters

Minecraft server configurations:

  • serverStart: Path to your Minecraft server starting bash / batch file.
  • serverType: Type of your server. Can be java, paper or bedrock.
  • autoRestart (optional): A boolean value which determine whether the MC-Repeater will auto restart your server after your server crashed (default: false).

Chat bot configurations:

An array for bot configurations:

  • botType: Your bot type which determines how the message will be sent. Can be zulip or koishi or local (for debugging).
  • botHost: Hostname of your bot server.
  • botName: User name of your bot. For Zulip, it's your bot e-mail address. It is not needed for Koishi.
  • channel: The channel you want to send information to. For Zulip, it's "example-stream/example-topic".
  • key: The API key or secret key for your bot. Usually provided by your bot server.
  • language: Your language. Currently support en-us and zh-cn.

Network optimization:

  • throttleInterval (optional): The minimum interval at which messages are sent (default: 0).
  • offlineTimeout (optional): The minimum time to determine a player is offline (default: 0).

Custom messages:

  • customMessage (optional): Custom messages to override original messages

    Example of customMessage:

    "customMessage": {
      "join": "Ob $1 joined the game.",
      "leave": "Ob $1 left the game.",
      "advancements": {
        "Diamonds!": "Diorites!"
      },
      "deathReasons": {
        "magic": "$1 was killed by mogic!",
      },
      "mobs": {
        "Ender Dragon": "Dragon Bro"
      }
    }

Message mask:

  • messageMask (optional): Block certain type of messages.

    Message Type Description
    join The message of a player joined the game
    leave The message of a player left the game
    start Server start message
    stop Server stop message
    chat Chat message from players
    server Chat message from the server
    advancement The message of a player achieved an advancement
    death Player death message

    Example of messageMask:

    messageMask: ["join", "leave", "death"]

License

Licensed under the MIT License.

mc-repeater's People

Contributors

kouchya avatar nn708 avatar shigma avatar track07-cda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

koishijs

mc-repeater's Issues

游戏内截图转发

Minecraft 中当玩家按下 F2 时默认行为是截图。我觉得可以借助内置的截图功能,加入快捷按键使得截图可以转发到群内。

推送信息节流机制

为了防止大量的网络请求带来的性能损耗,建议对发送的信息进行节流。

具体实现:

  • 在 config 中加入 throttleInterval 选项,用于表示最小发送信息的间隔
  • 加入一个全局字符串 messageBuffer,初始化为空串。
  • 当要发送某个信息时,将要发送的文本接在 messageBuffer 之后。
  • 设定一个定期任务,每隔 throttleInterval 秒检查一次 messageBuffer 中的文本,如果非空则发送并清空之。

Errors with reading the log file

Platform: Windows 10 x64

Error discription: Sometimes the program crashed when it tried to read the log file.

Error message:

index.js:17

[Error: EBADF: bad file descriptor, read] {
  errno: -4083,
  code: 'EBADF',
  syscall: 'read'
}

掉线防抖机制

由于网络或游戏机制等原因,游戏中可能会出现不必要的连续下线和上线提示。建议加入掉线防抖机制。

具体实现:

  • 在 config 中加入 offlineTimeout 选项,用于表示最小界定为下线的时间
  • 加入一个全局数组 offlinePlayers,其元素是下线玩家的 id。
  • 当某位玩家发生下线事件时,向数组中添加玩家 id 并等待 offlineTimeout 秒,如果期间发生了同一玩家上线事件,则清除此 id。等待结束后检查数组中是否有此 id,如果有则删去此 id 并向 bot 服务器发送此下线事件。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.