John Smith John Smith - 1 year ago 149
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 >)'

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download