#Setting Merchant recipe
1 messages · Page 1 of 1 (latest)
declaration: package: org.bukkit.inventory, class: MerchantRecipe
PLS Help, I can't understand, how to solve this problem
can u send the whole code and explain what exactly is the problem
function changeRecipe(e: entity):
set {_file_location} to "./plugins/Skript/json/trades.json"
set {_reader} to new FileReader({_file_location})
set {_parser} to new JSONParser()
set {_jsonObj} to {_parser}.parse({_reader})
set {_villager} to {_e}
set {_profession} to {_villager}.getProfession()
set {_json} to {_jsonObj}.get("%{_profession}%")
set {_trades::*} to ...{_villager}.getRecipes()
loop {_trades::*}:
set {_result} to loop-value.getResult()
set {_ingr::*} to ...loop-value.getIngredients()
set {_json_book::*} to ...{_json}.get("%{_result}%")
if {_result} is enchanted book:
set {_enchants::*} to stored enchants of {_result}
else:
set {_enchants::*} to enchantments of {_result}
loop {_enchants::*}:
set {_enchant} to enchantment of loop-value-2
set {_level} to enchantment level of loop-value-2
loop {_json_book::*}:
set {_json_ench} to loop-value-3.get("Enchantment")
if "%{_enchant}%" is "%{_json_ench}%":
set {_json_level} to loop-value-3.get("Level")
if "%{_level}%" is "%{_json_level}%":
set {_price} to 0
add loop-value-3.get("Price") to {_price}
loop {_ingr::*}:
if type of loop-value-4 is emerald:
set {_key} to 2
set {_diamonds} to diamonds
set item amount of {_diamonds} to {_price}
set {_a} to {_ingr::%{_key}%}
if {_ingr::%{_key}%} is set:
if type of {_a} isn't diamond:
set ingredients of merchant recipe loop-value-1 to {_diamonds} and {_ingr::%{_key}%}
else:
set ingredients of merchant recipe loop-value-1 to {_diamonds}
else:
set ingredients of merchant recipe loop-value-1 to {_diamonds}
I create the function to change trades recipe from JSON, but it works (set ingredients of merchant recipe (from SkBee)) only if I install plugin TradeManager, I cant find solution to change ingredients without this plugin
and why wont u use the plugin?
because it adds functionality that I don't need and is essentially a vestige.