Auto-Selling Items
-
First you want to create a YML file or just use the default config and set each item and the the cost there.
EX:
Code (YAML):IRON_INGOT:
cost: 10.0
GOLD_INGOT:
cost: 15.0
DIAMOND:
cost: 30.0
Then all you have to do is get all of the first level paths using: JavaPlugin#getConfig()#getKeys(false) This will return a set of strings, which will be your list of materials. Then loop through the config and get the price for each individual material and put it in a HashMap like this:
Code (Java):
Loop through the collection of ItemStacks you just made above and see if the set of keys contains the item's material.
Then all you have to do is get and set the price!
Code (Java):for(ItemStack item : drops)
{
String name = item.getType().toString();
if(prices.keySet().contains(name))
{
double cost = prices.get(name);
//Do things
}
} - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM