mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +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 useSSL = node.getNode("useSSL").getBoolean(false);
|
||||||
final boolean overrideBungeeCommands = node.getNode("override-bungee-commands").getBoolean(false);
|
final boolean overrideBungeeCommands = node.getNode("override-bungee-commands").getBoolean(false);
|
||||||
final boolean registerLegacyCommands = node.getNode("register-legacy-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 redisPassword = node.getNode("redis-password").getString("");
|
||||||
String proxyId = node.getNode("proxy-id").getString("test-1");
|
String proxyId = node.getNode("proxy-id").getString("test-1");
|
||||||
final int maxConnections = node.getNode("max-redis-connections").getInt(10);
|
final int maxConnections = node.getNode("max-redis-connections").getInt(10);
|
||||||
@ -81,7 +82,7 @@ public interface ConfigLoader {
|
|||||||
} else {
|
} else {
|
||||||
plugin.logInfo("Loaded proxy id " + proxyId);
|
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;
|
Summoner<?> summoner;
|
||||||
RedisBungeeMode redisBungeeMode;
|
RedisBungeeMode redisBungeeMode;
|
||||||
if (node.getNode("cluster-mode-enabled").getBoolean(false)) {
|
if (node.getNode("cluster-mode-enabled").getBoolean(false)) {
|
||||||
@ -134,6 +135,7 @@ public interface ConfigLoader {
|
|||||||
ConfigurationNode node = yamlConfigurationFileLoader.load();
|
ConfigurationNode node = yamlConfigurationFileLoader.load();
|
||||||
HashMap<RedisBungeeConfiguration.MessageType, String> messages = new HashMap<>();
|
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.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);
|
return ImmutableMap.copyOf(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,19 +22,20 @@ import java.util.List;
|
|||||||
public class RedisBungeeConfiguration {
|
public class RedisBungeeConfiguration {
|
||||||
|
|
||||||
public enum MessageType {
|
public enum MessageType {
|
||||||
LOGGED_IN_OTHER_LOCATION
|
LOGGED_IN_OTHER_LOCATION,
|
||||||
|
ALREADY_LOGGED_IN
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ImmutableMap<MessageType, String> messages;
|
private final ImmutableMap<MessageType, String> messages;
|
||||||
public static final int CONFIG_VERSION = 1;
|
public static final int CONFIG_VERSION = 1;
|
||||||
private final String proxyId;
|
private final String proxyId;
|
||||||
private final List<InetAddress> exemptAddresses;
|
private final List<InetAddress> exemptAddresses;
|
||||||
|
|
||||||
private final boolean registerLegacyCommands;
|
private final boolean registerLegacyCommands;
|
||||||
|
|
||||||
private final boolean overrideBungeeCommands;
|
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.proxyId = proxyId;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
||||||
@ -44,8 +45,8 @@ public class RedisBungeeConfiguration {
|
|||||||
this.exemptAddresses = addressBuilder.build();
|
this.exemptAddresses = addressBuilder.build();
|
||||||
this.registerLegacyCommands = registerLegacyCommands;
|
this.registerLegacyCommands = registerLegacyCommands;
|
||||||
this.overrideBungeeCommands = overrideBungeeCommands;
|
this.overrideBungeeCommands = overrideBungeeCommands;
|
||||||
|
this.restoreOldKickBehavior = restoreOldKickBehavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProxyId() {
|
public String getProxyId() {
|
||||||
return proxyId;
|
return proxyId;
|
||||||
}
|
}
|
||||||
@ -65,4 +66,8 @@ public class RedisBungeeConfiguration {
|
|||||||
public ImmutableMap<MessageType, String> getMessages() {
|
public ImmutableMap<MessageType, String> getMessages() {
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean restoreOldKickBehavior() {
|
||||||
|
return restoreOldKickBehavior;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,5 +68,10 @@ override-bungee-commands: false
|
|||||||
# restart scripts.
|
# restart scripts.
|
||||||
exempt-ip-addresses: []
|
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 DO NOT CHANGE!!!!
|
||||||
config-version: 1
|
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()) {
|
if (event.isCancelled()) {
|
||||||
return null;
|
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);
|
PlayerUtils.setKickedOtherLocation(event.getConnection().getUniqueId().toString(), unifiedJedis);
|
||||||
api.kickPlayer(event.getConnection().getUniqueId(), plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION));
|
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()) {
|
if (!event.getResult().isAllowed()) {
|
||||||
return null;
|
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);
|
PlayerUtils.setKickedOtherLocation(event.getPlayer().getUniqueId().toString(), unifiedJedis);
|
||||||
api.kickPlayer(event.getPlayer().getUniqueId(), plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION));
|
api.kickPlayer(event.getPlayer().getUniqueId(), plugin.getConfiguration().getMessages().get(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user