diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java index 428382c..e9b49c4 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/ConfigLoader.java @@ -51,7 +51,7 @@ public interface ConfigLoader { final boolean useSSL = node.getNode("useSSL").getBoolean(false); final boolean overrideBungeeCommands = node.getNode("override-bungee-commands").getBoolean(false); final boolean registerLegacyCommands = node.getNode("register-legacy-commands").getBoolean(false); - final boolean restoreOldKickBehavior = node.getNode("disable-kick-when-online").getBoolean(false); + final boolean kickWhenOnline = node.getNode("kick-when-online").getBoolean(false); String redisPassword = node.getNode("redis-password").getString(""); String redisUsername = node.getNode("redis-username").getString(""); String proxyId = node.getNode("proxy-id").getString("test-1"); @@ -86,7 +86,10 @@ public interface ConfigLoader { } else { plugin.logInfo("Loaded proxy id " + proxyId); } - RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)), restoreOldKickBehavior); + boolean reconnectToLastServer = node.getNode("reconnect-to-last-server").getBoolean(); + boolean handleMotd = node.getNode("handle-motd").getBoolean(true); + + RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)), kickWhenOnline, reconnectToLastServer, handleMotd); Summoner summoner; RedisBungeeMode redisBungeeMode; if (node.getNode("cluster-mode-enabled").getBoolean(false)) { diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java index e10c9d0..aeedb08 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java @@ -25,15 +25,18 @@ public class RedisBungeeConfiguration { } private final ImmutableMap messages; - public static final int CONFIG_VERSION = 1; + public static final int CONFIG_VERSION = 2; private final String proxyId; private final List exemptAddresses; private final boolean registerLegacyCommands; private final boolean overrideBungeeCommands; + private final boolean kickWhenOnline; - private final boolean restoreOldKickBehavior; + private final boolean handleReconnectToLastServer; + private final boolean handleMotd; - public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap messages, boolean restoreOldKickBehavior) { + + public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap messages, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) { this.proxyId = proxyId; this.messages = messages; ImmutableList.Builder addressBuilder = ImmutableList.builder(); @@ -43,7 +46,9 @@ public class RedisBungeeConfiguration { this.exemptAddresses = addressBuilder.build(); this.registerLegacyCommands = registerLegacyCommands; this.overrideBungeeCommands = overrideBungeeCommands; - this.restoreOldKickBehavior = restoreOldKickBehavior; + this.kickWhenOnline = kickWhenOnline; + this.handleReconnectToLastServer = handleReconnectToLastServer; + this.handleMotd = handleMotd; } public String getProxyId() { @@ -66,7 +71,17 @@ public class RedisBungeeConfiguration { return messages; } - public boolean restoreOldKickBehavior() { - return restoreOldKickBehavior; + public boolean kickWhenOnline() { + return kickWhenOnline; } + + public boolean handleMotd() { + return this.handleMotd; + } + + public boolean handleReconnectToLastServer() { + return this.handleReconnectToLastServer; + } + + } diff --git a/RedisBungee-API/src/main/resources/config.yml b/RedisBungee-API/src/main/resources/config.yml index 93756ee..d8453a7 100644 --- a/RedisBungee-API/src/main/resources/config.yml +++ b/RedisBungee-API/src/main/resources/config.yml @@ -74,8 +74,20 @@ override-bungee-commands: false # restart scripts. exempt-ip-addresses: [] -# restore old login when online behavior before 0.9.0 update -disable-kick-when-online: false +# restore old login behavior before 0.9.0 update +# enabled by default +# when true: when player login and there is old player with same uuid it will get disconnected as result and new player will login +# when false: when a player login but login will fail because old player is still connected. +kick-when-online: true + +# enabled by default +# this option tells redis-bungee handle motd and set online count, when motd is requested +# you can disable this when you want to handle motd yourself, use RedisBungee api to get total players when needed :) +handle-motd: true + +# disabled by default +# Redis-bungee will attempt to connect player to last server that was stored. +reconnect-to-last-server: false # Config version DO NOT CHANGE!!!! -config-version: 1 +config-version: 2 diff --git a/RedisBungee-API/src/main/resources/messages.yml b/RedisBungee-API/src/main/resources/messages.yml index a1b1853..200cb4a 100644 --- a/RedisBungee-API/src/main/resources/messages.yml +++ b/RedisBungee-API/src/main/resources/messages.yml @@ -1,2 +1,5 @@ +# this config file is for messages for players and command messages +# Note this uses legacy formating which § for color codes +# this might get replaced soon with mini message for both, velocity and bungeecord logged-in-other-location: "§cYou logged in from another location!" already-logged-in: "§cYou are already logged in!" \ No newline at end of file diff --git a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/BungeePlayerDataManager.java b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/BungeePlayerDataManager.java index e312b7c..7ccfa02 100644 --- a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/BungeePlayerDataManager.java +++ b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/BungeePlayerDataManager.java @@ -67,7 +67,7 @@ public class BungeePlayerDataManager extends PlayerDataManager event.completeIntent((Plugin) plugin), TimeUnit.SECONDS, 3); diff --git a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java index 6d7b6a7..ce298ff 100644 --- a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java +++ b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java @@ -28,8 +28,7 @@ import net.md_5.bungee.event.EventHandler; import java.util.*; -import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.MultiMapSerialization.serializeMultimap; -import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.MultiMapSerialization.serializeMultiset; +import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.MultiMapSerialization.*; public class RedisBungeeListener implements Listener { @@ -41,14 +40,11 @@ public class RedisBungeeListener implements Listener { @EventHandler public void onPing(ProxyPingEvent event) { - if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getAddress().getAddress())) { - return; - } + if (!plugin.configuration().handleMotd()) return; + if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getAddress().getAddress())) return; ServerInfo forced = AbstractReconnectHandler.getForcedHost(event.getConnection()); - if (forced != null && event.getConnection().getListener().isPingPassthrough()) { - return; - } + if (forced != null && event.getConnection().getListener().isPingPassthrough()) return; event.getResponse().getPlayers().setOnline(plugin.proxyDataManager().totalNetworkPlayers()); } diff --git a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java index 3d7d6cf..35a9807 100644 --- a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java +++ b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeListener.java @@ -41,9 +41,9 @@ public class RedisBungeeListener { @Subscribe(order = PostOrder.LAST) // some plugins changes it online players so we need to be executed as last public void onPing(ProxyPingEvent event) { - if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getRemoteAddress().getAddress())) { - return; - } + if (!plugin.configuration().handleMotd()) return; + if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getRemoteAddress().getAddress())) return; + ServerPing.Builder ping = event.getPing().asBuilder(); ping.onlinePlayers(plugin.proxyDataManager().totalNetworkPlayers()); event.setPing(ping.build()); diff --git a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/VelocityPlayerDataManager.java b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/VelocityPlayerDataManager.java index a2b6735..d374a04 100644 --- a/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/VelocityPlayerDataManager.java +++ b/RedisBungee-Velocity/src/main/java/com/imaginarycode/minecraft/redisbungee/VelocityPlayerDataManager.java @@ -71,7 +71,7 @@ public class VelocityPlayerDataManager extends PlayerDataManager