Getting specific items from inventory

Discussion in 'Plugin Development' started by DeamonZ, Apr 16, 2014.

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

    DeamonZ

    Hello,

    I'm making a minigame plugin and I've made some classes with there lore set as
    Code:java
    1. ChatColor.GOLD + "Soulbound"

    When they switch to a other class I want to remove all items from a inventory with the lore set as "soulbound". Any idea how to do this?
     
  2. Offline

    DoctorDark

    Code:java
    1.  
    2. [syntax=java]for (ItemStack contents : player.getInventory().getContents()) {
    3.  
    4. if (contents.hasItemMeta()) {
    5.  
    6. if (contents.getItemMeta().getLore().equals(ChatColor.GOLD + "Soulbound")) {
    7.  
    8. //perform whatever
    9.  
    10. }
    11.  
    12. }
    13.  
    14. }[/syntax]
    15.  
     
    DeamonZ likes this.
  3. Offline

    DeamonZ

    thanks
     
  4. Offline

    Gater12

    DeamonZ
    getLore() returns a List<String> not a String, so that wouldn't work.

    Code:java
    1. contents.getItemMeta().getLore().contains(ChatColor.GOLD + "Soulbound");
     
  5. Offline

    DoctorDark

    if (contents.getItemMeta().getLore().get(0).equalsIgnoreCase(ChatColor.GOLD+"Soulbound")) {

    }
     
Thread Status:
Not open for further replies.

Share This Page