Unique Trade-Sign Plugin

Discussion in 'Plugin Requests' started by Chief Keef, Jul 27, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Chief Keef

    A plugin where you can create a trade sign (which can be bought from and sold to in the same sign) which only holds the amount of items sold to it.
    So when you create the sign it is has an empty 'stock' of items and for a player to buy items from that sign another player (or the same player at an earlier time) had to have sold items to that sign prior, meaning you can't buy more than that sign has in stock at the time, if that sign is 'out of stock' of the item it's selling you cannot buy any items from it until someone has come and 'restocked' it (by selling items to the sign)
    Think of it as a chest, you cannot take/buy the items in that chest is containing if no one has put any there yet
    This means items have to be grown, mined or otherwise acquired from the world and sold to their respective sign before they can become circulated into the system.

    With current trade-sign plugins a player could spend 10 minutes digging dirt, sell all that dirt to a dirt sell sign then use that money on a diamond buy sign without anyone having acquired diamonds from the world naturally yet.
    With this plugin a player could spend time mining, get a load of resources, sell some of it to the items' respective signs and make a bit of profit, then another player who's been spending time farming can sell their items and use the money to buy the items the miner sold. And vice versa.
    The signs could also hold multiple unstackable items like picaxes.

    The sign could look like this:
    [Buy/Sell] (which could turn blue if the sign worked and red if it didn't)
    <itemname/id>
    Buy<amount>at<buy price per item>per item-Sell at<sell price per item>per item
    <amount in stock>

    All you have to type is:
    [bs]
    <the item id/name>
    <amount>$<buy price per item>-$<sell price per item>

    And the rest will be added automatically

    Right clicking the sign with the item the sign is for will sell however many is in your hand to the sign
    Right clicking with hand or any different item will buy the item the sign is for
    Shift right clicking with the item in hand will sell all in inv
    Shift right clicking with hand or any different item will buy all the stock in the sign clicked

    Just mention it in a reply if anything is unclear

    @Zombie_Striker
     
    Last edited: Jul 27, 2017
  2. Offline

    HotChocolate

    What kind of economy plugin are you using?
     
  3. @Chief Keef
    This sounds like a nice challenge. I have just one question: Will all the signs be connected, so if you were to sell 10 diamonds to sign A, someone else could come and buy them from sign B, or are there separate contents to all of the signs?

    Also, I'll be using Vault to manage all the money (which should give support for essentially all of the common economy plugins).
     
  4. Offline

    Chief Keef

    @HotChocolate The only plugins I am using are essentials, grief prevention, vault, world edit, and permissionsEX, and lockette. So the only economy plugin I am using is essentials I guess...


    @AlvinB I think best case scenario would be having a setting to either have all signs with same item id, buy-amount and price be connected (so you could have two or more shops be connected across the map or even across worlds), or have all signs be separate as I can think of ways both would be useful.
    Having them all connected would be good for a server shop and if players wanted to do inter-player trading they could use essentials signs.
    So I'd say that if you can't have a setting to switch between the two then go for having all signs with same item id, buy amount and price be connected.

    I'm not too familiar with how Vault works, but I have it installed so if this plugin will use it then I'm sure it will be fine.

    Thanks so much!

    EDIT: Even if the plugin auto detected when two signs were the exact same and would link them would be sweet
     
  5. @Chief Keef
    Right, I'll make an option to either:
    • Make all signs separate so if a player sells 10 dirt to sign A, those dirt blocks could ONLY be bought from sign A, sign B would still be empty, even if it had the same options (amount, price and item)
    OR:
    • Make signs with the same options link, so if a player sells 10 dirt to sign A, those dirt blocks can be bought from sign B aswell, as long as sign B has the same options (amount, price and item) as sign A. This would be automatically detected.
    Is this correct?

    EDIT: Also, Vault is basically a bridge between plugins using money and economy plugins. What this means is that I can use the same code to work with all Economy plugins (that support Vault, of course), avoiding to interact with each one individually.

    EDIT #2: I also propose to change what you put on the top sign to [NaturalSShop] (I plan on naming the plugin NaturalSignShop), since [Buy/Sell] is a bit too generic and might cause interference with other plugins. If this is an issue for you, please let me know, and I'll make it configurable.
     
    Last edited: Jul 28, 2017
  6. Offline

    Chief Keef

    @AlvinB
    That all sounds great!
    The setting would help heaps, would the setting be changed in a config file or on the sign in game?

    NaturalSignShop sounds like a great name too.
    It might be a little bit of a hassle to write [NaturalSShop] on each sign so maybe notation could be [nss] or something
    I dunno, just an idea... I figure if you have to make tons of signs then writing [NaturalSShop] on each one might get a little annoying after a while
     
  7. @Chief Keef
    The setting would be in a config file.

    And I can certainly implement [NSS] as an alternative (I'll use ignoreCase, so capitalization won't be a problem).
     
  8. Offline

    Chief Keef

    @AlvinB
    Ok sweet

    EDIT: I don't mean to sound rude but, I was just wondering how long it takes to develop a plugin from the ground up...
    I've got no experience with any of it so I am clueless as to how long the development process is.
     
    Last edited: Jul 28, 2017
  9. @Chief Keef
    Well, it totally depends on what type of plugin it is. A really simplistic plugin can take 10 minutes, and a really complicated one could take 10 days. This one is intermediate I'd say, so it should take about 2-3 days.

    Also, I'm decently close to finishing this, I should have it done by at least tomorrow. There is a question I have to ask though. Do you want a permission for creating these signs? I assume you don't want every odd player to be able to create a dirt sign to sell to for ridiculous prices..
     
  10. Offline

    Chief Keef

    @AlvinB
    Yeah, a permission for it would be great. I hadn't thought of that
    Would there be a permission for create and one for use?
    Also will the signs work for trades like XP points (someone farms xp and can sell it for someone else to buy)
    Not a totally must have feature but if it's easy to implement then it would be a nice addition.

    EDIT: Any news on the progress?
     
    Last edited: Jul 31, 2017
  11. @Chief Keef
    Right, I had some unexpected things (real life, boring isn't it?), so I couldn't work on the plugin yesterday. I have finished the functionality of the plugin, but I have not tested (and to implement your xp request, I'd want to change a couple things). But if you want the untested and unfinished version, here it is:
    http://bringholm.com/downloads/NaturalSignShop-1.0-SNAPSHOT.jar

    Please do tell me about any bugs that you find.

    EDIT: Oh, and the plugin uses metrics on bstats.org. If you wish to opt out of this, go to the plugins/bStats/config.yml file.

    EDIT #2: Adding the xp buying right now, but I ran into one problem. How should it know when to sell or when to buy the xp? You can't really hold XP in your hand.
     
    Last edited: Aug 1, 2017
  12. Offline

    Chief Keef

    @AlvinB
    Hmm, I had a think about it and maybe the xp selling doesn't need to be added...
    Like you said you can't hold it in your hand so there would have be a different way of buying and selling and at the moment I can't think of any smooth ways of doing it.
    Maybe, later on, if we think of a better way to implement it then it could be added.

    I'll install it on my server later today and will try and test as much as I can.

    EDIT: So far so good, working great!
    However, I noticed that upon running the server with the .jar in the plugins folder, no NaturalSignShop folder was created (with the config.yml, etc in it). I'm unsure if this is a bug or just because it's a snapshot at the moment.
    But otherwise I was able to create a sign to sell diamonds and it's all working perfectly.
    Currently the setting to make 'signs of the same type be connected' is off.
     
    Last edited: Aug 1, 2017
  13. @Chief Keef
    Yeah, that version doesn't have the config implemented. Permissions are not added either at the moment.

    I will scrap the xp idea, but the framework is in place to readd it (or anything else which can be given and quantifiable) if we come up with a good way to differentiate between selling and buying.
     
  14. Offline

    Chief Keef

    @AlvinB
    Ok sounds good.
    I'll keep you posted with any bugs I find.
     
  15. @Chief Keef
    Alright, I have now added the remaining features, and done some testing. Download link is here:
    http://bringholm.com/downloads/NaturalSignShop-1.0-SNAPSHOT.jar

    As previously mentioned the plugin uses Metrics on bstats.org. This can be disabled by going to plugins/bStats/config.yml.

    Source code is here.

    I also added a nice little info mode to the signs. If you left click on a NaturalShopSign, it will scroll some extra information about the sign. Try it!

    There is only one command, /naturalsignshop reload (you can also use nss and naturalsshop as command name), which reloads the configuration files belonging to the plugin.

    Permissions are as follows:
    • naturalsignshop.reload - Gives access to /naturalsignshop reload
    • naturalsignshop.create - Lets you create NaturalSignShop signs. You can also specify that users will be able to create signs with only a certain type. This is done with naturalsignshop.create.string_id (Ex. naturalsignshop.create.iron_block or with naturalsignshop.create.numerical_id (Ex. naturalsignshop.create.42). Data values can be represented by a colon (Ex naturalsignshop.create.stone:1 or naturalsignshop.create.1:1)
    • naturalsignshop.buy - Lets you buy items from a NaturalSignShop sign. This permission is given to everyone by default.
    • naturalsignshop.sell - Lets you sell items to a NaturalSignShop sign. This permission is given to everyone by default.
    • naturalsignshop.scroller - Lets you use the left click scroll mode to view extra information about a NaturalSignShop sign. This permission is given to everyone by default.

    Config is quite self-explanatory. Don't hesitate to ask questions if you have any! :)
     
  16. Offline

    Chief Keef

    @AlvinB
    Awesome!
    Installing it now!
     
  17. Offline

    Chief Keef

    @AlvinB
    I think I've found a bug. When I put melon as the item Id, the sign reverted to melon blocks, then I used 360 (item Id for melon) and it still reverted to blocks. Item Id for blocks is melon_block / 103.
     

    Attached Files:

  18. @Chief Keef
    I found the issue. Because I parse based on localized name first (so you can do 'cyan dye' instead of 'dye:6'), and some items have ambiguous localized names (both melon blocks and melon slices have the display name Melon), the parsing system would get confused. I have now changed it so localized names are ignored for any items with ambiguous names, so now you can only use 'melon' and 'melon_block' for melon slices and melon blocks respectively.

    It also turns out there was more ambiguity, in addition to Melons, Red and Brown Mushrooms, Snow Blocks and Snow Layers, Stone and Wooden Buttons, Clay Blocks and Clay Balls, Nether Brick Blocks and Nether Bricks and Music Discs all have conflicting names. These have all been fixed and should be working.

    Here's the new version:
    http://bringholm.com/downloads/NaturalSignShop-1.0-SNAPSHOT.jar
     
  19. Offline

    Chief Keef

    @AlvinB
    Ok sweet I'll give it a test later today.
     
Thread Status:
Not open for further replies.

Share This Page