2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-05-03 11:40:29 +00:00

1 Commits

Author SHA1 Message Date
1593c2d628 0.12.0 (#86)
## NOTES
data system shouldn't effect anybody, unless you do any direct query to
Redis query data, you should adapt the changes, by viewing classes
`ProxyDataManager` and `PlayerDataManager`

# Changes 
* RedisBungee is compiled with `java 17` now, Due java 11 support is
ending at end of September
* config version is now `2` which will reset your config if older
version
* Adventure API is included inside RedisBungee API
* new Language infrastructure for RedisBungee built-in messages #85
*commands not included yet*
* New data system which replaces Redis PubSub with Redis Streams *see
below*
* Ability to connect player to last server they where on using an config
option #84
* new environment variable `REDISBUNGEE_PROXY_ID` which can be set
before launch
* new environment variable `REDISBUNGEE_NETWORK_ID` which can be set
before launch
* RedisBungee requires redis version 6.2 or above  #88 
* Better command system
https://github.com/ProxioDev/RedisBungee/issues/93

## New data system
Due limitation of Redis PubSub in Cluster environment, Internals of
RedisBungee were changed to support Redis Streams
- Network Ids
  - networks ids used to group network proxies
    - example having 'test' network and 'main' network
- Networks in the same redis server / cluster share the same UUID cache
- Heartbeat system:
- RedisBungee old heartbeat system used hastset on redisbungee to store
the current unix time of the proxy to check what every proxy died or
not, now instead we publish the heartbeat using unix time, and online
count to proxy which proxy store it in their memory, which allow the
`get number of online players` to be faster than pooling whole list in
old data system.

- PubSub
- since redisbungee was initially designed with pubsub in mind,
registration no longer required now for event to fire, see the api
changes below.

## Commands System
* rewritten using [acf lib](https://github.com/aikar/commands) to be
platform independent
* new command `/rb` or `/redisbungee` with sub commands `help`, `info`,
'clean', 'show'.

* 'rb'
  * '/rb' and '/rb info'

![image](https://github.com/ProxioDev/RedisBungee/assets/34905970/70796ab0-b5fd-4578-8c93-c976e517df95)

  * '/rb show'
  

![image](https://github.com/ProxioDev/RedisBungee/assets/34905970/56332c37-701f-43e0-946b-6894b845fab3)

* configuration to disable or override each command from legacy to new
introduced one `/rb`
```yaml

# For redis bungee legacy commands
# either can be run using '/rbl glist' for example
# or if 'install' is set to true '/glist' can be used.
# 'install' also overrides the proxy installed commands
#
# In legacy commands each command got it own permissions since they had it own permission pre new command system,
# so it's also applied to subcommands in '/rbl'.
commands:
  # Permission redisbungee.legacy.use
  redisbungee-legacy:
    enabled: false
    subcommands:
        # Permission redisbungee.command.glist
        glist:
          enabled: false
          install: false
        # Permission redisbungee.command.find
        find:
          enabled: false
          install: false
        # Permission redisbungee.command.lastseen
        lastseen:
          enabled: false
          install: false
        # Permission redisbungee.command.ip
        ip:
          enabled: false
          install: false
        # Permission redisbungee.command.pproxy
        pproxy:
          enabled: false
          install: false
        # Permission redisbungee.command.sendtoall
        sendtoall:
          enabled: false
          install: false
        # Permission redisbungee.command.serverid
        serverid:
          enabled: false
          install: false
        # Permission redisbungee.command.serverids
        serverids:
          enabled: false
          install: false
       # Permission redisbungee.command.plist
        plist:
          enabled: false
          install: false
  # Permission redisbungee.command.use
  redisbungee:
    enabled: true
```

## API changes
- Kick api Deprecated: 
  - `kickPlayer(String playerName, String message) `
  - `kickPlayer(UUID playerUUID, String message) `

- newer where added using adventure api:
  - `kickPlayer(String playerName, Component message) `
  - `kickPlayer(UUID playerUUID, Component message) `

-  PubSub registration api Deprecated:
```java
/**
     * Register (a) PubSub channel(s), so that you may handle PubSubMessageEvent for it.
     *
     * @param channels the channels to register
     * @since 0.3
     * @deprecated No longer required
     */
    @Deprecated
    public final void registerPubSubChannels(String... channels) {
    }

    /**
     * Unregister (a) PubSub channel(s).
     *
     * @param channels the channels to unregister
     * @since 0.3
     * @deprecated No longer required
     */
    @Deprecated
    public final void unregisterPubSubChannels(String... channels) {
    }

```
# Contributors

* `summoncraft.us` for running this branch in production
* @SrBedrock for providing [Brazilian
Portuguese](https://en.wikipedia.org/wiki/Brazilian_Portuguese)
translation #87
 
# issues
closes #84 
closes #88 
closes #92 
closes #81
closes #93

---------

Signed-off-by: mohammed jasem alaajel <xrambad@gmail.com>
Co-authored-by: ThiagoROX <51332006+SrBedrock@users.noreply.github.com>
2024-04-28 15:29:53 +04:00
8 changed files with 33 additions and 34 deletions

View File

@@ -35,7 +35,6 @@ blossom {
commit = "$commitStdout".replace("\n", "") // for some reason it adds new line so remove it. commit = "$commitStdout".replace("\n", "") // for some reason it adds new line so remove it.
commitStdout.close() commitStdout.close()
replaceToken("@git_commit@", commit) replaceToken("@git_commit@", commit)
replaceToken("@build_date@", "${Instant.now().epochSecond}")
} }

View File

@@ -15,7 +15,6 @@ public class Constants {
public final static String VERSION = "@version@"; public final static String VERSION = "@version@";
public final static String GIT_COMMIT = "@git_commit@"; public final static String GIT_COMMIT = "@git_commit@";
public final static long BUILD_DATE = Long.parseLong("@build_date@");
public static String getGithubCommitLink() { public static String getGithubCommitLink() {
return "https://github.com/ProxioDev/RedisBungee/commit/" + GIT_COMMIT; return "https://github.com/ProxioDev/RedisBungee/commit/" + GIT_COMMIT;

View File

@@ -12,7 +12,6 @@ package com.imaginarycode.minecraft.redisbungee.api.config.loaders;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;

View File

@@ -56,7 +56,7 @@ network-id: "main"
# You can set Environment variable 'REDISBUNGEE_PROXY_ID' to override # You can set Environment variable 'REDISBUNGEE_PROXY_ID' to override
proxy-id: "proxy-1" proxy-id: "proxy-1"
# since RedisBungee Internally now uses JedisPooled instead of Jedis, JedisPool. # since RedisBungee Internally now uses UnifiedJedis instead of Jedis, JedisPool.
# which will break compatibility with old plugins that uses RedisBungee JedisPool # which will break compatibility with old plugins that uses RedisBungee JedisPool
# so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons. # so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons.
# disabled by default # disabled by default

View File

@@ -197,7 +197,6 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
public void initialize() { public void initialize() {
logInfo("Initializing RedisBungee....."); logInfo("Initializing RedisBungee.....");
logInfo("Version: {}", Constants.VERSION); logInfo("Version: {}", Constants.VERSION);
logInfo("Build date: {}", Date.from(Instant.ofEpochSecond(Constants.BUILD_DATE)));
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory(); ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory); ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
try { try {

View File

@@ -11,6 +11,7 @@
package com.imaginarycode.minecraft.redisbungee.commands; package com.imaginarycode.minecraft.redisbungee.commands;
import co.aikar.commands.CommandIssuer; import co.aikar.commands.CommandIssuer;
import co.aikar.commands.RegisteredCommand;
import co.aikar.commands.annotation.*; import co.aikar.commands.annotation.*;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.imaginarycode.minecraft.redisbungee.Constants; import com.imaginarycode.minecraft.redisbungee.Constants;
@@ -26,12 +27,12 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@CommandAlias("rb|redisbungee") @CommandAlias("rb|redisbungee")
@CommandPermission("redisbungee.command.use") @CommandPermission("redisbungee.command.use")
@Description("Main command")
public class CommandRedisBungee extends AdventureBaseCommand { public class CommandRedisBungee extends AdventureBaseCommand {
private final RedisBungeePlugin<?> plugin; private final RedisBungeePlugin<?> plugin;
@@ -42,12 +43,12 @@ public class CommandRedisBungee extends AdventureBaseCommand {
@Default @Default
@Subcommand("info|version|git") @Subcommand("info|version|git")
@Description("information about current redisbungee build")
public void info(CommandIssuer issuer) { public void info(CommandIssuer issuer) {
final String message = """ final String message = """
<color:aqua>This proxy is running RedisBungee Limework's fork <color:aqua>This proxy is running RedisBungee Limework's fork
<color:gold>======================================== <color:gold>========================================
<color:aqua>RedisBungee version: <color:green><version> <color:aqua>RedisBungee version: <color:green><version>
<color:aqua>Build date: <color:green><build-date>
<color:aqua>Commit: <color:green><commit> <color:aqua>Commit: <color:green><commit>
<color:gold>======================================== <color:gold>========================================
<color:gold>run /rb help for more commands"""; <color:gold>run /rb help for more commands""";
@@ -57,7 +58,6 @@ public class CommandRedisBungee extends AdventureBaseCommand {
.deserialize( .deserialize(
message, message,
Placeholder.component("version", Component.text(Constants.VERSION)), Placeholder.component("version", Component.text(Constants.VERSION)),
Placeholder.component("build-date", Component.text( new Date(Constants.BUILD_DATE * 1000).toString() )),
Placeholder.component( Placeholder.component(
"commit", "commit",
Component.text(Constants.GIT_COMMIT.substring(0, 8)) Component.text(Constants.GIT_COMMIT.substring(0, 8))
@@ -67,19 +67,29 @@ public class CommandRedisBungee extends AdventureBaseCommand {
} }
// <color:aqua>......: <color:green>...... // <color:aqua>......: <color:green>......
@HelpCommand @HelpCommand
@Description("shows the help page")
public void help(CommandIssuer issuer) { public void help(CommandIssuer issuer) {
final String message = """ final String barFormat = "<color:gold>========================================";
<color:gold>======================================== final String commandFormat = "<color:aqua>/rb <sub-command>: <color:green><description>";
<color:aqua>/rb info: <color:green>shows info of this version.
<color:aqua>/rb help: <color:green>shows this page. TextComponent.Builder message = Component.text();
<color:aqua>/rb clean: <color:green>cleans up the uuid cache message.append(MiniMessage.miniMessage().deserialize(barFormat));
<color:red><bold>WARNING...</bold> <color:white>command above could cause performance issues
<color:aqua>/rb show: <color:green>shows list of proxies with player count getSubCommands().forEach((subCommand, registeredCommand) -> {
<color:gold>======================================== String[] split = registeredCommand.getCommand().split(" ");
<color:gold>run /rb help for more commands"""; if (split.length > 1 && subCommand.equalsIgnoreCase(split[1])) {
sendMessage(issuer, MiniMessage.miniMessage().deserialize(message)); message.appendNewline().append(MiniMessage.miniMessage().deserialize(commandFormat, Placeholder.component("sub-command", Component.text(subCommand)),
Placeholder.component("description", MiniMessage.miniMessage().deserialize(registeredCommand.getHelpText()))
));
}
});
message.appendNewline().append(MiniMessage.miniMessage().deserialize(barFormat));
sendMessage(issuer, message.build());
} }
@Subcommand("clean") @Subcommand("clean")
@Description("cleans up the uuid cache<color:red> <bold>WARNING...</bold> <color:white>command above could cause performance issues")
@Private @Private
public void cleanUp(CommandIssuer issuer) { public void cleanUp(CommandIssuer issuer) {
if (StopperUUIDCleanupTask.isRunning) { if (StopperUUIDCleanupTask.isRunning) {
@@ -99,6 +109,7 @@ public class CommandRedisBungee extends AdventureBaseCommand {
} }
@Subcommand("show") @Subcommand("show")
@Description("Shows proxies in this network")
public void showProxies(CommandIssuer issuer, String[] args) { public void showProxies(CommandIssuer issuer, String[] args) {
final String closer = "<color:gold>========================================"; final String closer = "<color:gold>========================================";
final String pageTop = "<color:yellow>Page: <color:green><current>/<max> <color:yellow>Network ID: <color:green><network> <color:yellow>Proxies online: <color:green><proxies>"; final String pageTop = "<color:yellow>Page: <color:green><current>/<max> <color:yellow>Network ID: <color:green><network> <color:yellow>Proxies online: <color:green><proxies>";
@@ -123,15 +134,6 @@ public class CommandRedisBungee extends AdventureBaseCommand {
} else currentPage = 1; } else currentPage = 1;
var data = new ArrayList<>(plugin.proxyDataManager().eachProxyCount().entrySet()); var data = new ArrayList<>(plugin.proxyDataManager().eachProxyCount().entrySet());
data.addAll(data);
data.addAll(data);
data.addAll(data);
data.addAll(data);
data.addAll(data);
data.addAll(data);
data.addAll(data);
data.addAll(data);
// there is no way this runs because there is always an heartbeat. // there is no way this runs because there is always an heartbeat.
// if not could be some shenanigans done by devs :P // if not could be some shenanigans done by devs :P
if (data.isEmpty()) { if (data.isEmpty()) {
@@ -139,7 +141,7 @@ public class CommandRedisBungee extends AdventureBaseCommand {
return; return;
} }
// compute the total pages // compute the total pages
int maxPages = data.size() < pageSize ? 1 : data.size() / pageSize ; int maxPages = (int) Math.ceil(data.size() / (double) pageSize);
if (currentPage > maxPages) currentPage = maxPages; if (currentPage > maxPages) currentPage = maxPages;
var subList = subListProxies(data, currentPage, pageSize); var subList = subListProxies(data, currentPage, pageSize);
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
@@ -169,17 +171,19 @@ public class CommandRedisBungee extends AdventureBaseCommand {
} }
if (currentPage > 1) { if (currentPage > 1) {
builder.append(MiniMessage.miniMessage().deserialize(previousPage) builder.append(MiniMessage.miniMessage().deserialize(previousPage)
.clickEvent(ClickEvent.runCommand("/rb show " + (currentPage - 1)))); .color(NamedTextColor.WHITE).clickEvent(ClickEvent.runCommand("/rb show " + (currentPage - 1))));
} else {
builder.append(MiniMessage.miniMessage().deserialize(previousPage).color(NamedTextColor.GRAY));
} }
if (subList.size() == pageSize && !subListProxies(data, currentPage + 1, pageSize).isEmpty()) { if (subList.size() == pageSize && !subListProxies(data, currentPage + 1, pageSize).isEmpty()) {
builder.append(MiniMessage.miniMessage().deserialize(nextPage) builder.append(MiniMessage.miniMessage().deserialize(nextPage)
.clickEvent(ClickEvent.runCommand("/rb show " + (currentPage + 1)))); .color(NamedTextColor.WHITE).clickEvent(ClickEvent.runCommand("/rb show " + (currentPage + 1))));
} else {
builder.append(MiniMessage.miniMessage().deserialize(nextPage).color(NamedTextColor.GRAY));
} }
builder.appendNewline(); builder.appendNewline();
builder.append(MiniMessage.miniMessage().deserialize(closer)); builder.append(MiniMessage.miniMessage().deserialize(closer));
sendMessage(issuer, builder.build()); sendMessage(issuer, builder.build());
} }
} }

View File

@@ -102,7 +102,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
this.logger = logger; this.logger = logger;
this.dataFolder = dataDirectory; this.dataFolder = dataDirectory;
logInfo("Version: {}", Constants.VERSION); logInfo("Version: {}", Constants.VERSION);
logInfo("Build date: {}", Date.from(Instant.ofEpochSecond(Constants.BUILD_DATE)));
try { try {
loadConfig(this, dataDirectory); loadConfig(this, dataDirectory);
loadLangConfig(this, dataDirectory); loadLangConfig(this, dataDirectory);

View File

@@ -1,2 +1,2 @@
group=com.imaginarycode.minecraft group=com.imaginarycode.minecraft
version=0.12.0-SNAPSHOT version=0.12.0