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.

  • type Sets the type of the button.
  • slot Sets the button slot.
  • isPermanent Allows 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).
  • item Allows you to define the item to be displayed (Add an item)
  • permission Allows you to give permission to the.
  • elseMessage Allows you to send a message to the user when they do not have permission to click a button.
  • else Displays another button if the user does not have permission.
  • action Allows you to choose the formula for the verification with place holder, you have SUPERIOR, LOWER, SUPERIOR_OR_EQUAL, LOWER_OR_EQUAL
  • placeHolder Allows to check an API placeholder variable
  • value Allows you to set the value for placeholder verification
  • sound Allows you to have a sound when the player clicks on the button. You have the list of sounds available here: XSound
  • volume Changing the sound volume
  • pitchChanging the sound pitch
  • close Closes 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
  • display Displays 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
  • display Displays 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:

  • sellPrice Selling price of the item, put 0 to not put the item for sale. By default the value is 0.
  • buyPrice Buying price of the item, put 0 to not buy the item. By default the value is 0.
  • maxStack Allows 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.
  • giveItem Allows you to enable or disable giving the item away at the time of purchase. By default the value is in true.
  • lore Allows to display a different lore than the one defined in the config.yml file.
  • buyCommands Enables you to run a purchase order list during purchasing.
  • sellCommands Enables you to run a purchase order list during sale.
  • economy Allow 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:

  • inventory Allows 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:

  • amount The 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:

  • amount The 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:

  • commands List of commands that will be executed by player.
  • consoleCommands List of commands that will be executed by console.
  • consoleRightCommands List of commands that will be executed by console when player right click.
  • consoleLeftCommands List of commands that will be executed by console when player left click.
  • closeInventory Allows you to close the inventory before the commands are executed.
  • consolePermissionCommands Allows commands to be executed at the console only if the player has permission.
  • consolePermission Permission for the list above

ZSPAWNER (top)

Description:

Example:

item:
  material: SPIDER_SPAWN_EGG
  name: "&fSpider spawner"
buyPrice: 100.0
type: ZSPAWNER
slot: 23
entity: SPIDER
zpawnerAction: GIVE

Value:

  • entityType The type of the entity
  • spawnerAction The action to buy the spawner, either GIVE or ADD (referring to the /spawners give and /spawners add commands)
  • level The spawner level, by default 0