-
Type:
Bug
-
Resolution: Invalid
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
None
-
Environment:
Linux
Setting the contents of an offline player causes an [NPE|. Here is the sample code used:
Bar.java
private void clear(World world, UUID playerUUID) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerUUID); if (offlinePlayer.hasPlayedBefore()) { String playerName = offlinePlayer.getName(); playerUUID = offlinePlayer.getUniqueId(); MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer(); WorldServer worldServer = ((CraftWorld) world).getHandle(); GameProfile gameProfile = new GameProfile(playerUUID, playerName); PlayerInteractManager playerInteractManager = new PlayerInteractManager(worldServer); EntityPlayer entityPlayer = new EntityPlayer(minecraftServer, worldServer, gameProfile, playerInteractManager); Player player = entityPlayer.getBukkitEntity(); if (player != null) { player.loadData(); PlayerInventory inventory = player.getInventory(); inventory.clear(); inventory.setArmorContents(new ItemStack[inventory.getArmorContents().length]); player.saveData(); } } }