Editing ItemStacks in lists not working?

Discussion in 'Plugin Development' started by bowlerguy66, Jan 8, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    bowlerguy66

    I'm editing ItemStacks in a list, but when I change the displayname it isn't updating in the player inventory. I know it should work, but it isn't for me :I Check out my code:

    Code:
        public void loadTimer() {
           
            Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                public void run() {
                    for(ItemStack i : loads) {
                                           
                        ItemMeta im = i.getItemMeta();
                                   
                        int theirtime;
                       
                        if(loadtime.containsKey(i)) {
                            theirtime = loadtime.get(i);
                        } else {
                            theirtime = 3;
                        }
       
                        Bukkit.broadcastMessage(theirtime + "");
                       
                        if(theirtime == 0) {
                                   
                            im.setDisplayName(ChatColor.WHITE + "Musket - " + ChatColor.GRAY + "Loaded"); // <----- Change name
                            i.setItemMeta(im); // "i" is an Item in the list
                                                   
                            loadtime.remove(i);
                            loads.remove(i);
                           
                            Bukkit.broadcastMessage(im.getDisplayName() + ", name");
    
                            return;
                           
                        }
                                           
                        loadtime.put(i, theirtime - 1);
                        return;
                       
                    }
                }
            }, 0L, 20L);
    
        }
    The plugin doesn't throw any errors also
     
  2. Offline

    ProSl3nderMan

    Try updating their inventory: player.getPlayer().updateInventory();
     
Thread Status:
Not open for further replies.

Share This Page