1.15.2 Weird error with getting offline player heads

Discussion in 'Spigot Plugin Development' started by VoidMC, Feb 18, 2020.

  1. I don't even know how to describe this - there are no errors in the code, so I can't even show a log.

    I have a GUI that displays player heads and the player's name above, which looks like this:
    However, after about 5-10 seconds, for seemingly no reason, it changes to this: *For the record, it does this even without reloading.

    Here is the code that is used in this section:
    Code (Java):
    inventory.clear(); //Get rid of the inventory, avoids stacking.
            List<String> lore = new ArrayList();    
            List<?> members = plugin.getGenerators().getList("Generators." + generator.name + ".Members"); //Gets the UUID from generators.yml
            for(int i = 0; i < 5; ++i) { //Sets a row of skeleton skulls.
                lore.add(ChatColor.GRAY + "No member added.");
                int member = i+1;
                inventory.setItem(11+i, createGuiItem(Material.SKELETON_SKULL, ChatColor.DARK_GRAY + "Member " + member, lore));
            //Check how many members exist
            for(int i = 0; i < members.size(); ++i) { //Repeats for how many members there are.
                //Gets UUID Stuff
                String player_uuid_string = (String) members.get(i);
                UUID player_uuid = UUID.fromString(player_uuid_string);
                OfflinePlayer player = Bukkit.getOfflinePlayer(player_uuid);
                Log.info("UUIDSTR: " + player_uuid_string);
                Log.info("UUID: " + player_uuid);
                Log.info("NAME:" + player.getName());
                lore.add(ChatColor.GRAY + player.getName());
                int number = i + 1;
                inventory.setItem(11+i, createGuiHead(player, ChatColor.DARK_GRAY + "Member " + number , lore)); //Create the head

    Code (Java):
    private ItemStack createGuiHead(OfflinePlayer player, String name, List lore) {
            ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
            SkullMeta meta = (SkullMeta) item.getItemMeta();
            //Set item display name.
            //Set the lore.
            ArrayList<String> metaLore = new ArrayList<String>();
            for(int i = 0; i < lore.size(); ++i)
                metaLore.add((String) lore.get(i));
            return item;

    In the console, I logged the 'player_uuid_string', 'player_uuid' variables and player.getName().
    Heres the output after opening and closing the GUI.
    Code (Text):
    [INFO] UUIDSTR: 069a79f4-44e9-4726-a5be-fca90e38aaf5
    [INFO] UUID: 069a79f4-44e9-4726-a5be-fca90e38aaf5
    [INFO] NAME:Notch
    [INFO] UUIDSTR: 069a79f4-44e9-4726-a5be-fca90e38aaf5
    [INFO] UUID: 069a79f4-44e9-4726-a5be-fca90e38aaf5
    [INFO] NAME:null
    I really do not understand what is going on here, anyone have any idea?? I don't understand why it can't fetch the name/skull again with the UUID if it has already been done before.
    If you need more information, let me know :)
    #1 VoidMC, Feb 18, 2020
    Last edited: Feb 18, 2020
  2. I still don't have a solution, however I think it is due to trying to fetch an offline player, who has never joined before. For some reason it bugs out. I've just made it now so that if they have never joined, it reject it.

    If anyone has any idea still, please let me know as it could also help others out experiencing this issue in the future :)