Shopkeepers

Logo without text, tiny

Logo_Header

This plugin allows you to set up custom villager shopkeepers that sell exactly what you want them to sell and for what price. You can set up admin shops, which have infinite supply, and you can also set up player shops, which pull supply from a chest. It will also prevent any other trades with non-shopkeeper villagers if you want it to.

Installation and Configuration

Simply download the latest file and put it into your plugins folder. When the plugin first loads, it will create a config.yml file in the Shopkeepers folder. There are several configuration options you can customize. See the Configuration Options page for more information.

Note that this plugin is created to work with CraftBukkit (or alternatively Spigot). Bukkit does not have an API for some of the things necessary to make this plugin work. This means that other server software (Tekkit, Forge, etc.) will not work with this plugin.

In case you want to run this plugin on MC 1.8: this plugin supports Spigots updated versions of CraftBukkit. Other CraftBukkit derivatives/forks for MC 1.8 are not supported.

Creating a Shopkeeper

To create an admin shopkeeper, just use the command /shopkeeper [object type] while looking at a block. A villager will be spawned at the block you are looking at.

To create a player shopkeeper, you will need a villager spawn egg (or whatever item is defined in the config file). You must not be in creative mode when creating a shopkeeper. First, you can right-click in air (not on a block) to cycle through the different shop types (normal, book, buying, and trading). You can also hold sneak while right-clicking to cycle through the shopkeeper types (villager, sign, witch, ..). Then, right click on a chest to select it, then right click on another block to place the shopkeeper at that location.

You can also create a player shopkeeper by using the /shopkeeper [shop type] [object type] command while looking at a chest, but this will make the shopkeeper stand on top of the chest.
If no shop type and no object type are specified in the command, then either your current selection (the one you made via right clicking with the creation item in hand) or the default will be used. Alternatively you can specify only [shop type], only [object type], or both.

Every shopkeeper villager's AI will be overwritten so it doesn't wander away, and it is invulnerable to damage. It will also teleport back to its spawn location after a few seconds if it gets bumped out of place.

The default available player shop types are: normal (alias sell), buy, trade, book.

Shop object types are the things which represent the shop in the world, ex. the villager entity by default.
The default available shop object types are: sign, citizen (alias npc), or the mob name for all currently supported mob types.

Setting Up Trades (Admin Shopkeepers)

To modify the shop's trades, right-click on the shopkeeper while sneaking. This will open a regular-looking chest inventory, but it has a couple special icons on the right.

http://nisovin.com/shopkeepers/shopkeeper_admin_editor.png

Each column in the inventory represents a trade option. The top item is the first cost, the middle item is the second cost, and the bottom item is the item to sell. The top and bottom items are required, but the middle item (the second cost) is optional. You can simply drag your recipes into the inventory. You can input up to eight recipes on a shopkeeper.

Once you are done editing the trades, simply close the inventory window to save. Now just right click on the shopkeeper, and see the trades! It should work with any items, including enchanted items and written books.

To set the shop's name, click the anvil then type the name into the chat. You can cycle through the villager professions by clicking on the wool block. If you want to delete the shopkeeper, you can click on the bone in the bottom-right corner (be careful, there is no undo!).

Setting Up Costs (Player Shopkeepers)

First, the player will need to place items they wish to sell in the chest. In order to sell written books you must use the special book shopkeeper (in this case, you must put the written books you want to sell in the chest, then stock it with book & quill items).

http://nisovin.com/shopkeepers/shopkeeper_player_chest.png

Then, right-click on the villager while sneaking. This will open up the shopkeeper editor. The top row will show the various item types for sale from the chest. The bottom row will show the costs of those items. If no cost has been specified yet, there will be a slimeball. To modify the cost, left-click the emerald (or slimeball) to increase the cost, and right-click to decrease the cost. You can also hold shift while clicking to modify the cost by 10 at a time. You can adjust the item quantity in the same way, with left and right clicks.

http://nisovin.com/shopkeepers/shopkeeper_player_editor.png

Once the costs are all set up, just close the window to save. You can also click the anvil to rename the shopkeeper, click wool block to cycle through the villager professions, and click the fire to delete the shopkeeper.

When a player purchases an item from a player shopkeeper, the item in the chest will be removed and the emeralds used to purchase will be added. Due to limitations in the game, the trades will not update even when a player purchases the final stack of a certain item. However, if a player attempts to make a purchase when the chest is out, the trade will fail and the trade inventory window will close automatically.

