package org.monospark.spongematchers.type;

import java.util.Map;

import org.monospark.spongematchers.matcher.SpongeMatcher;
import org.monospark.spongematchers.matcher.sponge.ItemStackMatcher;
import org.monospark.spongematchers.parser.SpongeMatcherParseException;
import org.monospark.spongematchers.parser.element.StringElement;
import org.spongepowered.api.item.inventory.ItemStack;

public final class ItemStackType extends MatcherType<ItemStack> {

    private static final MatcherType<Map<String, Object>> MAP_TYPE = MatcherType.definedMap()
            .addEntry("type", MatcherType.STRING)
            .addEntry("damage", MatcherType.INTEGER)
            .addEntry("amount", MatcherType.INTEGER)
            .build();
    
    ItemStackType() {
        super("item stack");
    }

    @Override
    public boolean canMatch(Object o) {
        return o instanceof ItemStack;
    }

    @Override
    protected boolean canParse(StringElement element, boolean deep) {
        return MAP_TYPE.canParseMatcher(element, deep);
    }
    
    @Override
    protected SpongeMatcher<ItemStack> parse(StringElement element) throws SpongeMatcherParseException {
        SpongeMatcher<Map<String, Object>> matcher = MAP_TYPE.parseMatcher(element);
        return ItemStackMatcher.create(matcher);  
    }
}

@@ -621,13 +621,17 @@
 y(%22d
-amage
+urability
 %22, M
@@ -677,14 +677,16 @@
 ry(%22
-amount
+quantity
 %22, M
@@ -697,32 +697,85 @@
 erType.INTEGER)%0A
+            .addEntry(%22data%22, MatcherType.DATA_VIEW)%0A
             .bui

Fix outdated entry names of the ItemStackType map