From 4c6073c02a88bb9b297c8bec6da7252693241386 Mon Sep 17 00:00:00 2001 From: BenCodez Date: Fri, 1 Dec 2023 20:23:21 -0500 Subject: [PATCH] Add checks to matching server name in BungeeSettings.yml --- .../src/com/bencodez/votingplugin/BungeeHandler.java | 11 +++++++++++ .../votingplugin/bungee/VotingPluginBungee.java | 10 ++++++++++ .../bungee/VotingPluginBungeeCommand.java | 1 + .../bungee/velocity/VotingPluginVelocity.java | 10 ++++++++++ .../bungee/velocity/VotingPluginVelocityCommand.java | 2 ++ 5 files changed, 34 insertions(+) diff --git a/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java b/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java index 425bdb63c..b90465ac7 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java @@ -523,6 +523,17 @@ public void onRecieve(String subChannel, ArrayList args) { } }); + plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") { + @Override + public void onRecieve(String subChannel, ArrayList args) { + String server = args.get(0); + if (!plugin.getOptions().getServer().equals(server)) { + plugin.getLogger() + .warning("Server name doesn't match in BungeeSettings.yml, should be " + server); + } + } + }); + plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") { @Override public void onRecieve(String subChannel, ArrayList args) { diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java index 869653a11..48b5c0cb0 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java @@ -905,6 +905,16 @@ public void onReceive(String[] data) { if (!buildNumber.equals("NOTSET")) { getLogger().info("Detected using dev build number: " + buildNumber); } + sendServerNameMessage(); + } + + public void sendServerNameMessage() { + if (method.equals(BungeeMethod.PLUGINMESSAGING)) { + for (String s : getAvailableAllServers()) { + sendPluginMessageServer(s, "ServerName", s); + } + } + } public void loadMultiProxySupport() { diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungeeCommand.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungeeCommand.java index d4e7720b6..d1615e2bd 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungeeCommand.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungeeCommand.java @@ -49,6 +49,7 @@ public void execute(CommandSender sender, String[] args) { sender.sendMessage(new TextComponent( "&aChecking status, waiting for response, check console, method: plugin messaging")); bungee.status(sender); + bungee.sendServerNameMessage(); } else { sender.sendMessage( new TextComponent("&aNot using socket/pluginmessage method, command unavailable")); diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java index ce33937a5..fdae21b45 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java @@ -987,6 +987,16 @@ public void onReceive(String[] data) { if (!buildNumber.equals("NOTSET")) { logger.info("Detected using dev build number: " + buildNumber); } + sendServerNameMessage(); + } + + public void sendServerNameMessage() { + if (method.equals(BungeeMethod.PLUGINMESSAGING)) { + for (RegisteredServer s : getAvailableAllServers()) { + sendPluginMessageServer(s, "ServerName", s.getServerInfo().getName()); + } + } + } public void loadMultiProxySupport() { diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocityCommand.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocityCommand.java index d937a9683..346a20404 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocityCommand.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocityCommand.java @@ -55,6 +55,7 @@ public void execute(final Invocation invocation) { .text("Checking status, waiting for response, check console, method: pluginmessaging") .color(NamedTextColor.AQUA)); plugin.status(); + plugin.sendServerNameMessage(); } else { source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable") .color(NamedTextColor.AQUA)); @@ -62,6 +63,7 @@ public void execute(final Invocation invocation) { } if (args[0].equalsIgnoreCase("multiproxystatus")) { plugin.sendMultiProxyServerMessage("Status"); + source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA)); } if (args[0].equalsIgnoreCase("help")) {