From 958bc190a29ea7c44f4035ea0ca611c20ff6aef0 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Sun, 23 Apr 2017 13:56:09 -0600 Subject: [PATCH 1/3] Allowing commands to be run on all servers using '*' identifier --- .../src/net/ME1312/SubServers/Bungee/SubCommand.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java index eb4e1b48..015f5782 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java @@ -110,7 +110,7 @@ public final class SubCommand extends Command implements TabExecutor { } else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) { if (args.length > 2) { Map servers = plugin.api.getServers(); - if (!servers.keySet().contains(args[1].toLowerCase())) { + if (!(servers.keySet().contains(args[1].toLowerCase()) || args[1].equals("*"))) { sender.sendMessage("SubServers > There is no server with that name"); } else if (!(servers.get(args[1].toLowerCase()) instanceof SubServer)) { sender.sendMessage("SubServers > That Server is not a SubServer"); @@ -125,7 +125,15 @@ public final class SubCommand extends Command implements TabExecutor { str = str + " " + args[i]; } while ((i + 1) != args.length); } - ((SubServer) servers.get(args[1].toLowerCase())).command(str); + if (args[1].equals("*")) { + for (Server server : servers.values()) { + if (((SubServer) server).isRunning()) { + ((SubServer) server).command(str); + } + } + } else { + ((SubServer) servers.get(args[1].toLowerCase())).command(str); + } } } else { sender.sendMessage("SubServers > Usage: " + label + " " + args[0].toLowerCase() + " [Args...]"); From e802d4f467236a5468b091d9ec19db90d1c08339 Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Sun, 23 Apr 2017 14:06:46 -0600 Subject: [PATCH 2/3] Switching do while to a for loop --- .../src/net/ME1312/SubServers/Bungee/SubCommand.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java index 015f5782..b4bb6caf 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java @@ -117,13 +117,11 @@ public final class SubCommand extends Command implements TabExecutor { } else if (!((SubServer) servers.get(args[1].toLowerCase())).isRunning()) { sender.sendMessage("SubServers > That SubServer is not running"); } else { - int i = 2; String str = args[2]; if (args.length > 3) { - do { - i++; - str = str + " " + args[i]; - } while ((i + 1) != args.length); + for (int i = 3; i < args.length; i++) { + str += " " + args[i]; + } } if (args[1].equals("*")) { for (Server server : servers.values()) { From 1270fc1bec83126bb515adcab5d5fd00d7b8d3de Mon Sep 17 00:00:00 2001 From: Kyle Melton Date: Sun, 23 Apr 2017 14:10:22 -0600 Subject: [PATCH 3/3] Removing unused conditional statement --- .../src/net/ME1312/SubServers/Bungee/SubCommand.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java index b4bb6caf..7ceff58c 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubCommand.java @@ -118,10 +118,8 @@ public final class SubCommand extends Command implements TabExecutor { sender.sendMessage("SubServers > That SubServer is not running"); } else { String str = args[2]; - if (args.length > 3) { - for (int i = 3; i < args.length; i++) { - str += " " + args[i]; - } + for (int i = 3; i < args.length; i++) { + str += " " + args[i]; } if (args[1].equals("*")) { for (Server server : servers.values()) {