# 🔍Custom Item Match Method

## Default Item Match Method

### Vanilla Items

By default, we support two sell match method, they are:

* Bukkit: This sell method require inventory's item must 100% same as product item, if the item player has changed some thing, it can not be selled anymore. For example, add enchantments or change item name in anvil, they will change item's NBT info.
* ItemFormat: ItemFormat can set ignore list of item's vanilla NBT. If you add enchants and name in ignore list, then player can still sell item even the item has more enchantments or changed item name.

Example config:

```yaml
sell:
  # Support Value: Bukkit or ItemFormat.
  # For each product, you can add match-item section to make custom sell match method, for more info, please view Wiki.
  sell-method: Bukkit
  # Only support ItemFormat sell method.
  item-format:
    require-same-key: false
    ignore-key:
      - 'lore'
      - 'damage'
      - 'enchants'
      - 'tool.damage-per-block'
      - 'nbt.CustomNBTKey'
```

For options in `item-format` section:

* require-same-key: This means that the items in the shop must have all the data of the items owned by the player.\
  For example: The shop has a diamond sword without any enchantments, then player has a diamond sword with sharpness enchantment, if player try sell his diamond sword to shop and the `require-same-key` option is `true`, then this sword will not be allowed to sell, because the sword in shop miss the data of enchantment.
* ignore-key: The list of ItemFormat™ Key that will be ignored when check whether items are same.\
  For example: The shop has a diamond sword with sharpness enchantment, if player's sword don't has this enchantment, and you didn't set `enchants` at this option, then he can not sell the sword to shop, if you set `enchants` here, then we will ignore player's sword don't has this enchantment, and contine check other keys.

{% hint style="info" %}
You can parse the ItemFormat of a handheld item by using the command `/shop generateeitemformat`, and the key can also be indented. For example, if you only want to ignore the sharpness enchantment and do not want to ignore other enchantments, you can fill in `enchants.sharpness` in ignore-keys option instead of `enchants`.
{% endhint %}

### Third-plugin Item

Items generated by [Supported Plugins](/info/compatibility.md) will auto parse it's Item ID and compare it with the item ID you set in Item Format's `hook-item` option, so no matter how it changes, it will eventually sell normally.

## Custom Match Method for each product - Require MythicChanger

Although the **ItemFormat** method described above solves the problem of items being modifiable, its flexibility is still insufficient. Therefore, this feature can help you set custom product sell modes for each product.

You can **add** a `match-item` section in the configuration of each **product or price**, which means that if the item meets this matching rule, it is considered sellable.

**ItemFormat is still required** if you want give player the item you set here after player try buy this product and display it in plugin's placeholder and shop GUI.

This feature require your server must install **MythicChanger** plugin, please get it here:

**FREE:** [Click to download](https://www.spigotmc.org/resources/mythicchanger-match-and-modify-all-your-items-without-trouble-1-14-1-21.98523/)

**PREMIUM:** [Click to download](https://www.spigotmc.org/resources/mythicchanger-premium-match-and-modify-all-your-items-without-trouble-1-14-1-21.115913/)

For how to configure the match-item section, please read MythicChanger's wiki, [click here to visit](https://mythicchanger.superiormc.cn/). Please note that some of the match rules require <mark style="color:red;">**PREMIUM version of MythicChanger, not PREMIUM version of UltimateShop**</mark>!

An example product config can be found below, in this example, both emerald and diamond can be selled, but only diamond are display in shop, after player try buy this product, he will only get diamond because `match-rule` section does not effect buy.

```yaml
  A:
    price-mode: ALL
    product-mode: CLASSIC_ALL
    products:
      '1':
        material: diamond
        amount: 1
        match-item: # This is added match-item section.
          material: # This is the match rule key! Read MythicChanger wiki for list of them!
            - diamond
            - emerald
          has-name: false # This is the match rule key! Read MythicChanger wiki for list of them!
      '2':
        # more sub products here?
    buy-prices:
        # You can also use this in buy price!
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ultimateshop.superiormc.cn/features/custom-item-match-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
