John Smith John Smith - 2 months ago 26
Java Question

Java HashMaps with bukkit

And how to add 2 enchantments at once in bukkit with

myItem.addEnchantments( Enchantment.KNOCKBACK, 1 /* TODO Here goes 2nd enchantment */ );

'addEnchantments' accepts 'addEnchantments(Map < Enchantment, int >)'


You rather use addEnchantment twice (or more):

myItem.addEnchantment(Enchantment.KNOCKBACK, 1);
myItem.addEnchantment(Enchantment.THRONS, 2);

If you insist on using addEnchantments you'll need to create a map, populate it and pass it:

Map<Enhancement, Integer> map = new HashMap<Enhancement, Integer>();
map.put(Enchantment.KNOCKBACK, 1);
map.put(Enchantment.THRONS, 2);


In your case, I would go with option 1