GUI Shop

GUI Shop

273k Downloads

Item strings are mismatched, causing items to be unable to be sold

A248 opened this issue ยท 2 comments

commented

GUIShop currently keys the ITEMTABLE map by strings. These strings, which I call "item strings" are derived from an item's material. When items are defined in a Shop, their sell price is defined by their item string. When items are dropped into the sell GUI, their sell price is looked up by their item string.

For a GUI Item, the item string is material.toUpperCase(). For an ItemStack, it is itemStack.getType().toString().toUpperCase(). (Spawners are special-cased with a slightly different item string, to differentiate mob types).

However, the problem arises where the material configured in the shops.yml, which is the String material in Item, does not match the string representation of the Material of the ItemStack. Specifically, these are 2 different materials. The first is a config value which is later parsed via Item#parseMaterial, including XMaterial, and other attempts of parsing, which all manipulate the material string to find an itemstack. The latter is the actual name of the Material of an existing ItemStack.

Effectively, the difference between the first 'material' and the second Material is that one is a config value which may or may not be identical to an actual Material, and the other is truly a Material.

commented

For example, with nether wart, the config material string is "NETHER_WART", but in-game, it is "NETHER_STALK".

commented

XMaterial should be able to resolve these changes over legacy versions. The NETHER_WART was once a proper ID supported in earlier versions, in fact the config was probably written in these versions. XMaterial will resolve NETHER_WART into NETHER_STALK if functioning correctly.