Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Commands: add mode change for visual tab-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Oct 7, 2023
1 parent c497dd3 commit f756021
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

if (strings.length == 1) {
isOfflinePlayer(strings[0]);
isConfigOnlineModePlayer(strings[0]);
}

Collections.sort(wordsList);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/flectone/commands/CommandIgnore.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

if (strings.length == 1) {
isOfflinePlayer(strings[0]);
isConfigOnlineModePlayer(strings[0]);
}

Collections.sort(wordsList);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/flectone/commands/CommandMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

switch (strings.length){
case 1 -> isOfflinePlayer(strings[0]);
case 1 -> isConfigOnlineModePlayer(strings[0]);
case 2 -> isTabCompleteMessage(strings[1]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/flectone/commands/CommandMute.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

switch (strings.length){
case 1 -> isOfflinePlayer(strings[0]);
case 1 -> isConfigOnlineModePlayer(strings[0]);
case 2 -> isFormatString(strings[1]);
case 3 -> isTabCompleteMessage(strings[2], "tab-complete.reason");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/flectone/commands/CommandTempban.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

switch (strings.length) {
case 1 -> isOfflinePlayer(strings[0]);
case 1 -> isConfigOnlineModePlayer(strings[0]);
case 2 -> {
isFormatString(strings[1]);
isStartsWith(strings[1], "permanent");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/flectone/commands/CommandWarn.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull
wordsList.clear();

switch (strings.length){
case 1 -> isOfflinePlayer(strings[0]);
case 1 -> isConfigOnlineModePlayer(strings[0]);
case 2 -> isFormatString(strings[1]);
case 3 -> isTabCompleteMessage(strings[2], "tab-complete.reason");
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/flectone/misc/commands/FTabCompleter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ default void isFileKey(@NotNull FYamlConfiguration file, @NotNull String arg) {
.forEachOrdered(key -> isStartsWith(arg, key));
}

default void isConfigOnlineModePlayer(@NotNull String arg) {
if (FileManager.config.getString("command." + getCommandName() + ".tab-complete-mode").equals("offline")) {
isOfflinePlayer(arg);
return;
}

isOnlinePlayer(arg);
}

default void isOfflinePlayer(@NotNull String arg) {
offlinePlayerList.parallelStream().forEachOrdered(offlinePlayer -> isStartsWith(arg, offlinePlayer));
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ command:
announce: true
count-for-ban: 3

# Command tab-complete mode: offline/online
tab-complete-mode: "offline"

warnlist:
enable: true
per-page: 4
Expand Down Expand Up @@ -271,6 +274,9 @@ command:
firstonline:
enable: true

# Command tab-complete mode: offline/online
tab-complete-mode: "offline"

flectonechat:
enable: true

Expand All @@ -282,6 +288,9 @@ command:
ignore:
enable: true

# Command tab-complete mode: offline/online
tab-complete-mode: "offline"

ignorelist:
enable: true
per-page: 4
Expand Down Expand Up @@ -312,10 +321,16 @@ command:
msg:
enable: true

# (only for visual) Command tab-complete mode: offline/online
tab-complete-mode: "offline"

mute:
enable: true
announce: true

# (only for visual) Command tab-complete mode: offline/online
tab-complete-mode: "offline"

mutelist:
enable: true
per-page: 4
Expand Down Expand Up @@ -350,6 +365,9 @@ command:
enable: true
announce: true

# (only for visual) Command tab-complete mode: offline/online
tab-complete-mode: "offline"

tic-tac-toe:
enable: true

Expand Down

0 comments on commit f756021

Please sign in to comment.