diff --git a/pom.xml b/pom.xml
index 0fda030..4634371 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
eu.endermite
CommandWhitelist
- 1.7.7
+ 1.7.8
jar
CommandWhitelist
diff --git a/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/PlayerCommandPreProcessListener.java b/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/PlayerCommandPreProcessListener.java
index 1529dc7..3a73609 100644
--- a/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/PlayerCommandPreProcessListener.java
+++ b/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/PlayerCommandPreProcessListener.java
@@ -27,10 +27,9 @@ public class PlayerCommandPreProcessListener implements Listener {
for (String comm : s.getValue()) {
comm = comm.toLowerCase();
if (command.equalsIgnoreCase(comm) || command.startsWith(comm + " ")) {
- String rawCmd = event.getMessage();
List bannedSubCommands = CommandsList.getSuggestions(player);
for (String bannedSubCommand : bannedSubCommands) {
- if (rawCmd.startsWith(bannedSubCommand)) {
+ if (command.startsWith(bannedSubCommand)) {
event.setCancelled(true);
ConfigCache config = CommandWhitelist.getConfigCache();
player.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getPrefix() + RandomStuff.getMessage(config.getCommandDeniedList(), config.getSubCommandDenied())));
diff --git a/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/TabCompleteBlockerListener.java b/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/TabCompleteBlockerListener.java
index 9c61816..a7dada1 100644
--- a/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/TabCompleteBlockerListener.java
+++ b/src/main/java/eu/endermite/commandwhitelist/spigot/listeners/TabCompleteBlockerListener.java
@@ -14,14 +14,22 @@ public class TabCompleteBlockerListener implements Listener {
return;
Player player = (Player) event.getSender();
String buffer = event.getBuffer();
- String cmd = buffer.replace(CommandsList.getLastArgument(buffer), "");
+
List blockedCommands = CommandsList.getSuggestions(player);
List suggestions = event.getCompletions();
+
for (String s : blockedCommands) {
String slast = CommandsList.getLastArgument(s);
String scommand = s.replace(slast, "");
- cmd = cmd.replace(CommandsList.getLastArgument(cmd), "");
- if (cmd.startsWith("/" + scommand)) {
+ String[] cmdSplit = buffer.split(" ");
+ StringBuilder cmdBuilder = new StringBuilder();
+ for (int i = 0; i <= cmdSplit.length-1; i++)
+ cmdBuilder.append(cmdSplit[i]).append(" ");
+
+ String cmd = cmdBuilder.toString();
+ if (cmd.startsWith("/"+scommand)) {
+ // This sometimes throws exceptions. No clue why, it just does. try/catch is the only fix.
+ // Probably happening when plugin adds suggestions in this event on the same priority - not confirmed.
try {
while (suggestions.contains(slast))
suggestions.remove(slast);