Skip to content

Repository files navigation

RedEdit

The goal of this project is to abstract the network and simplify complex instructions. RedEdit allows for cross server code execution and data synchronization. This allows for new server instances (for load balancing) to be started on an as needed bases, each with the same data set and functionality. All servers within a server group will serve the same function (this can be configured in the config.yml).

Redis is used for cross server code execution. This project currently supports Spigot/Bungee network, but can be ported to other platforms. Objects are serialized and compressed when transmitted using LZ4.

Misc functionality:

  • Player tracking / teleporting between nodes / user configs.
  • Dynamic rendering based on server load
  • Task scheduling

TODO:

  • Port to sponge/lily
  • Fully abstract connected players
  • Scripting support

Example

Registering a remote call is easy; just create the object. The call can be received by any server which has it registered.

// Create your task during startupRemoteCall<Result, Argument> task = newRemoteCall<Result, Argument>() {
@OverridepublicStringrun(Serverserver, Integerarg) {
// This task runs on the target serverif (somecondition) {
// Return a resultreturnsomeresult;
}
// Or don't return a resultreturnnull;
}
// You can set a custom serializer if you want// Otherwise it will use the default serializer
}.setSerializer(someserializer);

You can then use call it whenever you want:

intserverGroup = 0; // Target all groupsintserverId = 0; // Target all servers in that groupArgumentarg = <someargument>;
// Provide a runnable if you want to do something with the result.task.call(serverGroup, serverId, arg, newRunnableVal2<Server, String>() {
@Overridepublicvoidrun(Serverserver, Resultresponse) {
// Do something with the result or server?
}
});
// Use `collect` or `any` instead of `call` to pass a result back.

Misc classes

Networknetwork = RedEdit.get().getNetwork(); // Get the connected players/serversPlayerListenerplayerListener = RedEdit.get().getPlayerListener(); // Schedule a task on player join (timeout: 10s)TeleportUtilutil = RedEdit.get().getTeleportUtil(); // Various teleportation functionRedEdit.get().getUserConfig(uuid); // Get a player's homesRedEdit.get().getWarpConfig(); // Get the warps

About

[Java] Cross server code execution using redis and object serialization

Resources

Stars

12 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages