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

Allow to customize ping events priority via handle-motd-order

This commit is contained in:
PinkLolicorn
2024-06-22 20:31:17 +02:00
parent 22f505e8a2
commit b5901366af
6 changed files with 87 additions and 6 deletions

View File

@@ -0,0 +1,7 @@
package com.imaginarycode.minecraft.redisbungee.api.config;
public enum HandleMotdOrder {
FIRST,
NORMAL,
LAST
}

View File

@@ -25,12 +25,13 @@ public class RedisBungeeConfiguration {
private final boolean handleReconnectToLastServer;
private final boolean handleMotd;
private final HandleMotdOrder handleMotdOrder;
private final CommandsConfiguration commandsConfiguration;
private final String networkId;
public RedisBungeeConfiguration(String networkId, String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, CommandsConfiguration commandsConfiguration) {
public RedisBungeeConfiguration(String networkId, String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, HandleMotdOrder handleMotdOrder, CommandsConfiguration commandsConfiguration) {
this.proxyId = proxyId;
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
for (String s : exemptAddresses) {
@@ -40,6 +41,7 @@ public class RedisBungeeConfiguration {
this.kickWhenOnline = kickWhenOnline;
this.handleReconnectToLastServer = handleReconnectToLastServer;
this.handleMotd = handleMotd;
this.handleMotdOrder = handleMotdOrder;
this.commandsConfiguration = commandsConfiguration;
this.networkId = networkId;
}
@@ -60,6 +62,10 @@ public class RedisBungeeConfiguration {
return this.handleMotd;
}
public HandleMotdOrder handleMotdPriority() {
return handleMotdOrder;
}
public boolean handleReconnectToLastServer() {
return this.handleReconnectToLastServer;
}

View File

@@ -14,6 +14,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config.loaders;
import com.google.common.reflect.TypeToken;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
@@ -104,6 +105,16 @@ public interface ConfigLoader extends GenericConfigLoader {
plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer);
plugin.logInfo("handle motd: {}", handleMotd);
HandleMotdOrder handleMotdOrder = HandleMotdOrder.NORMAL;
String handleMotdOrderName = node.getNode("handle-motd-priority").getString();
if (handleMotdOrderName != null) {
try {
handleMotdOrder = HandleMotdOrder.valueOf(handleMotdOrderName.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
plugin.logWarn("handle motd order value '{}' is unsupported (allowed: {})", handleMotdOrderName, HandleMotdOrder.values());
}
}
plugin.logInfo("handle motd order: {}", handleMotdOrder);
// commands
boolean redisBungeeEnabled = node.getNode("commands", "redisbungee", "enabled").getBoolean(true);
@@ -130,7 +141,8 @@ public interface ConfigLoader extends GenericConfigLoader {
boolean installPlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "install").getBoolean(false);
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(networkId, proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, new RedisBungeeConfiguration.CommandsConfiguration(
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(networkId, proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, handleMotdOrder,
new RedisBungeeConfiguration.CommandsConfiguration(
redisBungeeEnabled, redisBungeeLegacyEnabled,
new RedisBungeeConfiguration.LegacySubCommandsConfiguration(
findEnabled, glistEnabled, ipEnabled,

View File

@@ -77,6 +77,13 @@ kick-when-online: true
# you can disable this when you want to handle motd yourself, use RedisBungee api to get total players when needed :)
handle-motd: true
# MOTD plugins compatibility setting
# Allowed values: FIRST, NORMAL, LAST
# This option enables RedisBungee to manage various interactions between other plugins and the online player count,
# which is dynamically updated to a global player count in ping responses if the handle-motd option is enabled.
# If you encounter issues with other plugins accessing or modifying the player count, try using a value of FIRST or LAST.
handle-motd-order: NORMAL
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
# restart scripts.
# Automatically disabled if handle-motd is disabled.