-
-
Notifications
You must be signed in to change notification settings - Fork 3
Callback: buy
Misat11 edited this page May 11, 2020
·
3 revisions
This callback is called after preClick if item has price defined and generic shop is enabled for this inventory. This callback is cancellable so you can check, if it's canceled or cancel it. The cancelation will do nothing. Can be used with single item or with all items. These callbacks are called while ShopTransactionEvent is called. It's useful to register this callback just globally.
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
inventory {
buy {
// this callback will run when you click on some item with price
def currency = new ItemStack(Material.getMaterial(getType()), getPrice())
if (hasPlayerInInventory(currency)) {
sellStack(currency)
buyStack()
}
}
item ('STONE for 1 DIRT')
item ('GRAVEL for 5 DIRT') {
buy {
player.sendMessage 'Yay you are going to buy gravel'
}
/* Items inside category won't be affected with parent's callbacks */
item('DIRT')
}
}
All methods available inside buy can be found here
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)