Closed Joo200 closed 2 years ago
Hi,
implementing a general solution to this problem will take some time. In the meantime you can write your own Converter
implementation or convert the map using an additional field and the postLoad
hook.
final class MaterialMapConverter implements
Converter<Map<Material, Double>, Map<String, Double>> {
@Override
public Map<String, Double> convertTo(
Map<Material, Double> element, ConversionInfo info
) {
return element.entrySet().stream()
.collect(toMap(
o -> o.getKey().toString(),
Map.Entry::getValue
));
}
@Override
public Map<Material, Double> convertFrom(
Map<String, Double> element, ConversionInfo info
) {
return element.entrySet().stream()
.collect(toMap(
o -> Material.getMaterial(o.getKey()),
Map.Entry::getValue
));
}
}
@Convert(MaterialMapConverter.class)
public Map<Material, Double> validChairs = new HashMap<>();
Using enums as map keys now works out of the box with version 3. The ElementType
annotation is also not necessary anymore (and, therefore, gone). Only took 4 years. :tipping_hand_man:
I need a Map<Material, Double> in my configuration. Maybe you can add Enums as Map keys, thanks :)
I tried the following:
The error after server start: