Solved Getting Enchantment List

Discussion in 'Plugin Development' started by mrCookieSlime, Nov 23, 2013.

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

    mrCookieSlime

    Hey, I just wanna know how to get all Enchantment Types for an Item.

    For Example:
    I have a Sword and wanna know which Enchantments this Item may have.
    In this Case:
    Fire Aspect, Knockback, Sharpness,...

    So is there any way to get a List of Enchantments which only work for a certain Type of Material?
     
  2. Offline

    Chinwe

    Loop through Enchantment.values(), and for each use enchantment.canEnchantItem(itemstack), and if this is true, add the name of it to a List/StringBuilder to send to the player!
     
    mrCookieSlime likes this.
  3. Offline

    mrCookieSlime

    Chinwe
    Thanks :) This was exactly the Method I was looking for

    But also another Question:
    -Is there a .isEnchantable() Method

    If not, I can just check for the length of the List ^^
     
  4. Offline

    DarkBladee12

  5. Offline

    mrCookieSlime

    DarkBladee12
    Neat Utility, but doesn't help in my case. Anyway found the Solution already.
    But well, it doesn't help me, cause I need something which contains all future Enchantments and Mod Enchantments as well, so Enchantment.values() is the Method I prefer.
     
  6. Offline

    DarkBladee12

    mrCookieSlime ah ok, in that case this way of getting the applicable enchantments of an item is better than my class. It is not as efficient as the utility though, because you have to loop through all enchantments every time you want to check them.
     
  7. Offline

    mrCookieSlime

    DarkBladee12
    That's fine for me. Anyway just gonna loop through it once. I'm basicly making a Mysterious Enchanter for my Plugin Slimefun and there you see all possible Enchantments for your Item and can choose what Enchantment and what Level you want... :) And I discovered that MCPC+ adds Mod's Enchantments to Enchantment.values(), so you can actually put Mod's Enchantments on your Items as well :D
     
Thread Status:
Not open for further replies.

Share This Page