EssentialsX

EssentialsX

2M Downloads

Vanilla Item IDs not always accepted in worth.yml

elliotbailey opened this issue ยท 3 comments

commented

Information

Full output of /ess version:

Server version: 1.14.4-R0.1-SNAPSHOT git-Paper-207 (MC: 1.14.4)
EssentialsX version: 2.17.1.0
LuckPerms version: 4.4.1
Vault version: 1.7.2-b107
EssentialsXChat version: 2.17.1.0
EssentialsXSpawn version: 2.17.1.0

Details

Description
Some items in worth.yml that use vanilla names don't work in game with /worth or /sell, the plugin responds with Error: That item cannot be sold to the server.. The reason I'm not using essential ID aliases is because I'm planning on running the file through a script for another project.

Steps to reproduce

  1. Put vanilla item IDs such as coarse_dirt and oak_log instead of coarsedirt and oaklog in worth.yml
  2. Reload plugin/restart server
  3. /worth does not view the item as legitimate

Expected behavior
worth.yml file accepts all vanilla item IDs

commented

After a bit more testing, it appears to be any item IDs with an underscore in the name are affected

commented

Looking at the code that handles worth, both getting and setting prices strips the underscores out of material names - so it seems the ability to use vanilla item names was not the intention.

public BigDecimal getPrice(IEssentials ess, ItemStack itemStack) {
BigDecimal result;
String itemname = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");

public void setPrice(IEssentials ess, ItemStack itemStack, double price) {
String path = "worth." + itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", "");

commented

To clarify: the current recommended way to modify worth.yml is to use /setworth, which should guarantee that valid item names are stored in the file.