Skip to content

Commit 737c218

Browse files
committed
Added more subcommands to the addon
Not sure about the names of the subcommands...
1 parent c1f7f38 commit 737c218

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

Spigot Addon/src/main/java/com/jaimemartz/playerbalanceraddon/MainCommand.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
3333
if (sender instanceof Player) {
3434
plugin.getManager().connectPlayer((Player) sender, input);
3535
} else {
36-
sender.sendMessage("This command variant can only be executed by a player");
36+
sender.sendMessage(ChatColor.RED + "This command variant can only be executed by a player");
3737
}
3838
}
3939
} else {
@@ -60,21 +60,41 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
6060
break;
6161
}
6262

63-
/*
64-
case "info": {
65-
plugin.getManager().getSectionOfPlayer((Player) sender, (a) -> {
66-
System.out.println(a);
67-
sender.sendMessage(a);
68-
});
63+
case "bypassconnect": {
64+
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
65+
break;
66+
}
67+
68+
case "setbypass": {
69+
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
70+
break;
71+
}
72+
73+
case "clearbypass": {
74+
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
75+
break;
76+
}
77+
78+
case "overridestatus": {
79+
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
80+
break;
81+
}
82+
83+
case "clearoverride": {
84+
sender.sendMessage(ChatColor.RED + "This command variant is not implemented yet");
6985
break;
7086
}
71-
*/
7287
}
7388
} else {
7489
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
7590
sender.sendMessage(ChatColor.GRAY + "Available commands:");
7691
sender.sendMessage(ChatColor.AQUA + "/spb connect <section> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to that section");
7792
sender.sendMessage(ChatColor.AQUA + "/spb fallback [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to the parent of the current section");
93+
sender.sendMessage(ChatColor.AQUA + "/spb bypassconnect <server> [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Connects you or the specified player to a specific server without balancing");
94+
sender.sendMessage(ChatColor.AQUA + "/spb setbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Sets a bypass for you or the specified player");
95+
sender.sendMessage(ChatColor.AQUA + "/spb clearbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the bypass for you or the specified player");
96+
sender.sendMessage(ChatColor.AQUA + "/spb overridestatus <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Overrides the accessible status of a specific server, over anything else");
97+
sender.sendMessage(ChatColor.AQUA + "/spb clearoverride <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the overriden status of a specific server");
7898
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
7999
}
80100
}

Spigot Addon/src/main/java/com/jaimemartz/playerbalanceraddon/PluginMessageManager.java

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ public void connectPlayer(Player player, String section) {
5252
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
5353
}
5454

55+
public void fallbackPlayer(Player player) {
56+
ByteArrayDataOutput out = ByteStreams.newDataOutput();
57+
out.writeUTF("FallbackPlayer");
58+
out.writeUTF(player.getName());
59+
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
60+
}
61+
5562
public boolean getSectionByName(String section, Consumer<String> consumer) {
5663
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
5764
if (player == null) {
@@ -92,26 +99,6 @@ public boolean getSectionByServer(String server, Consumer<String> consumer) {
9299
return true;
93100
}
94101

95-
public boolean getSectionPlayerCount(String section, Consumer<Integer> consumer) {
96-
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
97-
if (player == null) {
98-
return false;
99-
}
100-
101-
ByteArrayDataOutput out = ByteStreams.newDataOutput();
102-
out.writeUTF("GetSectionPlayerCount");
103-
out.writeUTF(section);
104-
105-
contexts.put(new MessageContext(
106-
"PlayerBalancer",
107-
"GetSectionPlayerCount",
108-
player.getUniqueId()
109-
), (response) -> consumer.accept(response.readInt()));
110-
111-
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
112-
return true;
113-
}
114-
115102
public void getSectionOfPlayer(Player player, Consumer<String> consumer) {
116103
ByteArrayDataOutput out = ByteStreams.newDataOutput();
117104
out.writeUTF("GetSectionOfPlayer");
@@ -146,11 +133,24 @@ public boolean getServerStatus(String server, Consumer<String> consumer) {
146133
return true;
147134
}
148135

149-
public void fallbackPlayer(Player player) {
136+
public boolean getSectionPlayerCount(String section, Consumer<Integer> consumer) {
137+
Player player = Iterables.getFirst(plugin.getServer().getOnlinePlayers(), null);
138+
if (player == null) {
139+
return false;
140+
}
141+
150142
ByteArrayDataOutput out = ByteStreams.newDataOutput();
151-
out.writeUTF("FallbackPlayer");
152-
out.writeUTF(player.getName());
143+
out.writeUTF("GetSectionPlayerCount");
144+
out.writeUTF(section);
145+
146+
contexts.put(new MessageContext(
147+
"PlayerBalancer",
148+
"GetSectionPlayerCount",
149+
player.getUniqueId()
150+
), (response) -> consumer.accept(response.readInt()));
151+
153152
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
153+
return true;
154154
}
155155

156156
public boolean clearStatusOverride(String server) {
@@ -194,7 +194,6 @@ public void setPlayerBypass(Player player) {
194194
player.sendPluginMessage(plugin, "PlayerBalancer", out.toByteArray());
195195
}
196196

197-
//TODO Add this to the /balancer or some other command too
198197
public void bypassConnect(Player player, String server) {
199198
ByteArrayDataOutput out = ByteStreams.newDataOutput();
200199
out.writeUTF("BypassConnect");

0 commit comments

Comments
 (0)