AddUnsafeEnchantment Still Throws IllegalArgumentException

Discussion in 'Plugin Development' started by Zach_1919, Jul 29, 2013.

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

    Zach_1919

    I have a series of video tutorials that teach how to make a Bukkit plugin. I did one on ItemMeta and Enchantments, and I had someone who was very confuse, and so am I. In my code, I originally used the addEnchantment() method, but I got an IllegalArgumentException, because my desired level for the enchantment was 8. I changed addEnchantment() to addUnsafeEnchantment() and the error was gone and it worked just fine. Someone in the comments showed me his code and he had everything just like I did, but he was still getting the IllegalArgumentException, even though he changed to addUnsafeEnchantment(). Help as to why this is working for me, and not him?

    His Code
    His Error (code has been changed so the line numbers no longer match up)

    My Code
     
  2. Offline

    Zach_1919

  3. Offline

    adam753

    Well, the error says he tried to add an enchantment of level 10, when of course the possible range is 1-5. But in your code, the only possible places that can be happening, it says you're using level 5... So I have to ask, are you sure the error and code are both up to date? That is, is this the most recent code, and is it the exact same code that produced that error?
     
Thread Status:
Not open for further replies.

Share This Page