Added more subcommands to the addon

Not sure about the names of the subcommands...
This commit is contained in:
Jaime Martínez Rincón 2017-11-29 18:25:28 +01:00
parent c1f7f38f2b
commit 737c218295
2 changed files with 51 additions and 32 deletions

View File

@ -33,7 +33,7 @@ public class MainCommand implements CommandExecutor {
if (sender instanceof Player) {
plugin.getManager().connectPlayer((Player) sender, input);
} else {
sender.sendMessage("This command variant can only be executed by a player");
sender.sendMessage(ChatColor.RED + "This command variant can only be executed by a player");
}
}
} else {
@ -60,21 +60,41 @@ public class MainCommand implements CommandExecutor {
break;
}
/*
case "info": {
plugin.getManager().getSectionOfPlayer((Player) sender, (a) -> {
System.out.println(a);
sender.sendMessage(a);
});
case "bypassconnect": {
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
break;
}
case "setbypass": {
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
break;
}
case "clearbypass": {
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
break;
}
case "overridestatus": {
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
break;
}
case "clearoverride": {
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
break;
}
*/
}
} else {
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
sender.sendMessage(ChatColor.GRAY + "Available commands:");
sender.sendMessage(ChatColor.AQUA + "/spb connect <section> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to that section");
sender.sendMessage(ChatColor.AQUA + "/spb fallback [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to the parent of the current section");
sender.sendMessage(ChatColor.AQUA + "/spb bypassconnect <server> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to a specific server without balancing");
sender.sendMessage(ChatColor.AQUA + "/spb setbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Sets a bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb clearbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb overridestatus <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Overrides the accessible status of a specific server, over anything else");
sender.sendMessage(ChatColor.AQUA + "/spb clearoverride <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the overriden status of a specific server");
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
}
}

View File

@ -52,6 +52,13 @@ public class PluginMessageManager implements PluginMessageListener {
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
}
public void fallbackPlayer(Player player) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("FallbackPlayer");
out.writeUTF(player.getName());
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
}
public boolean getSectionByName(String section, Consumer<String> consumer) {
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
if (player == null) {
@ -92,26 +99,6 @@ public class PluginMessageManager implements PluginMessageListener {
return true;
}
public boolean getSectionPlayerCount(String section, Consumer<Integer> consumer) {
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
if (player == null) {
return false;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("GetSectionPlayerCount");
out.writeUTF(section);
contexts.put(new MessageContext(
"PlayerBalancer",
"GetSectionPlayerCount",
player.getUniqueId()
), (response) -> consumer.accept(response.readInt()));
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
return true;
}
public void getSectionOfPlayer(Player player, Consumer<String> consumer) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("GetSectionOfPlayer");
@ -146,11 +133,24 @@ public class PluginMessageManager implements PluginMessageListener {
return true;
}
public void fallbackPlayer(Player player) {
public boolean getSectionPlayerCount(String section, Consumer<Integer> consumer) {
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
if (player == null) {
return false;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("FallbackPlayer");
out.writeUTF(player.getName());
out.writeUTF("GetSectionPlayerCount");
out.writeUTF(section);
contexts.put(new MessageContext(
"PlayerBalancer",
"GetSectionPlayerCount",
player.getUniqueId()
), (response) -> consumer.accept(response.readInt()));
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
return true;
}
public boolean clearStatusOverride(String server) {
@ -194,7 +194,6 @@ public class PluginMessageManager implements PluginMessageListener {
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
}
//TODO Add this to the /balancer or some other command too
public void bypassConnect(Player player, String server) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("BypassConnect");