Redis based Server Data Manager
Supported versions
Tags
Tags
None
Redstone - Redis based Server Data Manager
Introduction
Hi guys! Here is my Redis based Server Data Manager for large multi-server networks.

Features
  • Blazingly Fast - Based off Redis, making it incredibly fast and scales to hundreds of bukkit game servers.
  • Dynamic Bungeecord Bindings - When a server goes up or down, it is dynamically modified on the bungeecord. This could be useful for large minigame networks that dynamically create servers.
  • Extensive API - Ability to create an expansive list of addons (Queue's, Hub-Balancer, etc)
Pricing
$20USD for just the jar with updates,
$40USD for source with updates.

Proof of Ownership
Code:
package io.github.thatkawaiisam.redstone.bukkit;

import io.github.thatkawaiisam.configs.BukkitConfigHelper;
import io.github.thatkawaiisam.redstone.shared.*;
import io.github.thatkawaiisam.redstone.shared.redis.RedisCredentials;
import io.github.thatkawaiisam.redstone.shared.redis.RedisHelper;
import io.github.thatkawaiisam.redstone.shared.server.RedstoneServer;
import io.github.thatkawaiisam.redstone.shared.server.ServerState;
import io.github.thatkawaiisam.utils.MessageUtility;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.Configuration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import redis.clients.jedis.Jedis;

import static io.github.thatkawaiisam.redstone.shared.server.ServerState.ONLINE;
import static io.github.thatkawaiisam.redstone.shared.server.ServerState.WHITELISTED;

@Getter @Setter
public class RedstoneBukkitPlugin extends JavaPlugin {

    /* Configuration Files */
    private BukkitConfigHelper redstoneBukkitConfig,
            redstoneServerConfig,
            redstoneRedisConfig;

    @Override
    public void onEnable() {
        /* Setup Configurations */
        redstoneBukkitConfig = new BukkitConfigHelper(this, "config", this.getDataFolder().getAbsolutePath());
        redstoneServerConfig = new BukkitConfigHelper(this, "server", this.getDataFolder().getAbsolutePath());
        redstoneRedisConfig = new BukkitConfigHelper(this, "redis", this.getDataFolder().getAbsolutePath());

        /* Configure Redstone Plugin Settings */
        new RedstoneConstants();
        loadPluginSettings(redstoneServerConfig.getConfiguration());

        /* Create Redstone Bukkit API */
        new RedstoneBukkitAPI(this);

        /* Start Redstone Shared */
        new RedstoneShared();

        /* Setup Redis Connection */
        loadRedisSettings(redstoneRedisConfig.getConfiguration());

        /* Setup Server Handler */
        RedstoneShared.setRedstoneServerHandler(new RedstoneServerHandler() {
            @Override
            public void addServer(RedstoneServer redstoneServer) {
                super.addServer(redstoneServer);
                /* Notify Online Staff */
                for (Player player : Bukkit.getOnlinePlayers()) {
                    if (player.hasPermission("Redstone.Add.Notify")) {
                        player.sendMessage(MessageUtility.formatMessage("&c[Redstone] &f" + redstoneServer.getServerID() + " has been added!"));
                    }
                }
            }
            @Override
            public void removeServer(RedstoneServer redstoneServer) {
                super.removeServer(redstoneServer);
                /* Notify Online Staff */
                for (Player player : Bukkit.getOnlinePlayers()) {
                    if (player.hasPermission("Redstone.Remove.Notify")) {
                        player.sendMessage(MessageUtility.formatMessage("&c[Redstone] &f" + redstoneServer.getServerID() + " has been removed!"));
                    }
                }
            }
        });

        /* Registered API's */
        new RedstoneSharedAPI(RedstoneShared.getRedstoneServerHandler());

        /* Execute Redstone Internal */
        Thread pubSubThread = RedstoneInternal.createPubSubThread(RedstoneShared.getRedisHelper(), new String[] {"Redstone-Delete", "Redstone-Add", "Redstone-StateChange"});
        RedstoneInternal.intialPayloadToRedis();
        RedstoneInternal.sendAddNotification();
        RedstoneInternal.fetchFromRedis();

        /* Add threads */
        RedstoneShared.getThreads().put("pubsub", pubSubThread);
        RedstoneShared.getThreads().put("payload", new PayloadThread(RedstoneShared.getRedisHelper()));
        RedstoneShared.getThreads().put("fetch", new FetchThread(RedstoneShared.getRedisHelper()));

        /* Start threads */
        RedstoneShared.startThreads();
    }

    @Override
    public void onDisable() {
        /* Stop Threads */
        RedstoneShared.stopThreads();

        /* Redis Resource */
        try(Jedis jedis = RedstoneShared.getRedisHelper().getPool().getResource()){
            /* Change the State to all of the servers */
            jedis.publish("Redstone-StateChange", RedstoneBukkitAPI.getCurrentServerName() + "|||" + ServerState.OFFLINE.getOrdinal());

            /* Remove server from Redis */
            jedis.del(RedstoneShared.KEY + RedstoneBukkitAPI.getCurrentServerName());
        }

        /* Send Notification to remove cached copy */
        RedstoneInternal.sendRemoveNotification();
    }

    private void loadRedisSettings(Configuration c) {
        RedstoneShared.setRedisHelper(
                new RedisHelper(
                        new RedisCredentials(
                                c.getString("Redis.IP"),
                                c.getString("Redis.Password"),
                                c.getInt("Redis.Port")
                        )
                )
        );
    }

    private void loadPluginSettings(Configuration c){
        RedstoneConstants.SERVER_NAME = c.getString("Server-Name");
        RedstoneConstants.SERVER_GROUP = c.getString("Server-Group");
        RedstoneConstants.SERVER_REGION = c.getString("Server-Region");
    }

    public static ServerState getCurrent(){
        return Bukkit.hasWhitelist() ? WHITELISTED : ONLINE;
    }
}

Configs
Code:
#Bukkit Stuff
Permissions:
  Add-Notify: "Redstone.Add.Notify"
  Remove-Notify: "Redstone.Remove.Notify"
  Change-Notify: "Redstone.Change.Notify"

#Bungeecord Stuff
Bungee-Dynamic: true
Code:
Redis:
  IP: localhost
  Port: 6379
  #Leave blank if no authentication is required.
  Password:
Code:
Server-Name: lobby-1

Server-Groups:
  - "NA"
  - "Lobbies"

APIs

Contact

Discord: ThatKawaiiSad#3881
Telegram: ThatKawaiiSam
Twitter: ThatKawaiiSam

I have also created a discord server to serve as an easier form of communication for updates and suggestions!
https://discord.gg/QAHPJBm

Author

Author
ThatKawaiiSam
Downloads
5
Type
Digital product
License duration
Unlimited
Price
20.00 USD
Views
975
First release
Last update
Rating
0.00 star(s) 0 ratings
Top
You need to upgrade!
Our dark style is reserved for our Premium members. Upgrade here.