ChestShop's API
Overview of ChestShop's API
Depending on ChestShop
You can use maven to add ChestShop as a dependency to your project:
<repository>
<id>chestshop-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<dependency>
<groupId>com.acrobot.chestshop</groupId>
<artifactId>chestshop</artifactId>
<version>3.12</version>
<scope>provided</scope>
</dependency>
Events
ChestShop is getting more and more event-driven. Here is a summary of all events currently existing:
- AccountCheckEvent - checks for the existence of an account
- CurrencyAddEvent - represents an addition of currency to entity
- CurrencyAmountEvent - checks the amount of currency available
- CurrencyCheckEvent - represents a check for the existence of specified currency amount
- CurrencyFormatEvent - represents a moment when the currency needs to be shown
- CurrencyHoldEvent - checks if the account can hold the amount of currency
- CurrencySubtractEvent - represents a subtraction of currency to entity
- CurrencyTransferEvent - represents a transaction of goods between two entities
Transaction Events
- PreTransactionEvent - It's a pre-transaction event. It can be used to cancel transactions, for example when the player hasn't got enough EXP.
- TransactionEvent - It's a post-transaction event, so it is fired after a transaction is made. It can be used, for example, for logging transactions.
Shop Events
- PreShopCreationEvent - Called when a shop is being created. Can be used to cancel shop creation, modify the sign, etc.
- ShopCreatedEvent - Called after a shop is created. Can be used for logging/rewarding with EXP, etc.
- ShopDestroyedEvent - Called when a shop is destroyed.
- BuildPermissionEvent - checks if a shop can be made in its location. It's only blocking shop creation if all plugins that used it blocked the usage.
- ProtectBlockEvent - this event is called to tell protection plugins to protect the block. You should usually check if the block has been protected already before protecting it.
- ProtectionCheckEvent - checks if a block is protected and if the player from the event can access the block.
Miscellaneous Events
- AccountQueryEvent - used to query the account information from the sign name. If you want special shop owners (e.g. clans or factions) then you'll want to work with this.
- ShopInfoEvent - can be used to add shop information to the /shopinfo command or the shop container right click. It's a post-action event.
- ItemInfoEvent - can be used to add item information to the /iteminfo command, or for logging the usage of it. It's a post-action event.
- ItemStringQueryEvent - queries the string that represents an item on the sign. Can be used to provide custom item strings
- ItemParseEvent - parses item stacks from the strings on a sign. Can be used to add custom item functionality or additional data
- MaterialParseEvent - parses the material name from the sign string. Can be modified for custom item support
Implementing custom shop owners
If you want to implement custom owners of shops (like factions) then you need to listen for the following events:
- PreShopCreationEvent - To write a unique name/ID on the sign instead of the name of the player creating the sign)
- AccountQueryEvent - To get your custom account from the sign
- AccountCheckEvent - To check if your custom account still exists (e.g. after a disband)
- Currency*Event - All of those need to be handled to move money to your custom account owner if they don't natively integrate with Vault
- TransactionEvent - Optional, useful for sending messages to the members of your owner account
- PreTransactionEvent - Optional, send messages on empty shops