fix: prevent npe on empty profile name

This commit is contained in:
aro 2023-01-15 18:29:07 +01:00
parent 3ad1adb264
commit 593e69c797
4 changed files with 12 additions and 8 deletions

View file

@ -86,11 +86,12 @@ public class v1_17_R1 implements Internals {
final CraftPlayer craftPlayer = (CraftPlayer) player;
final EntityPlayer entityPlayer = craftPlayer.getHandle();
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
final String profileName = profile.getName() == null ? player.getName() : profile.getName();
Optional<MojangSkin> skin;
final PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.e, entityPlayer);
final PacketPlayOutPlayerInfo add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profile.getName());
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
if (skinChange || changeOnlyName) {
try {
@ -117,7 +118,7 @@ public class v1_17_R1 implements Internals {
add.b().clear();
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
player.getPing(),
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profile.getName())));
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
entityPlayer.b.sendPacket(remove);
entityPlayer.b.sendPacket(add);