/mbedwars addon cosmetics shop open <shop> [player]
There is no permission to open the shop. This is to enforce good practice, as such commands shall not be accessed by players and instead shall be redirected to by third-party plugins (e.g. NPCs or GUIs). These plugins then execute that command via console (granting all players) and include their player name placeholder within the player name argument of the command.
Run /npc select
while looking at a spawned NPC to select it. Then run this exact command to make the NPC open the shop when clicked upon: /npc command add mbedwars addon cosmetics shop open main <p>
.
It might look like this within it's saves.yml
file:
last-created-npc-id: 0
npc:
'0':
metadata:
cached-skin-uuid: d8d5a923-7b20-43d8-883b-1150148d6955
cached-skin-uuid-name: test
name: test
uuid: c8f4c282-e084-45ff-ac28-09816618af68
traits:
location:
bodyYaw: 131.99768
world: bla
x: 125.473
y: 114.0
z: 353.2611
yaw: 131.9977
pitch: 1.8
commandtrait:
commands:
'0':
command: mbedwars addon cosmetics shop open main <p> ## !! Important
hand: RIGHT
player: false ## !! Important
npc: false ## !! Important
op: false ## !! Important
cooldown: 0
globalcooldown: 0
n: -1
delay: 0
cost: -1.0
experienceCost: -1
cost: -1.0
executionMode: LINEAR
experienceCost: -1
hideErrorMessages: false
persistSequence: false
temporaryPermissionsDuration: 0
type: PLAYER
owner:
uuid: 8ef8a4a0-3b8b-35a4-bd22-03b77611655d
spawned: true
skintrait:
fetchDefaultSkin: true
signature: Py4vaAkl/kT1KV6vKWKHXU9XOAcQi7neJ9YbICqzusv2kfKpfELVvcxoME/+YLSUjApJYSx5qb/gTcR1dzy+DAOU8P4KDfqM9WkXzP3ndujnHOrLqiTB0NIJCX/dzkx6hyZZFlmE/L/kqREsvPydlZhDqAKjhxPpl8n2sUPDv0zU8ztxEYR8ebbWC+HLmhgmxJlzZga2WnSG77HwRzn1YOCeCCK1NWOXGx4ezH4OtCYZJeqEaY0XHd/B/wTHI9JCyYqgnt0gVc3XoUuFrREhii+D21bDOk9A+tePzkWuSwVLLFbh+O9+3KbFcTF87N8lMkP6Pni1RoAAcf5UKWWjsxae9L42qltHuDZIS/gubJxUSqBrOTbupfT2miuK7Lak7g+HH5GbBY3WrAZPa64XnXpNzqa8bf3Dg/dqo5KXWswoPf5AAHSwJ7hN0YwyCnwSxNwYts6hiPwS+ZVS9yvPOtx+s33U+fo7RMn9+PNV3261LtNRxPLIBbeWX9DMsw1iTK+7bRgS3nJsnmySu5pRJKvaHWtRKv1K2eJS3lTxu1qIUc8SdyqcQzmzwS3n4Icu/rDhZDA98r38cmNJY/lgMuERI4nkon0lK2stagT7/oTgbqwXasw9y1hc9DW3REd7iWL09qgny2dy//3xeUNrQ2jPdw+ufUwroOTBai4KIpM=
textureRaw: ewogICJ0aW1lc3RhbXAiIDogMTczMDgwNTI2NjE0NCwKICAicHJvZmlsZUlkIiA6ICJkOGQ1YTkyMzdiMjA0M2Q4ODgzYjExNTAxNDhkNjk1NSIsCiAgInByb2ZpbGVOYW1lIiA6ICJUZXN0IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzk2MzQzODk1M2E3ODJkYTc2OTQ4MGIwYTQ5MTI1YTkyZTI1OTIwNzcwMGNiOGUzZTFhYWMzOGU0NzFlMjAzMDgiCiAgICB9CiAgfQp9
updateSkins: false
traitnames: inventory,location,commandtrait,type,owner,spawned,scoreboardtrait,skintrait
navigator:
speedmodifier: 1.0
avoidwater: false
usedefaultstuckaction: false
Run /znpcs action <id> add CONSOLE mbedwars addon cosmetics shop open main %player_name%
. Replace <id> with the id of your NPC.
Note, if that doesn't work: ZNPCs depends on PlaceholderAPI and its Player extension.
You may configure an item similar to this:
items:
'0':
material: GRANITE
slot: 0
display_name: '&fTest'
left_click_commands:
- '[console] mbedwars addon cosmetics shop open main %player_name%'
right_click_commands:
- '[console] mbedwars addon cosmetics shop open main %player_name%'
Read more about ArenasGUIs. One layout file may look like this:
header:
name: "example"
version: "1.0"
author: "MBedwars Team"
min-version: "1.13"
height: 3
title: "%ArenasGUI_Title%"
elements:
- type: executecommand-button
x: 0
y: 0
item: 'STONE'
command: 'mbedwars addon cosmetics shop open main {player}'
as-console: true
Imagine if you had a crate system, where a player may receive access to a random Cosmetics item once spinned. But how do you realize such system without hooking into the API? The answer is to grant a permission.
The Cosmetics addon will check whether a player owns such permission and if he does, grant him the ability to use item, as if would have bought it.
To make use of this system, open the config file /MBedwars/add-ons/Cosmetics/configs.yml
. Set enable-item-permissions
to true. Reload the plugin using the command /mbedwars addons cosmetics reload
.
You may now grant players permissions in the format of mbedwars_cosmetics.item.<item id>
. You may find the ids in the shop layout files (located inside the shops folder):
gl_emerald: ### Example: The permission for this item is mbedwars_cosmetics.item.gl_emerald
name: "%Cosmetics_Item_Iron_Name%"
icon: "iron_ingot"
...
For performance reasons, permissions are cached and only get updated if the player joins or the plugin reloads. You may clear the cache and enforce permission rechecks using the command:
/bw addon cosmetics shop checkitempermissions <player>
Now what if you've got items that may only be accessed during certain events or for certain roles, such as MVPs or VIPs?
For that, open the shop file which contains the items to which you want to apply this to. They are located at /MBedwars/add-ons/Cosmetics/shops/<shop>.yml
. Add the locked-permission
section, similar to this:
sp_tree:
name: "%Cosmetics_Item_Tree_Name%"
icon: "oak_sapling"
category: image-item-frame
rarity: epic
image-path: "images/sprays/tree.png"
locked-permission:
id: "mvp" ## Example: Permission would be mbedwars_cosmetics.locked-item.mvp
hint-message: "&cLimited to &6MVP&e+"
chat-message: "&cGet yourself &6MVP&e+ &cat {store} and receive access to this and many more benefits!"
The section persists of the following configs:
Name | Meaning |
---|---|
id | A string of you may chose yourself. Multiple items may share the same id. Used within the permission |
hint-message | The text that will be shown in the GUI if the player doesn't have the required permission |
chat-message | The text that will be shown in the chat if the player tries to click on the item while he doesn't have the permission |
For hint-message and chat-message you may use the {store}
placeholder, which refers to the store-url
config, which may be configured in /MBedwars/add-ons/Cosmetics/configs.yml
.
To now grant players access to these items, you may give them the permission in the format mbedwars_cosmetics.locked-item.<id>
.
For performance reasons, permissions are cached and only get updated if the player joins or the plugin reloads. You may clear the cache and enforce permission rechecks using the command:
/bw addon cosmetics shop checkitempermissions <player>