For the special "buying" shopkeepers, you must place at least one of each type of item you want to buy in the chest, as well as plenty of currency. Then when you open the editor interface, it works the same except the items are on bottom and the currency is on top. A buying shopkeeper can only buy basic items, not enchanted items, books, or maps.

For setting up a "trading" player shopkeeper, Mouro001 created a small tutorial about it here: imgur.com/82NnbPU

Available mob types

You can theoretically try to use any living entity type as shopkeeper entity. However, not all entity types will actually properly work: While some might only show some weird but harmless behavior, others might cause more serious issues to your server or save-data.

Therefore, only a small tested subset of the available living entity types are currently enabled by default.
If you want to try out (on your own risk) if another living entity type works as shop entity, you will have to manually enable it in the config.

Also each of those enabled mob types can only be used if the player has the needed permission node: shopkeeper.entity.<mobtype> (or shopkeeper.entity.* for access to all enabled mob types).
By default players are only able to create villager, witch or creeper shops (if those are not disabled).

For compatibility with older versions there exist alternative permission nodes for some mob types: shopkeeper.villager, shopkeeper.witch and shopkeeper.creeper

If you want to use other entity types you might want to try out shopkeeper's integration with the citizens plugin! See below for information on that.

Citizens shopkeepers

There is experimental support for shopkeepers using citizens npcs (disabled by default).
The permission needed to create citizens player shops is: shopkeeper.citizen

You can create an admin citizens shopkeeper with the command /shopkeeper npc.
Alternatively there is a 'shopkeeper' trait which you can assign to already existing citizens, though creating the citizens with the above command is the recommended way of doing it.

Citizens admin shopkeepers will default to normal villagers as mob type. You will have to use the citizens commands to change the mob type of the npc.

Citizens player shopkeepers will automatically default to player-type npc's with the name of the shop owner. There is a configuration options which determines if player's are allowed to renamed those npc player shops (default: false).

Special Commands

Help

Using the /shopkeepers help command will display the available commands. Commands for which a player doesn't have the needed permission get filtered out.

Reload

You can use the /shopkeepers reload command to reload the plugin. This will save any changes and reload the config file.

Debug

Use /shopkeepers debug to toggle debug mode. This allows you to see sometimes useful information in the console.
Also there is a /shopkeepers checkitem command, which prints debug information about the item in hand, and the item in the next slot.

List

Use /shopkeeper list [player|admin] [page] to list the players own shops (if no player / 'admin' is specified), the shops of a specified player or all admin shops. The shops are divided into pages.

Remove

Use /shopkeeper remove [player|all|admin] to remove the players own shops (if no player/'admin' is specified), the shops of a specified player, all player shops, or all admin shops. The command needs to be confirmed by the player via /shopkeeper confirm.

Transfer

Use /shopkeepers transfer playername to transfer ownership of a shopkeeper to another player. You must use this command while looking at a chest owned by a shopkeeper.

Trading permission

Use /shopkeepers setTradePerm <shop-id> <tradePerm|-|?> to set, remove (-) or display (?) the trading permission for an admin shopkeeper specified by id, unique id, or name. This trading permission will be required when a player tries to trade with the affected shopkeepe, additionally to the general trade permission.

Hire

Use /shopkeepers setforhire to set a player shopkeeper for hire. Hold the hire cost in your hand, and look at a chest owned by a shopkeeper when you use this command. This will allow another player to pay the hire cost and gain ownership of that shopkeeper.

Permissions

PermissionDescriptionDefault
shopkeeper.*Includes all other permissions.op-only
shopkeeper.adminCreate and modify admin shops.op-only
shopkeeper.debugAccess to the debug command.op-only
shopkeeper.bypassModify player shops that you do not own.op-only
shopkeeper.reloadUse the /shopkeeper reload command.op-only
shopkeeper.list.ownList the own player shops via command.everyone
shopkeeper.list.othersList the shops of other players via command.op-only
shopkeeper.list.adminList all admin shops via command.op-only
shopkeeper.remove.ownRemove the own player shops via command.op-only
shopkeeper.remove.othersRemove the shops of other players via command.op-only
shopkeeper.remove.allRemove all players shops of all players at once via command.op-only
shopkeeper.remove.adminRemove all admin shops via command.op-only
shopkeeper.remoteRemotely open admin shops via shop name.op-only
shopkeeper.transferTransfer a shopkeeper to another player.op-only
shopkeeper.setTradePermSet the trade permissions for admin shopkeepers.op-only
shopkeeper.setforhireSets a shopkeeper to be up for hire.op-only
shopkeeper.helpAccess to the help command.everyone
shopkeeper.tradeAllows trading with shopkeepers.everyone
shopkeeper.hireAllows a player to hire a shopkeeper.everyone
shopkeeper.player.normalCreate normal player shops.everyone
shopkeeper.player.bookCreate book-selling player shops.everyone
shopkeeper.player.buyCreate buying player shops.everyone
shopkeeper.player.tradeCreate item trading player shops.everyone
shopkeeper.playerAll player shops.
shopkeeper.entity.<mobtype>Create shopkeepers of the specified mob type
shopkeeper.entity.*Create all types of mob shopkeepers.
shopkeeper.entity.villagerCreate a villager shopkeeper.everyone
shopkeeper.entity.witchCreate a witch shopkeeper.everyone
shopkeeper.entity.creeperCreate a creeper shopkeeper.everyone
shopkeeper.signCreate a sign shopkeeper.everyone
shopkeeper.maxshops.<option>Check out the configuration options for this.none

