Getting Custom Inventory to Update?

Discussion in 'Plugin Development' started by SneakyBruh, Oct 4, 2017.

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

    SneakyBruh

    basically simpler checking the players level and determining on what to set the clay... (i know there are simplier ways but i find it easier to use this). I was wondering on how to constantly update this inventory so if they rankup the red clay will turn into green?

    Code:
       if(cfg.getInt(player.getUniqueId()+"."+"rank")>=4){
    
            ItemStack sonic = new ItemStack(Material.STAINED_CLAY, 1, (byte) 5);
    
                ItemMeta sonicmeta = sonic.getItemMeta();
    
                sonicmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&',"&a&lSonic"));
    
                sonicmeta.setLore(Arrays.asList(ChatColor.AQUA+"Recieve Speed 5 after a kill",ChatColor.RED+"REQUIRES LVL: 4"));
    
                sonic.setItemMeta(sonicmeta);
    
        inv.setItem(7,newItemStack(sonic));
    
        }else{
    
            ItemStack sonic = new ItemStack(Material.STAINED_CLAY, 1, (byte) 14);
    
                ItemMeta sonicmeta = sonic.getItemMeta();
    
                sonicmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&',"&4&lSonic"));
    
                sonicmeta.setLore(Arrays.asList(ChatColor.AQUA+"Recieve Speed 5 after a kill",ChatColor.RED+"REQUIRES LVL: 4",ChatColor.GRAY+"LOCKED"));
    
                sonic.setItemMeta(sonicmeta);
    
            inv.setItem(7, new ItemStack(sonic));
    
        }
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    @SneakyBruh Well, they open the inventory sometime, why not update it then?
     
  3. Offline

    SneakyBruh

    The problem i had was trying to get a method that updates inv (Inventory inv = Bukkit.createInventory(...)
     
  4. Offline

    timtower Administrator Administrator Moderator

    Get the old inventory, make the changes, open the inventory.
     
  5. Offline

    SneakyBruh

    Thanks! worked like a charm!
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page