-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updated VoiceCommand TabCompletion -> is now shared/common function - Updated voicecommands's /voice setup since it didn't save port as Integer - Updated the network thing to show more logical error
1 parent
46e9101
commit 1240edb
Showing
6 changed files
with
109 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/io/greitan/avion/common/utils/HasPermissionOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.greitan.avion.common.utils; | ||
|
||
public interface HasPermissionOperation { | ||
boolean execute(String permission); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/greitan/avion/common/utils/VoiceCommandCompletions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.greitan.avion.common.utils; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import io.greitan.avion.common.utils.HasPermissionOperation; | ||
|
||
public class VoiceCommandCompletions { | ||
public static List<String> execute(String[] args, HasPermissionOperation hasPermission) { | ||
List<String> completions = List.of(); | ||
|
||
// Main command arguments. | ||
if (args.length == 1 || args.length == 0) { | ||
List<String> options = List.of("bind", "setup", "connect", "reload", "settings"); | ||
completions = options.stream().filter(val -> (args.length == 0 || val.startsWith(args[0])) && hasPermission.execute("voice." + val)).collect(Collectors.toList()); | ||
} | ||
|
||
// Setup command arguments. | ||
if (args.length == 2 && args[0].equalsIgnoreCase("setup") && hasPermission.execute("voice.setup")) { | ||
List<String> options = List.of("host port key"); | ||
completions = options.stream().filter(val -> val.startsWith(args[1])).collect(Collectors.toList()); | ||
} | ||
|
||
// Connect command arguments. | ||
if (args.length == 2 && args[0].equalsIgnoreCase("connect") && hasPermission.execute("voice.connect")) { | ||
List<String> options = List.of("true", "false"); | ||
completions = options.stream().filter(val -> val.startsWith(args[1])).collect(Collectors.toList()); | ||
} | ||
|
||
return completions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters