Skip to content

Commit

Permalink
Add checks to matching server name in BungeeSettings.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed Dec 2, 2023
1 parent b1eb591 commit 4c6073c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,17 @@ public void onRecieve(String subChannel, ArrayList<String> args) {
}
});

plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") {
@Override
public void onRecieve(String subChannel, ArrayList<String> 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<String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ 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));
}
}
if (args[0].equalsIgnoreCase("multiproxystatus")) {
plugin.sendMultiProxyServerMessage("Status");

source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
}
if (args[0].equalsIgnoreCase("help")) {
Expand Down

0 comments on commit 4c6073c

Please sign in to comment.