java.lang.ClassCastException: java.lang.String cannot be cast to org.spongepowered.api.effect.potion.PotionEffect


Hello, I can not apply a potion:

                 List<PotionEffect> potions = null;

                    try {
                        potions = conf.getConfig().getNode("conf", "MagicShield", "Armor", "Helmet").getValue(new TypeToken<List<PotionEffect>>() {});
                    } catch (ObjectMappingException e) {

                    if(potions != null) {

                        if(!player.get(Keys.POTION_EFFECTS).isPresent()) {
                            player.offer(Keys.POTION_EFFECTS, potions);

En conf:
[{ContentVersion=2, PotionType=minecraft:night_vision, Duration=6000, Amplifier=0, Ambiance=false, ShowsParticles=false}, {ContentVersion=2, PotionType=minecraft:water_breathing, Duration=6000, Amplifier=0, Ambiance=false, ShowsParticles=false}]


Sadly you can not just create a new instance of TypeToken. Thankfully Sponge has got your back.


Also make sure your saving the value with the same TypeTokens.


thank you!!! thank you!!! thank you!!!