Skip to content

Add @s and @p selector support #6110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,10 @@ public User matchUser(final Server server, final User sourceUser, final String s
final User user;
Player exPlayer;

if (sourceUser != null && (searchTerm.equals("@p") || searchTerm.equals("@s"))) {
return sourceUser;
}

try {
exPlayer = server.getPlayer(UUID.fromString(searchTerm));
} catch (final IllegalArgumentException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ protected void loopOfflinePlayersConsumer(final Server server, final CommandSour
throw new PlayerNotFoundException();
}

if (sender.isPlayer() && (searchTerm.equals("@s") || searchTerm.equals("@p"))) {
userConsumer.accept((User) sender.getUser());
return;
}

final UUID uuid = StringUtil.toUUID(searchTerm);
if (uuid != null) {
final User matchedUser = ess.getUser(uuid);
Expand Down Expand Up @@ -78,6 +83,11 @@ protected void loopOnlinePlayersConsumer(final Server server, final CommandSourc
throw new PlayerNotFoundException();
}

if (sender.isPlayer() && (searchTerm.equals("@s") || searchTerm.equals("@p"))) {
userConsumer.accept((User) sender.getUser());
return;
}

final boolean skipHidden = sender.isPlayer() && !ess.getUser(sender.getPlayer()).canInteractVanished();

if (matchWildcards && (searchTerm.contentEquals("**") || searchTerm.contentEquals("*"))) {
Expand Down
Loading