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

Commit

Permalink
FPlayer: fix parall tabcomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Aug 1, 2023
1 parent 3ca7de2 commit 272f545
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/net/flectone/custom/FTabCompleter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

public class FTabCompleter implements CommandExecutor, TabCompleter {

protected String commandName;
protected List<String> wordsList = new ArrayList<>();
protected List<String> wordsList = Collections.synchronizedList(new ArrayList<>());

public String getCommandName() {
return commandName;
}

protected void isStartsWith(String arg, String string) {
if (string.toLowerCase().startsWith(arg.toLowerCase()) || arg.replace(" ", "").isEmpty()) {
if(wordsList.contains(string)) return;
wordsList.add(string);
}
}
Expand All @@ -40,7 +38,7 @@ protected void addKeysFile(FileManager fileManager, String arg) {

protected void isOfflinePlayer(String arg) {
FPlayerManager.getPlayers().parallelStream().filter(Objects::nonNull)
.forEach(offlinePlayer -> isStartsWith(arg, offlinePlayer.getRealName()));
.forEachOrdered(offlinePlayer -> isStartsWith(arg, offlinePlayer.getRealName()));
}

protected void isOnlinePlayer(String arg) {
Expand Down

0 comments on commit 272f545

Please sign in to comment.