Skip to content

Commit 8c7ef90

Browse files
authored
paper: Fix handling of empty slash buffer in async suggestion listener (#327)
1 parent aa00e33 commit 8c7ef90

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/AsyncCommandSuggestionsListener.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ final class AsyncCommandSuggestionsListener<C> implements Listener {
4242

4343
@EventHandler
4444
void onTabCompletion(final @NonNull AsyncTabCompleteEvent event) {
45-
if (event.getBuffer().trim().isEmpty()) {
45+
/* Turn '(/)plugin:command arg1 arg2 ...' into 'plugin:command arg1 arg2 ...' */
46+
final String strippedBuffer = event.getBuffer().startsWith("/")
47+
? event.getBuffer().substring(1)
48+
: event.getBuffer();
49+
if (strippedBuffer.trim().isEmpty()) {
4650
return;
4751
}
4852

4953
@SuppressWarnings("unchecked")
5054
final BukkitPluginRegistrationHandler<C> bukkitPluginRegistrationHandler =
5155
(BukkitPluginRegistrationHandler<C>) this.paperCommandManager.getCommandRegistrationHandler();
5256

53-
/* Turn '(/)plugin:command arg1 arg2 ...' into 'plugin:command' */
54-
final String commandLabel = (event.getBuffer().startsWith("/")
55-
? event.getBuffer().substring(1)
56-
: event.getBuffer())
57-
.split(" ")[0];
57+
/* Turn 'plugin:command arg1 arg2 ...' into 'plugin:command' */
58+
final String commandLabel = strippedBuffer.split(" ")[0];
5859
if (!bukkitPluginRegistrationHandler.isRecognized(commandLabel)) {
5960
return;
6061
}

0 commit comments

Comments
 (0)