append new text instead of concatenating (#330)

This commit is contained in:
Chipmunk 2022-12-27 17:49:24 +00:00 committed by GitHub
parent baddda61aa
commit 411cdaa104
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -35,9 +35,13 @@ public final class CommandDestroyEntities implements CommandExecutor {
worldCount++;
}
sender.sendMessage(Component.text(
"Successfully destroyed " + entityCount + " entities in "
+ worldCount + " worlds"));
sender.sendMessage(
Component.text("Successfully destroyed ")
.append(Component.text(entityCount))
.append(Component.text(" entities in "))
.append(Component.text(worldCount))
.append(Component.text(" worlds"))
);
return true;
}
}

View file

@ -54,8 +54,12 @@ public final class CommandPing implements CommandExecutor {
break;
}
sender.sendMessage(Component.text((args.length == 0 ?
"Your" : target.getName() + "'s") + " ping is ")
Component namePrefix = args.length == 0
? Component.text("Your")
: Component.text(target.getName()).append(Component.text("'s"));
sender.sendMessage(namePrefix
.append(Component.text(" ping is "))
.append(Component.text(ping, highlighting))
.append(Component.text("ms.", highlighting)));
return true;