mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-12-23 02:28:01 +00:00
add config option to restore old kick behavior pre 0.9.0
This commit is contained in:
parent
31e461a11c
commit
c8362a44ec
@ -52,6 +52,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);
|
||||
String redisPassword = node.getNode("redis-password").getString("");
|
||||
String proxyId = node.getNode("proxy-id").getString("test-1");
|
||||
final int maxConnections = node.getNode("max-redis-connections").getInt(10);
|
||||
@ -81,7 +82,7 @@ public interface ConfigLoader {
|
||||
} else {
|
||||
plugin.logInfo("Loaded proxy id " + proxyId);
|
||||
}
|
||||
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)));
|
||||
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)), restoreOldKickBehavior);
|
||||
Summoner<?> summoner;
|
||||
RedisBungeeMode redisBungeeMode;
|
||||
if (node.getNode("cluster-mode-enabled").getBoolean(false)) {
|
||||
@ -134,6 +135,7 @@ public interface ConfigLoader {
|
||||
ConfigurationNode node = yamlConfigurationFileLoader.load();
|
||||
HashMap<RedisBungeeConfiguration.MessageType, String> messages = new HashMap<>();
|
||||
messages.put(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION, node.getNode("logged-in-other-location").getString("§cLogged in from another location."));
|
||||
messages.put(RedisBungeeConfiguration.MessageType.ALREADY_LOGGED_IN, node.getNode("already-logged-in").getString("§cYou are already logged in!"));
|
||||
return ImmutableMap.copyOf(messages);
|
||||
}
|
||||
|
||||
|
@ -22,19 +22,20 @@ import java.util.List;
|
||||
public class RedisBungeeConfiguration {
|
||||
|
||||
public enum MessageType {
|
||||
LOGGED_IN_OTHER_LOCATION
|
||||
LOGGED_IN_OTHER_LOCATION,
|
||||
ALREADY_LOGGED_IN
|
||||
}
|
||||
|
||||
private final ImmutableMap<MessageType, String> messages;
|
||||
public static final int CONFIG_VERSION = 1;
|
||||
private final String proxyId;
|
||||
private final List<InetAddress> exemptAddresses;
|
||||
|
||||
private final boolean registerLegacyCommands;
|
||||
|
||||
private final boolean overrideBungeeCommands;
|
||||
|
||||
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap<MessageType, String> messages) {
|
||||
private final boolean restoreOldKickBehavior;
|
||||
|
||||
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap<MessageType, String> messages, boolean restoreOldKickBehavior) {
|
||||
this.proxyId = proxyId;
|
||||
this.messages = messages;
|
||||
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
||||
@ -44,8 +45,8 @@ public class RedisBungeeConfiguration {
|
||||
this.exemptAddresses = addressBuilder.build();
|
||||
this.registerLegacyCommands = registerLegacyCommands;
|
||||
this.overrideBungeeCommands = overrideBungeeCommands;
|
||||
this.restoreOldKickBehavior = restoreOldKickBehavior;
|
||||
}
|
||||
|
||||
public String getProxyId() {
|
||||
return proxyId;
|
||||
}
|
||||
@ -65,4 +66,8 @@ public class RedisBungeeConfiguration {
|
||||
public ImmutableMap<MessageType, String> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public boolean restoreOldKickBehavior() {
|
||||
return restoreOldKickBehavior;
|
||||
}
|
||||
}
|
||||
|
@ -68,5 +68,10 @@ override-bungee-commands: false
|
||||
# restart scripts.
|
||||
exempt-ip-addresses: []
|
||||
|
||||
# restore old login when online behavior before 0.9.0 update
|
||||
# uncomment to enable it
|
||||
|
||||
# disable-kick-when-online: true
|
||||
|
||||
# Config version DO NOT CHANGE!!!!
|
||||
config-version: 1
|
@ -1 +1,2 @@
|
||||
logged-in-other-location: "§cYou logged in from another location!"
|
||||
logged-in-other-location: "§cYou logged in from another location!"
|
||||
already-logged-in: "§cYou are already logged in!"
|
@ -58,7 +58,15 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
if (api.isPlayerOnline(event.getConnection().getUniqueId())) {
|
||||
if (plugin.getConfiguration().restoreOldKickBehavior()) {
|
||||
for (String s : plugin.getProxiesIds()) {
|
||||
if (unifiedJedis.sismember("proxy:" + s + ":usersOnline", event.getConnection().getUniqueId().toString())) {
|
||||
event.setCancelled(true);
|
||||
event.setCancelReason(plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.ALREADY_LOGGED_IN));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else if (api.isPlayerOnline(event.getConnection().getUniqueId())) {
|
||||
PlayerUtils.setKickedOtherLocation(event.getConnection().getUniqueId().toString(), unifiedJedis);
|
||||
api.kickPlayer(event.getConnection().getUniqueId(), plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION));
|
||||
}
|
||||
|
@ -65,7 +65,16 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
||||
if (!event.getResult().isAllowed()) {
|
||||
return null;
|
||||
}
|
||||
if (api.isPlayerOnline(event.getPlayer().getUniqueId())) {
|
||||
if (plugin.getConfiguration().restoreOldKickBehavior()) {
|
||||
|
||||
for (String s : plugin.getProxiesIds()) {
|
||||
if (unifiedJedis.sismember("proxy:" + s + ":usersOnline", event.getPlayer().getUniqueId().toString())) {
|
||||
event.setResult(ResultedEvent.ComponentResult.denied(serializer.deserialize(plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.ALREADY_LOGGED_IN))));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (api.isPlayerOnline(event.getPlayer().getUniqueId())) {
|
||||
PlayerUtils.setKickedOtherLocation(event.getPlayer().getUniqueId().toString(), unifiedJedis);
|
||||
api.kickPlayer(event.getPlayer().getUniqueId(), plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user