2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-04-08 16:10:26 +00:00

finsh up command system

This commit is contained in:
2024-04-18 12:48:00 +04:00
parent 78561fa467
commit 32826d843c
15 changed files with 448 additions and 23 deletions

View File

@@ -13,6 +13,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
import com.google.common.collect.ImmutableList;
import com.google.common.net.InetAddresses;
import javax.annotation.Nullable;
import java.net.InetAddress;
import java.util.List;
@@ -25,8 +26,10 @@ public class RedisBungeeConfiguration {
private final boolean handleReconnectToLastServer;
private final boolean handleMotd;
private final CommandsConfiguration commandsConfiguration;
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) {
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, CommandsConfiguration commandsConfiguration) {
this.proxyId = proxyId;
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
for (String s : exemptAddresses) {
@@ -36,6 +39,7 @@ public class RedisBungeeConfiguration {
this.kickWhenOnline = kickWhenOnline;
this.handleReconnectToLastServer = handleReconnectToLastServer;
this.handleMotd = handleMotd;
this.commandsConfiguration = commandsConfiguration;
}
public String getProxyId() {
@@ -58,5 +62,21 @@ public class RedisBungeeConfiguration {
return this.handleReconnectToLastServer;
}
public record CommandsConfiguration(boolean redisbungeeEnabled, boolean redisbungeeLegacyEnabled,
@Nullable LegacySubCommandsConfiguration legacySubCommandsConfiguration) {
}
public record LegacySubCommandsConfiguration(boolean findEnabled, boolean glistEnabled, boolean ipEnabled,
boolean lastseenEnabled, boolean plistEnabled, boolean pproxyEnabled,
boolean sendtoallEnabled, boolean serveridEnabled,
boolean serveridsEnabled, boolean installFind, boolean installGlist, boolean installIp,
boolean installLastseen, boolean installPlist, boolean installPproxy,
boolean installSendtoall, boolean installServerid,
boolean installServerids) {
}
public CommandsConfiguration commandsConfiguration() {
return commandsConfiguration;
}
}

View File

@@ -86,7 +86,42 @@ public interface ConfigLoader extends GenericConfigLoader {
plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer);
plugin.logInfo("handle motd: {}", handleMotd);
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd);
// commands
boolean redisBungeeEnabled = node.getNode("commands", "redisbungee", "enabled").getBoolean();
boolean redisBungeeLegacyEnabled =node.getNode("commands", "redisbungee-legacy", "enabled").getBoolean();
boolean glistEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "glist", "enabled").getBoolean();
boolean findEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "find", "enabled").getBoolean();
boolean lastseenEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "lastseen", "enabled").getBoolean();
boolean ipEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "ip", "enabled").getBoolean();
boolean pproxyEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "pproxy", "enabled").getBoolean();
boolean sendToAllEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "sendtoall", "enabled").getBoolean();
boolean serverIdEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverid", "enabled").getBoolean();
boolean serverIdsEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverids", "enabled").getBoolean();
boolean pListEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "enabled").getBoolean();
boolean installGlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "glist", "install").getBoolean();
boolean installFind = node.getNode("commands", "redisbungee-legacy", "subcommands", "find", "install").getBoolean();
boolean installLastseen = node.getNode("commands", "redisbungee-legacy", "subcommands", "lastseen", "install").getBoolean();
boolean installIp = node.getNode("commands", "redisbungee-legacy", "subcommands", "ip", "install").getBoolean();
boolean installPproxy = node.getNode("commands", "redisbungee-legacy", "subcommands", "pproxy", "install").getBoolean();
boolean installSendToAll = node.getNode("commands", "redisbungee-legacy", "subcommands", "sendtoall", "install").getBoolean();
boolean installServerid = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverid", "install").getBoolean();
boolean installServerIds = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverids", "install").getBoolean();
boolean installPlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "install").getBoolean();
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, new RedisBungeeConfiguration.CommandsConfiguration(
redisBungeeEnabled, redisBungeeLegacyEnabled,
new RedisBungeeConfiguration.LegacySubCommandsConfiguration(
findEnabled, glistEnabled, ipEnabled,
lastseenEnabled, pListEnabled, pproxyEnabled,
sendToAllEnabled, serverIdEnabled, serverIdsEnabled,
installFind, installGlist, installIp,
installLastseen, installPlist, installPproxy,
installSendToAll, installServerid, installServerIds)
));
Summoner<?> summoner;
RedisBungeeMode redisBungeeMode;
if (useSSL) {

View File

@@ -50,7 +50,7 @@ proxy-id: "proxy-1"
# which will break compatibility with old plugins that uses RedisBungee JedisPool
# so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons.
# disabled by default
# ignored when cluster mode is enabled
# Automatically disabled when cluster mode is enabled
enable-jedis-pool-compatibility: false
# max connections for the compatibility pool
@@ -69,12 +69,64 @@ handle-motd: true
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
# restart scripts.
# ignored if handle-motd is disabled.
# Automatically disabled if handle-motd is disabled.
exempt-ip-addresses: []
# disabled by default
# RedisBungee will attempt to connect player to last server that was stored.
reconnect-to-last-server: false
# 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
# Config version DO NOT CHANGE!!!!
config-version: 2