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 baseKey, int level) {
        this.baseKey = baseKey;
        this.level = level;
        if (this.level > 1)
        {
            isVariant = true;
            this.key = baseKey + "|" + level;
        }
        else
        {
            isVariant = false;
            this.key = baseKey;
        }
    }

    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;
    }
}

@@ -83,16 +83,56 @@
 Utils;%0A%0A
+import com.google.common.base.Objects;%0A%0A
 public c
@@ -414,24 +414,16 @@
 vel %3E 1)
-%0A       
  %7B%0A     
@@ -506,29 +506,13 @@
    %7D
-%0A        else%0A       
+ else
  %7B%0A 
@@ -1430,11 +1430,172 @@
 t;%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        return Objects.toStringHelper(this)%0A                .addValue(getKey())%0A                .toString();%0A    %7D
 %0A%7D%0A

Add SpellKey#toString