Video Tutorials

A tutorial by KreatorB showing how to setup shops with the more recent versions

A tutorial showing how to setup the trading player-shopkeepers: https:www.youtube.com/watch?v=5E2lOQQ_mPQ

An old but good tutorial provided by TrowbridgeHD/RyanDT13

Frequently Asked Questions

Something's gone wrong! I have a problem! Will you please help me?

Submitting a ticket is the best way to get help or report a problem with the plugin. Please provide the version you are using of both Craftbukkit/Spigot and Shopkeepers, and thoroughly describe the problem you are having, including step-by-step instructions on how to reproduce the problem.

My shop isn't working! Why can't I buy stuff from my shop?

You cannot buy items from your own player shop. This restriction is in place to help reduce duplication bugs if and when they arise. It doesn't completely prevent them, but it helps keep them from being obvious.

A shop isn't working! I can't take the item out of the trade result slot!

The items offered for the trade probably don't match the required items. The plugin not only compares the item types but also additional internal data of the items like display names, lore, enchantments, data values / durability, attributes and all kinds of even more specific data for items like skulls, books, potions, fireworks, etc.
If you turn debug mode on you should get detailed information in the console log why certain trades failed.

Why don't colors seem to be working in the config? They seem to turn into weird characters!

You should try setting your file-encoding option in the config file. Set it to "UTF-8".

I can't use color codes for shopkeeper names!

Every time a shopkeeper is renamed the new name get validated first. The plugin uses a regular expression for this validation which you can find and edit in the config file. This regular expression specifies which characters can be used for the name and how long the name has to be at least and at maximum. By default this regular expression might not contain the color code character '&'. So in order to allow colors for shopkeeper names you have to add that character to the regular expression in the config.

Will you add support for currency plugins (integrate with Vault)?

No, sorry. The trade interface is really designed for item trades only. For example, the purchase item doesn't even show up until you've put in the item cost required. As an alternative, you could use another plugin to create some sort of bank, where you would buy and sell emeralds for virtual currency. In this way players could deposit and withdraw emeralds for shopping. You may also be interested in the plugin Gringotts or GoldIsMoney.

How can I get shopkeepers to spawn when some other plugin like WorldGuard blocks them?

You could first try if it works when you enable the setting 'bypass-spawn-blocking' in the shopkeeper config.
If that doesn't work you will have to search for a setting in the other plugin which allows disabling this spawn blocking.
WorldGuard for example has a configuration option to specify which mob types it blocks from spawning. The option is under mobs, called block-creature-spawn. If it is empty, you will need to add in all of the creature types you wish to block, making sure you leave out Villager. Another option is to set WorldGuard's block-plugin-spawning option (also under mobs) to false, but this may have other side effects.

Can I have more than eight trades on a shopkeeper?

I feel like eight trades is plenty to have on one shopkeeper, and that it would be best to set up multiple shopkeepers if you need to have more items for sale. However, if you insist, it is possible, just more work.

For player shopkeepers, it's actually fairly easy. The cost setup will show the first eight item types in the chest. So, just set up the costs for those items, then rearrange the items in the chest. You will then be able to set up the costs for the other items.

For admin shopkeepers, the only way is to modify the save.yml file and add the options manually. Please note that I do not support doing this. If you try to do this and mess up your save file, you'll have to fix it on your own. In my opinion, you shouldn't do this anyway. It is a lot more user-friendly to have multiple shopkeepers with various categories of items (probably indicated by nearby signs).

Can you instead just rebalance the regular villager trade options, or allow admins to configure what trades are possible with regular villagers?

