Skip to content

Commit e122889

Browse files
committed
Actually handle entity uuids
1 parent fc78084 commit e122889

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/net/earthcomputer/clientcommands/command/arguments/ClientEntityArgumentType.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ClientEntitySelector parse() throws CommandSyntaxException {
143143
if (reader.canRead() && reader.peek() == '@') {
144144
parseAtSelector();
145145
} else {
146-
parsePlayerName();
146+
parsePlayerNameOrUuid();
147147
}
148148

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

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

180180
int start = reader.getCursor();
181181
String playerName = reader.readString();
182+
try {
183+
UUID uuid = UUID.fromString(playerName);
184+
filter = (origin, entity) -> entity.getUuid().equals(uuid);
185+
limit = 1;
186+
return;
187+
} catch (IllegalArgumentException ignore) {
188+
// we don't have a uuid, check player names
189+
}
190+
182191
if (playerName.isEmpty() || playerName.length() > 16) {
183192
reader.setCursor(start);
184193
throw EntitySelectorReader.INVALID_ENTITY_EXCEPTION.createWithContext(reader);

0 commit comments

Comments
 (0)