https://github.com/josscoder/redisbridge
RedisBridge is a Nukkit/WaterdogPE plugin for auto server registration and communication
https://github.com/josscoder/redisbridge
bedrock minecraft network nukkit redis redisbungee waterdogpe
Last synced: 9 months ago
JSON representation
RedisBridge is a Nukkit/WaterdogPE plugin for auto server registration and communication
- Host: GitHub
- URL: https://github.com/josscoder/redisbridge
- Owner: Josscoder
- License: mit
- Created: 2025-07-02T02:04:40.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-07-21T16:47:33.000Z (11 months ago)
- Last Synced: 2025-07-21T18:51:12.700Z (11 months ago)
- Topics: bedrock, minecraft, network, nukkit, redis, redisbungee, waterdogpe
- Language: Java
- Homepage:
- Size: 987 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**RedisBridge** is a complete rewrite of my previous plugin [JBridge](https://github.com/JossArchived/JBridge), developed for Nukkit and WaterdogPE. It provides automatic server registration, player management, and seamless communication between backend servers and the proxy.
# ⚙️ Available Commands
RedisBridge includes ready-to-use commands for your WaterdogPE proxy or Nukkit backend servers:
- `/lobby`
Teleports the player to an available lobby instance using the `LOWEST_PLAYERS` strategy to avoid overloading a single lobby while keeping activity balanced.
- `/transfer `
Transfers the player to a specific instance if available. Useful for networks with multiple game modes.
- `/whereami`
Displays information to the player showing which instance and proxy they are currently in.
# 📡 Instance Management Usage
RedisBridge includes a **distributed instance discovery and selection system** for minigame servers, lobbies, or backend servers using Redis and a low-latency distributed cache.
Each server instance sends **automatic heartbeats** via `InstanceHeartbeatMessage` containing:
- `id` (unique identifier)
- `group` (e.g., `lobby`, `solo_skywars`, `duels`)
- `players` (current online players)
- `maxPlayers` (maximum capacity)
- `host` and `port`
This allows other servers and the proxy to know in real time which instances are available, their capacity, and their status.
The `InstanceManager`:
- Uses a local cache with a 10-second expiration to keep instance state updated efficiently.
- Allows you to:
- Retrieve instances by ID (`getInstanceById`)
- Retrieve all instances in a group (`getGroupInstances`)
- Get total player counts or per group (`getTotalPlayerCount`, `getGroupPlayerCount`)
- Get total maximum player capacity or per group (`getTotalMaxPlayers`, `getGroupMaxPlayers`)
Provides **automatic available instance selection** using different strategies:
- `RANDOM`: Selects a random instance in the group.
- `LOWEST_PLAYERS`: Selects the instance with the fewest players.
- `MOST_PLAYERS_AVAILABLE`: Selects the instance with the most players while still having available slots.
Example:
```java
InstanceInfo instance = InstanceManager.getInstance().selectAvailableInstance("lobby", InstanceManager.SelectionStrategy.LOWEST_PLAYERS);
if (instance != null) {
// Connect player to this instance
}
```
This system enables your network to distribute players dynamically without relying on a heavy centralized matchmaking server.
# 🚀 Communication Usage
RedisBridge simplifies inter-server communication over Redis, enabling you to publish and subscribe to messages seamlessly between your proxy and backend servers.
## How it works?
- Uses Redis Pub/Sub on a single channel (redis-bridge-channel) for all message transmission.
- Messages are serialized in JSON and identified using their type field.
- Each message type can have:
- A registered class (MessageRegistry) for deserialization.
- An optional handler (MessageHandlerRegistry) for automatic processing when received.
- Includes default messages for instance heartbeat and shutdown announcements to enable automatic instance tracking.
## Publishing Messages
To send a message to all connected instances:
```java
YourCustomMessage message = new YourCustomMessage();
// fill your message data here
redisBridge.publish(message, "sender-id");
```
## Handling Incoming Messages
- Register your message type:
```java
MessageRegistry.register("your-message-type", YourCustomMessage.class);
```
- Register your message handler:
```java
MessageHandlerRegistry.register("your-message-type", new MessageHandler() {
@Override
public void handle(YourCustomMessage message) {
// handle your message here
}
});
```
## License
**RedisBridge** is licensed under the [MIT License](./LICENSE). Feel free to use, modify, and distribute it in your projects.