-
-
Notifications
You must be signed in to change notification settings - Fork 3
Example: Making shop with SimpleInventories
Misat11 edited this page May 30, 2020
·
2 revisions
If you want to create a custom shop, there are lot of methods that could help you with it. For this you will need groovy format, because in YAML you can't write any code blocks. Then you will need SimpleInventories-Plugin.
Open your config.yml and put here these informations:
inventories:
# .. there could be another shops
shop:
file: shop.groovy # the file name
options:
genericShop: true # this will enable shop callbacks for our inventory
genericShopPriceTypeRequired: true # this will disable calling shop callback if price type is not specified
/* First we will import needed bukkit API */
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
inventory {
/* Then we will create global buy callback, so all items with price will use it */
buy {
/*
Inside this callback we can use hasPlayerInInventory, buyStack and sellStack,
this will help us making an shop
*/
def currency = new ItemStack(Material.getMaterial(getType()), getPrice())
if (hasPlayerInInventory(currency)) {
sellStack(currency)
buyStack()
}
}
/* Now we can just simply create items with prices */
item('STONE;2 for 1 DIRT')
item('IRON_ORE;4 for 5 DIRT')
}
Can't find what are you looking for on this wiki? Maybe our automatically generated javadoc could help you https://docs.screamingsandals.org/simpleinventories/simpleinventories-core/
- Welcome on this wiki
- Formats:
- Variables:
- Callbacks: (Groovy only)
-
Examples:
- Making shop (Groovy only)
- Making vault shop (Groovy only)