use of com.laytonsmith.core.exceptions.CRE.CREEnchantmentException in project CommandHelper by EngineHub.
the class ObjectGenerator method enchants.
public Map<MCEnchantment, Integer> enchants(CArray enchantArray, Target t) {
Map<MCEnchantment, Integer> ret = new HashMap<>();
for (String key : enchantArray.stringKeySet()) {
try {
CArray ea = (CArray) enchantArray.get(key, t);
String setype = ea.get("etype", t).val();
MCEnchantment etype = StaticLayer.GetConvertor().GetEnchantmentByName(setype);
int elevel = Static.getInt32(ea.get("elevel", t), t);
if (etype == null) {
if (setype.equals("SWEEPING")) {
// data from 1.11.2, changed in 1.12
etype = StaticLayer.GetEnchantmentByName("SWEEPING_EDGE");
}
if (etype == null) {
throw new CREEnchantmentException("Unknown enchantment type at " + key, t);
}
}
ret.put(etype, elevel);
} catch (ClassCastException cce) {
throw new CREFormatException("Expected an array at index " + key, t);
}
}
return ret;
}
Aggregations