How do I add a button - Maxlego08/zShop-API GitHub Wiki
Buttons are the basic foundation of the plugin, they are very important to be able to manage your configuration. Here you have all available button types and an example of their use.
Button types:
- NONE
- NONE_SLOT
- BACK
- HOME
- PREVIOUS
- NEXT
- ITEM
- ITEM_CONFIRM
- INVENTORY
- BUY_CONFIRM
- SELL_CONFIRM
- ADD
- REMOVE
- SET_TO_MAX
- SET_TO_MIN
- SHOW_ITEM
- PERFORM_COMMAND
- ZSPAWNER
Default (top)
Here is the information that is valid for all button types.
typeSets the type of the button.slotSets the button slot.isPermanentAllows you to set a button as permanent, so the paging system will not take this button into account (you must set the value to true).itemAllows you to define the item to be displayed (Add an item)permissionAllows you to give permission to the.elseMessageAllows you to send a message to the user when they do not have permission to click a button.elseDisplays another button if the user does not have permission.actionAllows you to choose the formula for the verification with place holder, you have SUPERIOR, LOWER, SUPERIOR_OR_EQUAL, LOWER_OR_EQUALplaceHolderAllows to check an API placeholder variablevalueAllows you to set the value for placeholder verificationsoundAllows you to have a sound when the player clicks on the button. You have the list of sounds available here: XSoundvolumeChanging the sound volumepitchChanging the sound pitchcloseCloses the inventory when clicking
Example:
block:
item:
material: GRASS
name: "&aBlocks"
lore:
- "&7Click to access the blocks"
type: INVENTORY
inventory: "blocks"
slot: 20
sound: BLOCK_NOTE_BLOCK_PLING
volume: 1.3f
pitch: 0.8f
NONE (top)
Description:
- This type allows you to display a single item, no interaction is possible.
Example:
example:
item:
material: GRASS_BLOCK
name: "&cRandom name"
type: NONE
slot: 0
NONE_SLOT (top)
Description:
- The type with the same works as the NONE type but allows to display the same item on several slots. Example:
slots:
type: NONE_SLOT
item:
material: STAINED_GLASS_PANE
data: 7
name: "&e"
slots:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
BACK (top)
Description:
- Returns to the previous inventory.
Example:
back:
item:
material: BARRIER
name: "&cBack"
type: BACK
slot: 49
HOME (top)
Description:
- Returns to the main inventory.
Example:
home:
item:
material: BARRIER
name: "&eHome"
type: HOME
slot: 49
PREVIOUS (top)
Description:
- Returns to the previous page
Example:
previous:
item:
material: 262
name: "&7Previous page"
type: PREVIOUS
display: true
slot: 48
displayDisplays the button even if the page is the first one.
NEXT (top)
Description:
- Go to the next page
Example:
next:
item:
material: 262
name: "&7Next page"
type: NEXT
slot: 50
displayDisplays the button even if the page is the lest one.
ITEM (top)
Description:
- Allows you to sell items or commands. Right click to sell an item. Left-click to buy an item. Click on the wheel to sell all your inventory.
Example:
1:
item:
material: GRASS_BLOCK
buyPrice: 10.0
sellPrice: 0.5
type: ITEM
slot:
Values:
sellPriceSelling price of the item, put 0 to not put the item for sale. By default the value is 0.buyPriceBuying price of the item, put 0 to not buy the item. By default the value is 0.maxStackAllows you to define the maximum number of items that can be bought or sold at the same time. To be used for items such as potions, armor or other. The default value is 64.giveItemAllows you to enable or disable giving the item away at the time of purchase. By default the value is in true.loreAllows to display a different lore than the one defined in the config.yml file.buyCommandsEnables you to run a purchase order list during purchasing.sellCommandsEnables you to run a purchase order list during sale.economyAllow to change the economy used for the button. By default, the economy will be vault
ITEM_CONFIRM (top)
Description:
- Same type as ITEM but here you can only buy the item with a confirmation inventory.
Example:
20:
item:
material: HAY_BLOCK
name: "&eConfirm item"
buyPrice: 15.0
type: ITEM_CONFIRM
giveItem: false
lore:
- "&f> &2Buying price&7: &a%buyPrice%%currency%"
- ""
- "&f> &7Click to buy and confirm"
buyCommands:
- "bc %player% just buy %amount% %item% for %price%%currency%"
slot: 22
INVENTORY (top)
Description:
- Allows you to move between inventories. Please note that you can only move between inventories with a default type, otherwise you may get errors.
Example:
block:
item:
material: GRASS_BLOCK
name: "&aBlocks"
lore:
- "&7Click to access the blocks"
type: INVENTORY
inventory: "blocks"
slot: 20
Value:
inventoryAllows you to define the name of the inventory to which you want to go.
BUY_CONFIRM (top)
Description:
- Allows you to confirm the purchase. Attention, you can only use this type of button in an inventory of type BUY and CONFIRM.
Example:
accept:
item:
material: GREEN_STAINED_GLASS_PANE
name: "&aBuy"
type: BUY_CONFIRM
slot: 41
SELL_CONFIRM (top)
Description:
- Allows you to confirm the sale. Attention, you can only use this type of button in an inventory of type SELL.
Example:
accept:
item:
material: GREEN_STAINED_GLASS_PANE
name: "&aSell"
type: SELL_CONFIRM
slot: 41
ADD (top)
Description:
- Allows you to add a certain number to the item you want to buy or sell. Attention you can only use this type in an inventory of type SELL or BUY.
Example:
addone:
item:
material: YELLOW_STAINED_GLASS_PANE
name: "&aAdd 1"
type: ADD
amount: 1
slot: 24
addten:
item:
material: LIME_STAINED_GLASS_PANE
name: "&aAdd 10"
type: ADD
amount: 10
slot: 25
Value:
amountThe number you want to add to the item.
REMOVE (top)
Description:
- Allows you to remove a certain number to the item you want to buy or sell. Attention you can only use this type in an inventory of type SELL or BUY.
Example:
removeten:
item:
material: ORANGE_STAINED_GLASS_PANE
name: "&cRemove 10"
type: REMOVE
amount: 10
slot: 19
removeone:
item:
material: YELLOW_STAINED_GLASS_PANE
name: "&cRemove 1"
type: REMOVE
amount: 1
slot: 20
Value:
amountThe number you want to remove to the item.
SET_TO_MAX (top)
Description:
- Allows to set the item to the maximum number where it can be (default 64). Attention you can only use this type in an inventory of type SELL or BUY.
Example:
settomax:
item:
material: GREEN_STAINED_GLASS_PANE
name: "&aSet to %maxStack%"
type: SET_TO_MAX
slot: 26
SET_TO_ONE (top)
Description:
- Allows to set the item to 1. Attention you can only use this type in an inventory of type SELL or BUY.
Example:
settoone:
item:
material: RED_STAINED_GLASS_PANE
name: "&cSet to 1"
type: SET_TO_ONE
slot: 18
SHOW_ITEM (top)
Description:
- Allows you to see the item you are about to buy. Attention you can only use this type in BUY, SELL, or CONFIRM inventories.
Example:
show:
type: SHOW_ITEM
slot: 22
lore:
- "&eBuy price&8: &b%buyPrice%%currency%"
PERFORM_COMMAND (top)
Description:
- Allows the player to execute commands. And thus to navigate in the inventories of other plugin for example
Example:
commands:
type: PERFORM_COMMAND
item:
material: EMERALD
name: "&eClick for execute command"
slot: 30
commands:
- "bc %player% est vraiment trop beau"
closeInventory: true
Value:
commandsList of commands that will be executed by player.consoleCommandsList of commands that will be executed by console.consoleRightCommandsList of commands that will be executed by console when player right click.consoleLeftCommandsList of commands that will be executed by console when player left click.closeInventoryAllows you to close the inventory before the commands are executed.consolePermissionCommandsAllows commands to be executed at the console only if the player has permission.consolePermissionPermission for the list above
ZSPAWNER (top)
Description:
- Allows to sell spawners coming from the zSpawner plugin, the type extends from the confirm item, so you will have the confirmation mistletoe for the purchase of the spawner.
- Here is an example of configuration: https://github.com/Maxlego08/zShop-API/blob/master/inventories/1_13/spawners.yml
Example:
item:
material: SPIDER_SPAWN_EGG
name: "&fSpider spawner"
buyPrice: 100.0
type: ZSPAWNER
slot: 23
entity: SPIDER
zpawnerAction: GIVE
Value:
entityTypeThe type of the entityspawnerActionThe action to buy the spawner, either GIVE or ADD (referring to the /spawners give and /spawners add commands)levelThe spawner level, by default 0