fix: prevent npe on empty profile name
This commit is contained in:
parent
3ad1adb264
commit
593e69c797
4 changed files with 12 additions and 8 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -88,11 +88,12 @@ public class v1_18_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 {
|
||||
|
@ -119,7 +120,7 @@ public class v1_18_R1 implements Internals {
|
|||
add.b().clear();
|
||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
||||
player.getPing(),
|
||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profile.getName())));
|
||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
||||
entityPlayer.b.a(remove);
|
||||
entityPlayer.b.a(add);
|
||||
|
||||
|
|
|
@ -88,11 +88,12 @@ public class v1_18_R2 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 {
|
||||
|
@ -119,7 +120,7 @@ public class v1_18_R2 implements Internals {
|
|||
add.b().clear();
|
||||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
||||
player.getPing(),
|
||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profile.getName())));
|
||||
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
|
||||
entityPlayer.b.a(remove);
|
||||
entityPlayer.b.a(add);
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ public class v1_19_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 add = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a);
|
||||
|
@ -97,7 +98,7 @@ public class v1_19_R1 implements Internals {
|
|||
|
||||
// "It's a Surprise Tool That Will Help Us Later!"
|
||||
final ProfilePublicKey.a key = remove.b().get(0).e();
|
||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profile.getName());
|
||||
final GameProfile gameProfile = new GameProfile(player.getUniqueId(), profileName);
|
||||
|
||||
if (skinChange || changeOnlyName) {
|
||||
try {
|
||||
|
@ -126,7 +127,7 @@ public class v1_19_R1 implements Internals {
|
|||
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
|
||||
player.getPing(),
|
||||
EnumGamemode.a(player.getGameMode().ordinal()),
|
||||
IChatBaseComponent.a(profile.getName()),
|
||||
IChatBaseComponent.a(profileName),
|
||||
key)); // f mojang
|
||||
|
||||
entityPlayer.b.a(remove);
|
||||
|
|
Loading…
Reference in a new issue