From f7d88a26efc3f4f4794efa0a334ef9124e20da08 Mon Sep 17 00:00:00 2001 From: BenCodez Date: Sun, 5 Nov 2023 20:16:52 -0500 Subject: [PATCH] Handle allowunjoined disabled on multi-proxy setup --- .../bungee/NonVotedPlayersCache.java | 2 +- .../bungee/VotingPluginBungee.java | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/NonVotedPlayersCache.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/NonVotedPlayersCache.java index 6fb3288b9..e1fc8e9b6 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/NonVotedPlayersCache.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/NonVotedPlayersCache.java @@ -25,7 +25,7 @@ public void addPlayer(ProxiedPlayer proxiedPlayer) { } } - private void addPlayer(String uuid, String playerName) { + public void addPlayer(String uuid, String playerName) { getData().set("NonVotedPlayers." + playerName + ".UUID", uuid); getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis()); } diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java index cff9e2d13..869653a11 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java @@ -936,6 +936,8 @@ public void onReceive(String[] data) { getLogger().info("Multi-proxy status message received"); } else if (data[0].equalsIgnoreCase("ClearVote")) { cachedOnlineVotes.remove(data[2]); + } else if (data[0].equalsIgnoreCase("login")) { + nonVotedPlayersCache.addPlayer(data[1], data[2]); } } if (data.length > 8) { @@ -952,9 +954,7 @@ public void onReceive(String[] data) { }); multiproxyClientHandles = new HashMap(); - for ( - - String s : config.getMultiProxyServers()) { + for (String s : config.getMultiProxyServers()) { Configuration d = config.getMultiProxyServersConfiguration(s); multiproxyClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234), encryptionHandler, config.getDebug())); @@ -989,14 +989,15 @@ public boolean isOnline(ProxiedPlayer p) { public void login(ProxiedPlayer p) { if (p != null && p.getServer() != null && p.getServer().getInfo() != null) { final String server = p.getServer().getInfo().getName(); - final ProxiedPlayer proixedPlayer = p; + final ProxiedPlayer proxiedPlayer = p; getProxy().getScheduler().schedule(this, new Runnable() { @Override public void run() { if (isOnline(p)) { checkCachedVotes(server); - checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server); + checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server); + multiProxyLogin(proxiedPlayer); } } }, 1, TimeUnit.SECONDS); @@ -1004,6 +1005,18 @@ public void run() { } + public void multiProxyLogin(ProxiedPlayer p) { + if (!config.getMultiProxySupport()) { + return; + } + if (config.getPrimaryServer()) { + return; + } + if (!config.getAllowUnJoined()) { + sendMultiProxyServerMessage("Login", p.getUniqueId().toString(), p.getName()); + } + } + @EventHandler public void onPluginMessage(PluginMessageEvent ev) { if (!ev.getTag().equals("vp:vp".toLowerCase())) {