Configuration- Advanced options

Sep 26, 2017
Configuration- Advanced options
  • How to set up different kinds of actions?
    That's easy! Simply copy your price-, reward- and lore-lines and modify the path:
    Add the name of the clicktype you want to use to the end of the path.
    Examples:
    Reward -> Reward_right
    Message -> Message_middle

    Possible Clicktypes:
    • left
    • right
    • middle
    • shift_left
    • shift_right
    Configuration example
    Code (Text):
      Diamonds:
        MenuItem:
        - type:DIAMOND
        - amount:5
        - name:&95 Diamonds
        - 'lore1:&eClick &2left &eto buy &c%reward% &efor &c%price%&e.'
        - 'lore2:&eClick &2right &eto sell &c%price_right% &efor &c%reward_right%&e.'
        RewardType: ITEM
        Reward:
        - - type:DIAMOND
          - amount:5
        PriceType: MONEY
        Price: 5000
        Message: '&eYou bought %reward%! Money left: &c%left%'
        RewardType_right: MONEY
        Reward_right: 2500
        PriceType_right: ITEM
        Price_right:
        - - type:DIAMOND
          - amount:5
        Message_right: '&eYou just sold %price_right%!'
        ExtraPermission: ''
        InventoryLocation: 3
    In this case the player would buy diamonds with leftclick and sell diamonds with rightclick.
    You can use the placeholders %reward_<clicktype>% and %price_<clicktype>% to display reward and price of the action.
    Optionally you can add independent extrapermissions to the different clicktypes by adding "ExtraPermission_<clicktype>" to your shopitem. For example "ExtraPermission_right: BossShop.itemshop.apple.rightclick".

    Other possible settings
    There are following settings that you can add to the main config.yml, any shop and any shopitem:
    • "HideItemsPlayersDoNotHavePermissionsFor: true/false" - Should be clear, effect can be replaced with conditions
    • "AllowUnsafeEnchantments: true/false" - If enabled players can use every Enchantment reward on any item
    • "CanPlayersSellItemsWithGreaterEnchants: true/false" - If enabled players can sell items with greater enchants than needed to a shop that allows to sell items. That might be helpful when dealing with items with bad enchants, but also might lead to accidently selling items below their worth.
    • "CloseShopAfterPurchase: true/false" - If enabled the inventory GUI will be closed after a successful purchase
    These settings are inherited by their children: If you for example set "CloseShopAfterPurchase: true" in your main config.yml all shopitems will be affected by it. Now if you set "CloseShopAfterPurchase: false" for an individual shops the setting will be disabled for every shopitem in that shop.

    Sound settings can be inherited aswell. You can add following properties to any shop or shopitem in order to make them and their children use new sounds:
    Code (Text):
    Sound:
      Shopitem:
        Click: 'UI_BUTTON_CLICK:1:1'
        Purchase: 'ENTITY_PLAYER_LEVELUP:1:1.8'
        NoPermission: 'ENTITY_BLAZE_DEATH:1:1'
        NotEnoughMoney: 'ENTITY_SHULKER_HURT:1:0.8'
    Following sound properties can be added to any shop:
    Code (Text):
    Sound:
      Shop:
        ChangePage: 'UI_BUTTON_CLICK:0.2:1'
        ChangeShop: 'BLOCK_CHEST_OPEN:0.2:1'
        Open: 'ENTITY_ELDER_GUARDIAN_CURSE:1:1.8'
        Close: ''
    The formatting of sounds is "<sound name>:<volume>:<pitch>". You can turn a sound off by setting it to ''. You can find all available sound names here.

    Following optional settings can be added to any shop (but not shopitem):
    • InventoryRows: <amount of rows> - This setting allows increasing the size of an inventory without needing to add a shopitem to the bottom row

    Player input

    You can force players to input their own text or to select an online player. The input is stored and can be accessed using the "%input%" placeholder. Possible applications:
    • Player menu: Select a player and then execute a certain action like kick/mute/ban/promote
    • Command "completion": When players click a certain shopitem a command is executed which uses the player input
    • Allow players to name the items they buy (by setting "name:%input%")
    • Many more
    That way it is possible to turn basically everything into a neat GUI: For example a Factions GUI can be created which players can use to claim areas or to promote other players (using input to enter the name of the player to promote).

    In order to force player input, simply add following lines to your shopitem:
    Code (Text):
        ForceInput: PLAYER/TEXT
        ForceInputMessage: 'any message'
    You can either add those lines to any shopitems which use playerinput to make sure they enter new input before the action is performed, or force the player to select input and then provide a shop where all items use the same input.
    If you allow players to enter input once and then give them access to shopitems which use input but do not force new input, you need to make sure the players already have entered input.
    Here's an example for the approach where input only needs to be entered once:

    Section of main menu.
    Code (Text):
      playercommandsmenu:
        MenuItem:
        - lore:&8Commands to manage other players.
        - name:&e&lPlayer Commands
        - type:paper
        ForceInput: PLAYER
        ForceInputMessage: '&8Enter the name of a player you want to select.'
        RewardType: SHOP
        Reward: playercommandssecret
        PriceType: NOTHING
        Message: ''
        ExtraPermission: ''
        InventoryLocation: 40

    PlayerCommands shop.
    Code (Text):
    #Note: In order for commands to work properly players need to open the shop via main menu where they are forced to select a target.

    #Because of that simply do not give your players direct permissions to this shop.
    ShopName: PlayerCommandsSecret
    DisplayName: '&6&l%input% &0&lCommands'
    shop:
      reselecttarget:
        MenuItem:
        - name:&f&lSelect other player
        - lore:&8Click to select an other player.
        - amount:1
        - type:SKULL_ITEM
        - durability:3
        RewardType: SHOP
        ForceInput: PLAYER
        ForceInputMessage: '&8Enter the name of a player you want to select.'
        Reward: PlayerCommandsSecret
        PriceType: NOTHING
        Message: ''
        ExtraPermission: ''
        InventoryLocation: 1
      gamemode:
        MenuItem:
        - name:&f&lAdventure mode
        - lore:&8Set the gamemode of &l&6%input% &8to adventure mode.
        - amount:1
        - type:TORCH
        RewardType: PLAYERCOMMAND
        Reward:
        - 'gamemode 2 %input%'
        PriceType: NOTHING
        Message: ''
        ExtraPermission: ''
        InventoryLocation: 2
      msgtest:
        MenuItem:
        - name:&f&lTest message
        - lore:&8Send &l&6%input% &8a test message.
        - amount:1
        - type:PAPER
        RewardType: PLAYERCOMMAND
        Reward:
        - 'msg %input% this is a test'
        PriceType: NOTHING
        Message: ''
        ExtraPermission: ''
        InventoryLocation: 3
      kick:
        MenuItem:
        - name:&f&lKick
        - lore:&8Kick &l&6%input% &8from the server.
        - amount:1
        - type:DIAMOND_SWORD
        - itemflag:all
        RewardType: PLAYERCOMMAND
        Reward:
        - 'kick %input%'
        PriceType: NOTHING
        Message: ''
        ExtraPermission: ''
        InventoryLocation: 4




    Configuration tricks
    There are several tricks that make setting shops up easier. For example if you sell items you normally would create an item as Reward and you would create an other item up as MenuItem, right? There is a simple way to avoid creating two items that are the same: You can use the placeholders '%rewarditem_<id>%' and '%priceitem_<id>%' in order to make your MenuItem import the look of the given item.
    Example 1:
    Code (Text):
      GodApple:
        MenuItem:
        - '%rewarditem_1%'
        - 'lore:&cPrice: %price%'
        RewardType: ITEM
        Reward:
        - - type:GOLDEN_APPLE
          - amount:1
          - durability:1
        PriceType: MONEY
        Price: 10000
        Message: '&eYou bought 1 %itemname%! &eMoney left: &c%left%'
        ExtraPermission: ''
    In this example the MenuItem uses the look of the first reward item (there only is one anyways). That way the god apple has to be set up once only.

    Example 2:
    Code (Text):
      bow_ranger:
        MenuItem:
        - '%rewarditem_2%'
        - lore:&cCosts %price%.
        RewardType: ITEM
        Reward:
        - - amount:16
          - type:ARROW
        - - name:&2&lRanger Bow
          - amount:1
          - type:BOW
          - enchantment:ARROW_DAMAGE#7
          - enchantment:ARROW_KNOCKBACK#10
        PriceType: EXP
        Price: 30
        Message: '&2You have bought a new weapon for &c%price%&2.'
        ExtraPermission: ''
        InventoryLocation: 14
    In this case the reward consists of some arrows and a complicated bow. Because the MenuItem should not look like the arrows but rather like the bow we use '%rewarditem_2%' here (The bow is the second item of the reward list).

    If you want more tricks like this one I recommend checking out the Addon TrickyShops.

    Different RewardTypes for one item
    That's a tricky thing to do but actually possible using the simulate command:
    In order to be able to use different RewardTypes, simply use "RewardType: command" and set up a list of commands which simulate clicking other shopitems. You can either use existing shopitems if they fit your needs or for example create a new "invisible" shop which players do not have permissions for, where you set up new shopitems with "PriceType: nothing" and any kind of reward you want.

    Obviously a dirty workaround which works in most cases would be simply using rewardtype "command" and set up a list of commands which directly execute all needed actions, like giving items to the player, add permissions to the player or execute commands of other plugins.
  • Loading...
  • Loading...