SPIGOT-7486: Alternate approach to null profile names

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-09-22 07:36:30 +10:00
parent fb7dc796d5
commit 3ff2a7bc12
7 changed files with 28 additions and 91 deletions

View File

@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.block;
import com.google.common.base.Preconditions;
import com.mojang.authlib.GameProfile;
import net.minecraft.SystemUtils;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.block.entity.TileEntitySkull;
@@ -16,7 +17,6 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Rotatable;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.profile.CraftGameProfile;
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.profile.PlayerProfile;
@@ -84,11 +84,11 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
@Override
public OfflinePlayer getOwningPlayer() {
if (profile != null) {
if (profile.getId() != null) {
if (!profile.getId().equals(SystemUtils.NIL_UUID)) {
return Bukkit.getOfflinePlayer(profile.getId());
}
if (profile.getName() != null) {
if (!profile.getName().isEmpty()) {
return Bukkit.getOfflinePlayer(profile.getName());
}
}
@@ -103,7 +103,7 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
if (player instanceof CraftPlayer) {
this.profile = ((CraftPlayer) player).getProfile();
} else {
this.profile = new CraftGameProfile(player.getUniqueId(), player.getName());
this.profile = new GameProfile(player.getUniqueId(), player.getName());
}
}