2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

Always kick the new player in online mode.

Allowing the new player on is more seamless, but does not synchronize well, so I've forced a kick instead, which is a cleaner solution at the expense of minor inconvenience.
This commit is contained in:
Tux 2015-06-22 04:54:15 -04:00
parent ff602bc5e6
commit 8c05655330

View File

@ -60,6 +60,11 @@ public class RedisBungeeListener implements Listener {
.append("\n\nIf you were disconnected forcefully, please wait up to one minute.\nIf this does not resolve your issue, please contact staff.")
.color(ChatColor.GRAY)
.create();
private static final BaseComponent[] ONLINE_MODE_RECONNECT =
new ComponentBuilder("Whoops! You need to reconnect.").color(ChatColor.RED)
.append("\n\nWe found someone online using your username. They were kicked and you may reconnect.\nIf this does not work, please contact staff.")
.color(ChatColor.GRAY)
.create();
private final RedisBungee plugin;
private final List<InetAddress> exemptAddresses;
@ -74,11 +79,20 @@ public class RedisBungeeListener implements Listener {
return null;
}
// If a player with this name isn't on this proxy, we make sure they aren't trying to use an existing
// player's name. This is BungeeCord behavior I disapprove of but I don't really care at this point.
// We make sure they aren't trying to use an existing player's name.
// This is problematic for online-mode servers as they always disconnect old clients.
if (plugin.getProxy().getConfig().isOnlineMode()) {
ProxiedPlayer player = plugin.getProxy().getPlayer(event.getConnection().getName());
if (player == null) {
if (player != null) {
event.setCancelled(true);
// TODO: Make it accept a BaseComponent[] like everything else.
event.setCancelReason(TextComponent.toLegacyText(ONLINE_MODE_RECONNECT));
event.completeIntent(plugin);
return null;
}
}
String online = jedis.hget("player:" + event.getConnection().getUniqueId().toString(), "online");
if (online != null && online.equals("0")) {
@ -88,7 +102,6 @@ public class RedisBungeeListener implements Listener {
event.completeIntent(plugin);
return null;
}
}
Map<String, String> playerData = new HashMap<>(4);
playerData.put("online", "0");