-
-
Notifications
You must be signed in to change notification settings - Fork 3
Example: Making vault shop with SimpleInventories
Misat11 edited this page May 30, 2020
·
1 revision
If you want to create a vault 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, Vault and Economy plugin of course.
Open your config.yml and put here these informations:
inventories:
# .. there could be another shops
vault:
file: vault.groovy # the file name
options:
genericShop: true # this will enable shop callbacks for our inventory
genericShopPriceTypeRequired: false # we don't need specific shop price type, because there's just one type
/* First we will import needed Bukkit and Vault API */
import org.bukkit.Bukkit;
import net.milkbowl.vault.economy.Economy;
/* Then we must get the economy provider. This can be done here but also in the buy callback */
def rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
def econ = rsp.getProvider();
inventory {
/* Then we will create global buy callback, so all items with price will use it */
buy {
/*
Inside this callback we can use buyStack, this will help us making an shop.
In this case we will also need an economy provider
*/
if (econ.has(player, getPrice())) {
econ.withdrawPlayer(player, getPrice())
buyStack()
}
}
/* Now we can just simply create items with prices (without price types) */
item('STONE;2 for 1')
item('IRON_ORE;4 for 5')
}
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)