package com.elmakers.mine.bukkit.magic;

import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;

import org.bukkit.configuration.ConfigurationSection;

import com.elmakers.mine.bukkit.api.spell.MageSpell;

public class SpellParameters extends MageParameters {
    private @Nonnull ConfigurationSection variables;
    private final @Nonnull Set<String> allParameters = new HashSet<>();
    private final @Nonnull MageSpell spell;

    public SpellParameters(MageSpell spell) {
        super(spell.getMage(), "Spell: " + spell.getKey());
        this.spell = spell;
        this.variables = spell.getVariables();
        this.allParameters.addAll(super.getParameters());
    }

    public SpellParameters(MageSpell spell, ConfigurationSection config) {
        this(spell);
        wrap(config);
    }

    public SpellParameters(SpellParameters copy) {
        super(copy);
        this.spell = copy.spell;
        this.variables = copy.variables;
        this.allParameters.addAll(copy.allParameters);
    }

    @Override
    protected double getParameter(String parameter) {
        if (variables.contains(parameter)) {
            return variables.getDouble(parameter);
        }
        Double value = spell.getAttribute(parameter);
        return value == null || Double.isNaN(value) || Double.isInfinite(value) ? 0 : value;
    }

    @Override
    protected Set<String> getParameters() {
        this.allParameters.addAll(variables.getKeys(false));
        return allParameters;
    }

    public void setVariables(@Nonnull ConfigurationSection variables) {
        this.variables = variables;
    }
}

@@ -626,24 +626,128 @@
 ariables();%0A
+        Set%3CString%3E superParameters = super.getParameters();%0A        if (superParameters != null) %7B%0A    
         this
@@ -769,28 +769,24 @@
 addAll(super
-.get
 Parameters()
@@ -783,20 +783,28 @@
 rameters
-()
 );
+%0A        %7D
 %0A    %7D%0A%0A

Add a special check here to fix metadata generation