Skip to content

Commit

Permalink
Actually handle entity uuids
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Jul 8, 2021
1 parent fc78084 commit e122889
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ ClientEntitySelector parse() throws CommandSyntaxException {
if (reader.canRead() && reader.peek() == '@') {
parseAtSelector();
} else {
parsePlayerName();
parsePlayerNameOrUuid();
}

if (boxX != null || boxY != null || boxZ != null) {
Expand All @@ -166,7 +166,7 @@ ClientEntitySelector parse() throws CommandSyntaxException {
return new ClientEntitySelector(filter, sorter, limit, senderOnly, originX, originY, originZ);
}

void parsePlayerName() throws CommandSyntaxException {
void parsePlayerNameOrUuid() throws CommandSyntaxException {
if (reader.canRead()) {
int start = reader.getCursor();
suggestor = (builder, playerNameSuggestor) -> {
Expand All @@ -179,6 +179,15 @@ void parsePlayerName() throws CommandSyntaxException {

int start = reader.getCursor();
String playerName = reader.readString();
try {
UUID uuid = UUID.fromString(playerName);
filter = (origin, entity) -> entity.getUuid().equals(uuid);
limit = 1;
return;
} catch (IllegalArgumentException ignore) {
// we don't have a uuid, check player names
}

if (playerName.isEmpty() || playerName.length() > 16) {
reader.setCursor(start);
throw EntitySelectorReader.INVALID_ENTITY_EXCEPTION.createWithContext(reader);
Expand Down

0 comments on commit e122889

Please sign in to comment.