There is another plugin that offers villager trade rebalancing as well as custom trade options, you can find it here: http://dev.bukkit.org/server-mods/rebalance-villagers/

Oh wise Nisovin, how can I create a successful economy?

I've actually put a bit of thought into this. You can read my opinions here.

I am a plugin developer: How can I check if a given entity is a shopkeeper?

Every shopkeeper entity should be tagged with the 'shopkeeper' metadata, so you can check for that.

Can I see the source code?

Certainly, here it is.

Changelogs

You can find all previously uploaded files together with their changelogs on the 'Files' page.

Donations

If you like this plugin, consider leaving a donation for Nisovin, the original author, or for blablubbabc. Thanks!

Want to help? Looking for a documenter!

Hey! I am looking for someone who would be willing to actively get involved in the project.
Currently that would probably mostly mean helping me with keeping the documentation up-to-date / improving it, but if you have any ideas on how you can contribute to the project beyond that, let me know!
If you are interested, feel free to contact me via PM.

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of papaguii papaguii May 01, 2016 at 22:13 UTC - 0 likes

    I am using Spigot 1.9.2 with this plugin, right clicking looking to the sky doesnt do anything with the item set in the config, also the help menu doesnt tell me how to use the commands, dont tell me the shop types, and appear to be showing the arguments in the wrong order, when I create a villager, I have to type /shopkeeper villager or /shopkeeper doesnt matter what I wirte after that its pretty much the same command that spawns an admin villager shop, without a chest, I am trying to create players shop, even using /shopkeeper sign aiming to the chest it doesnt count the chest and just act as an admin shop. How do I create players shop?

    EDIT

    I noticed you posted an update I will try it and see if it fixes my problems, I might be just confused, I am pretty sure I was able to create players stores once, but now the command seems to not work anymore. Thank you very much! This plugin is great!

    EDIT

    Apparently my problem could be related with a setting simulate-right-click-on-command: I got it fixed.

    Last edited May 01, 2016 by papaguii
  • Avatar of blablubbabc blablubbabc May 01, 2016 at 21:44 UTC - 1 like

    v1.72 for MC 1.9.x, 1.8.x, 1.7.10

    This update contains a change, which might require you to update your permissions.

    • Changed the setTradePerm permissions to 'shopkeeper.settradeperm' (all lower-case), to match the other permissions and potentially cause less trouble with certain permissions plugins.
    • Fixed a typo in the default config: 'msg-trade-perm-removed' instead of 'term'.
    • Fixed an issue related to the shopkeeper citizens trait when either shopkeepers or citizens are not running: Unregistering shopkeeper citizens trait whenever shopkeepers or citizens get disabled. And added an additional check to ignore shopkeeper citizens trait attachments if shopkeepers isn't currently running (just in case).
    • Removed the restrictions of not being able to open shops while holding a villager egg in the hand by slightly changing the way the villager trading menu gets opened for past minecraft versions.
    • Removed the no longer used 'msg-cant-open-shop-with-spawn-egg' message.
    • Fix: The remote command should now work again.
    • Added: Preventing shopkeepers from entering vehicles.
    • Improved filtering out of faulty trading offers in the saved data.
    • Fixed: The shop creation item, the hire item and the currency item get now automatically set to their defaults if they are invalidly set to AIR in the config. The (high) zero currency items should now even work in the player shop editors if being of type AIR.
  • Avatar of blablubbabc blablubbabc Apr 26, 2016 at 15:31 UTC - 0 likes

    @boushwa: Go

    Quote:

    there is no preference as to opening a virtual chest based on a command or button click

    I was more a comparison of using the virtual chest vs using a 'real' chest placed in the world. With the chest being in the world, an admin would have to link it,and the plugin would have to protect the chest (similar to player shop chests), and maybe react to admins changing the chest contents. However, shopkeepers wouldn't have to store the contents itself in the save file then.

    Quote:

    and then when a player clicks the actual shopkeeper then they can see what is actually the current remaining stock

    They would see the trades for which the stock had enough items for when they opened the trading window. Similar to the trading window of player shops.

    One could also have multiple commands: One for viewing (and maybe even modifying) the currently remaining stock (/shopkeeper stock). This could maybe also be available for players to access their player shop chest via command. And one for viewing and editing the stock-refilling ('/shopkeeper stock source' or similar..). And then '/shopkeeper stock refill' (or 'refresh') to manually refresh the stock, and '/shopkeeper stock rate 24' or similar to set the refresh rate in hours.

  • Avatar of boushwa boushwa Apr 26, 2016 at 11:25 UTC - 0 likes

    @blablubbabc: Go

    If the chest solution could work out, there is no preference as to opening a virtual chest based on a command or button click. Whichever is easiest and works best.

    I would assume viewing the contents of the chest should show the stock which automatically gets refilled if it is for an admin's eyes only and then when a player clicks the actual shopkeeper then they can see what is actually the current remaining stock - could it potentially work like that?

  • Avatar of blablubbabc blablubbabc Apr 26, 2016 at 11:15 UTC - 0 likes

    @boushwa: Go

    I would really prefer the 'limit number of trades' option currently (instead of limiting the number of items), because detecting how many items were actually traded is currently not that trivial as it seems, due to all the different inventory clicking actions the player can perform. That's one reason why for player shops there are certain special clicks (shift clicking, etc.) prevented, because there it matters to know how many items were actually traded.

    However, I can see if I am maybe able to improve the 'traded items'-detection to calculate the amount of traded items depending on the used clicking action, the clicked item, the current items on the cursor, etc. Which would also be required to properly log trades, and it would maybe allow lowering the player-shop restrictions.

    So if that works out, then the chest solution would probably be most convenient. It could even be a virtual chest which opens via command or button click only. Not sure what is prefered.
    However, would the chest display the shop's current remaining stock, or the stock which gets automatically refilled? The first would be needed to see how many items the shop has left, while the second would be needed to configure the shops total stock.

  • Avatar of boushwa boushwa Apr 25, 2016 at 23:48 UTC - 0 likes

    @blablubbabc: Go

    Would it be easier to connect an admin shop to a chest and have the overall contents of the chest auto-replenish after a set number of hours/days?

  • Avatar of blablubbabc blablubbabc Apr 25, 2016 at 23:31 UTC - 0 likes

    @boushwa: Go

    Setting it up per item/per trade might be difficulty to do via command currently. The trades don't have any persistent id currently, which would allow me to reference additional data like this with them (and I don't like trying to squize it into the current recipes data). I will have to refactor this part before something like this could be added.
    Anyways, best you create a ticket for your request, including command recommendations or similar, so I don't lose track of it.

    Last edited Apr 25, 2016 by blablubbabc
  • Avatar of boushwa boushwa Apr 25, 2016 at 21:07 UTC - 0 likes

    @blablubbabc: Go

    Thank you for responding to my comment. Personally speaking, a simple command like that would work for me as an admin user with the following caveats:

    • Able to set any duration per item per Shopkeeper; it would need to be a per item setting
    • Able to set the quantity to any whole number

    The reason I'd like to see something like this implemented is due to supply and demand. I'd like to have the ability to let the admin shop run out of stock and remain out of stock for the duration of a day, 3 days, a week or whatever period of time and then restock automatically with no action on my part as admin.

    I feel this would allow player shops to take advantage of the admin shops being out of stock. They can take advantage of the market situation by raising their prices and potentially selling more items to other players who frequent the admin shops.

    As someone who wishes to have both admin shops and player shops, having an infinite inventory at the admin shop puts limits on the potential of the player shops.

    Last edited Apr 25, 2016 by boushwa
  • Avatar of blablubbabc blablubbabc Apr 25, 2016 at 09:15 UTC - 0 likes

    @Bodyash: Go

    They should get teleported back every 10 second nevertheless though.
    However, I will try to prevent shopkeepers from entering vehicles in the next version. Thanks!

    @boushwa: Go

    Nope there is nothing like this available currently. Just curious: How would you expect setting this up for a shopkeeper? Would a command that sets a limit of number of trades (optionally with a specific time) for the shopkeeper be sufficient for something like this? Something like '/shopkeeper maxTrades 10 24' to limit the amount of trades the shopkeeper accepts in 24 hours to 10.

  • Avatar of boushwa boushwa Apr 25, 2016 at 03:08 UTC - 0 likes

    Perhaps I've missed this but is there a way to set up an Admin Shopkeeper to have a limited amount of inventory per a given period of time? For example - a stock of 25 diamonds available every 24 hours that auto-resets?

Facts

Date created
Aug 03, 2012
Categories
Last update
Apr 07, 2016
Development stage
Release
License
GNU General Public License version 3 (GPLv3)
Curse link
Shopkeepers
Downloads
595,331
Recent files
  • R: v1.71 for 1.9 Apr 07, 2016
  • R: v1.70 for 1.9 Mar 08, 2016
  • R: v1.69 for 1.9 Mar 01, 2016
  • R: v1.68 for 1.8 Dec 21, 2015
  • R: v1.67 for 1.8 Nov 28, 2015

Authors