package com.elmakers.mine.bukkit.api.spell;

import org.apache.commons.lang.StringUtils;

public class SpellKey {
    private final String key;
    private final String baseKey;
    private final int level;
    private final boolean isVariant;

    public SpellKey(String key) {
        this.key = key;
        if (key.contains("|")) {
            String[] pieces = StringUtils.split(key, "|");
            this.baseKey = pieces[0];
            int parsedLevel;
            try {
                parsedLevel = Integer.parseInt(pieces[1]);
            } catch (Exception ex) {
                parsedLevel = 1;
                ex.printStackTrace();
            }
            level = parsedLevel;
            isVariant = true;
        } else {
            level = 1;
            this.baseKey = key;
            isVariant = false;
        }
    }

    public String getKey() {
        return key;
    }

    public String getBaseKey() {
        return baseKey;
    }

    public int getLevel() {
        return level;
    }

    public boolean isVariant() {
        return isVariant;
    }
}

@@ -238,16 +238,352 @@
 riant;%0A%0A
+    public SpellKey(String baseKey, int level) %7B%0A        this.baseKey = baseKey;%0A        this.level = level;%0A        if (this.level %3E 1)%0A        %7B%0A            isVariant = true;%0A            this.key = baseKey + %22%7C%22 + level;%0A        %7D%0A        else%0A        %7B%0A            isVariant = false;%0A            this.key = baseKey;%0A        %7D%0A    %7D%0A%0A
     publ

Add a constructor to rebuild a SpellKey from the base and level