Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/net/elytrium/velocitytools/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public static class FIND {
public String USERNAME_NEEDED = "&cYou must supply the username.";
public String PLAYER_ONLINE_AT = "&6{0} &fis online at &6{1}";
public String PLAYER_NOT_ONLINE = "&6{0} &fis not online.";

@Comment(@CommentValue("List of players that cannot be found using /find command"))
public List<String> FIND_BLACKLIST = List.of("player1", "player2");
}

public static class SEND {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public class FindCommand implements SimpleCommand {
private final ProxyServer server;
private final Component usernameNeeded;
private final String playerOnlineAt;
private final List<String> blacklist;

public FindCommand(ProxyServer server) {
this.server = server;
this.usernameNeeded = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.FIND.USERNAME_NEEDED);
this.playerOnlineAt = Settings.IMP.COMMANDS.FIND.PLAYER_ONLINE_AT;
this.blacklist = Settings.IMP.COMMANDS.FIND.FIND_BLACKLIST;
}

@Override
Expand All @@ -50,11 +52,13 @@ public List<String> suggest(SimpleCommand.Invocation invocation) {
if (args.length == 0) {
return this.server.getAllPlayers().stream()
.map(Player::getUsername)
.filter(name -> !blacklist.contains(name))
.collect(Collectors.toList());
} else if (args.length == 1) {
return this.server.getAllPlayers().stream()
.map(Player::getUsername)
.filter(name -> name.regionMatches(true, 0, args[0], 0, args[0].length()))
.filter(name -> !blacklist.contains(name))
.collect(Collectors.toList());
} else {
return ImmutableList.of();
Expand All @@ -70,7 +74,7 @@ public void execute(SimpleCommand.Invocation invocation) {
source.sendMessage(this.usernameNeeded);
} else {
Optional<Player> player = this.server.getPlayer(args[0]);
if (player.isPresent()) {
if (player.isPresent() && !blacklist.contains(player.get().getUsername())) {
Player player0 = player.get();
Optional<ServerConnection> server = player0.getCurrentServer();
server.ifPresent(srv ->
Expand Down