[INACTIVE][MECH] SimpleBarter 1.2 - inventory trading [612-677]

Discussion in 'Inactive/Unsupported Plugins' started by Afforess, Mar 29, 2011.

  1. Offline


    SimpleBarter - trade in inventory dialog
    Version: v1.2

    Want to be able to trade items other players with other players without dropping them on the ground (where accidents can and do happen...)? Don't want to use the nasty, easy to forget, easy to mess up command system that other plugins use? Barter on your own terms.


    SimpleBarter allows players to trade items in their inventory with other players easily. Simple tap another player while your hand is empty. They will be notified that you want to trade, and will tap back if they want to trade. A dialog with both of your inventories in it will appear, allowing both players to drag and drop items seamlessly into each others inventories. Once either of the players closes the inventory dialog, both inventory dialogs will close (that way, a sneaky player who leaves it up while you walk away, can not steal stuff. It will close once you leave).

    Other Notes:
    Tapping multiple times rapidly on one player will only give them 1 notification (won't spam chat log). It will tell the tapper to quite pestering other players as well. Additionally, this plugin blocks damage from tapping with nothing in your hand, to other players. Using any item will damage players normally.

    No Commands.
    No messy Configuration.
    No Dependancies.
    No Hassle.


    Download Here
    Source Code

    • version 1.0
      • initial release
    • version 1.1
      • added configuration
      • added right click to trade
      • added item configuration
    • version 1.2
      • Optional backpack support
    ray landers, anon and Digi like this.
  2. Offline


    Just a suggestion, but what about making it so your hot bar does not show up? That way you can hide anything you do not want to lose in the hot bar.
  3. Offline


    the idea is wonderful, but this plugin absolutely makes no sense to me as long as the players can directly access each others inventory and pull items into their own.
    They should be able to just drop items from their own inventory into the other player's inventory...
  4. Offline


    I have an idea how it could work more securely.

    How bout in a trade, the player who initiates the trade sees an empty chest GUI. They place their offer in the empty chest.
    Then the other player sees a chest with those items in there, and they take the items and place their counter offer.
    Finally the originally player sees the counter-offer, and if he takes the items the transaction is completed.

    On the other hand, if the items are not taken by the other player then the original player's items are removed from the other player's inventory and returned. Same if the other player doesn't accept the offer, he simply would close the chest without taking the item, and the item is returned to the original player's inventory.
  5. Offline


    I was literally typing this same thing into this chatbox when I saw this post above.

    If you do this suggestion, I can guarantee SimpleBarter will be used on almost every server. It will be like the "WorldGuard" of trading.
  6. Offline


    @furyx639 & @Kahl

    That's not a bad idea. Actually, it's an excellent idea. I'll start working on it during my next available free time.
  7. Offline


    I would seriously consider donating if that got done.

    Also, if you didn't want to make it so that the chest interface opened for each user like fury suggested, what if just a single chest opened up and both users saw what was in it and could exchange items in it? That would be much simpler and do-able I think. There could always be a short delay and chat line saying "WARNING: Any items put in the chest can be taken by *username of other player* at any time".
  8. Offline


    Cant it tell that you are right clicking a user, not air or a block or something?

    The right clicking is literally impossible to use, and on a pvp server left click trading is useless.

    Right clicking wolves with bones is accurate, surely there is a way that same method could work for being able to tell you're right clicking a player.

    EDIT: After testing this out, we have seemed to make the trading work by each standing on opposite sides of the door. As long as the door is selected by our mouse, but the other person is on the other side of it, it will send a trade. It seems you must right click a block with the person behind it? Strange, can you make it if you right click an air block with a person behind it? I don't know anything about coding I'm just trying to figure out right click.
  9. Offline



    If you read my posts, I mentioned that right clicking did not work well. There is nothing I can do about it.

    @Others re: the improved trading system. It's turning out more complicated, because Bukkit lacks the hooks for it. I'm working on writing these hooks for bukkit so I can move forward.
  10. Offline


    I think you could do something about it which is what I'm saying. If the client can send to the server that you accurately right-clicked a wolf, then it should be able to do it with a player; correct me if i'm wrong.

    I read your posts and I thought I found something that could help solve it. This plugin won't go far if it has to rely on left click and frankly the servers that need trading the most are pvp serverd which enable left click damage.
  11. Offline


    Actually - you've got a good point. I did some digging, and it doesn't actually use right clicking, it has to do with the player is aiming the cursor. I'm going to duplicate that and find out how well that works as a replacement.

    I appreciate the help, but veiled threats are not necessary.
  12. Offline


    Awesome, if you get it to work that'd be insane, and what i said was not meant to be a veiled threat in any way. I was just being realistic because the RPG servers that need this the most (including mine) can't have trading with left click because it attacks.
  13. Offline


    Make it a chest interface appearing for both players. You drag and drop items into the chest and then the other person drags and drops into their inventory. Vice versa. Something like that?

    I really like how this mod is done, but the way it works currently doesn't work well. People can just loot other people's inventories clean, or at least get away with one item even if they cancel right after they accept.

    I think right-clicking is a nice concept. Maybe with a particular item? Or left-clicking with a particular item other than fist..?
  14. Offline


    Read the discussion - it will be changing formats soon.

    See the config file.
  15. Offline


    Okay, thanks.
  16. Offline


    @SuppressWarnings({ "rawtypes" })
     private List getEntityList(PlayerInteractEvent e) {
      Location loc = e.getPlayer().getTargetBlock(null, 4).getLocation();
      Location loc2 = e.getPlayer().getLocation();
      double x1 = loc.getBlockX() + 0.4D;
      double y1 = loc.getBlockY() + 0.4D;
      double z1 = loc.getBlockZ() + 0.4D;
      double x2 = loc2.getBlockX();
      double y2 = loc.getBlockY() + 0.6D;
      double z2 = loc2.getBlockZ();
      return ((CraftWorld) e.getPlayer().getWorld()).getHandle().b(
        ((CraftPlayer) e.getPlayer()).getHandle(),
        AxisAlignedBB.a(Math.min(x1, x2), y1, Math.min(z1, z2),
          Math.max(x1, x2), y2, Math.max(z1, z2)));
    @Afforess - this is the code I use to get right clicked entities (just check if the list size is 1).
  17. Offline


    Looking forward to utilizing this mod with a controlled inventory. As it is I use it to trade with trusted people on my server and it's a really great mod.
  18. Offline


    Utilizing fullwall's right click along with opening a virtual chest for both players (a "trade box") would make this plugin ideal for my server :)
  19. Offline


  20. Offline


    Great, thank you. I have been messing around with a couple ideas unsuccessfully, I appreciate the code snippet.
  21. Offline


    Oh... just realised, you may want to up the max range on GetTargetBlock.
  22. Offline


    Yeah, I played around with it.

    Edit: Still not perfect though... I wish there was a packet for right clicks...
  23. Offline


    keep up the good work :)
    I love this plugin so much :D
  24. Offline


  25. Offline


    I've got right clicking working perfectly, and this almost done - but I've snagged on the last (but important) part.

    Okay, let's explain how this works first:

    Right click on a player. It pops up with a double inventory screen, with the OTHER player's at the top, an empty inventory on the bottom. You drag items you want to request from the other player to the bottom.

    When you close that, instantly, a second double inventory screen pops up. The bottom inventory is your inventory, the top is empty. The top is where you will drag items to be traded FOR what you requested in the last screen.

    When you close the 2nd screen, the player you right clicked get's alerted to the trade. A popup with what they will lose on the top, and what they will gain on the bottom appears.

    Now, the above it all coded and works flawlessly.

    The snag is what to do when the 2nd player sees the offer and request screen. How does that player accept the trade? Should They have to tap the other player back once to accept it?
  26. Offline


    Could you post some pics of this plugin :) The best option I can see for this is to just bring up your inventory and say a chest where you control half and the person your trading with controls the other half, In my opinion you don't need to see what the other person has just what they are trading. This way there is no stealing maybe (I don't know how >.>) you could do a confirmation that both parties are happy before the trade goes through and when you confirm your trade its locked in (no taking stuff out at the last second)
  27. Offline


    The player initiating the trade shouldn't be allowed to see the other player's inventory.

    In some situations that might be undesirable, like say for example if you want to run a server that plays like an MORPG where items can be stolen if you kill the other player. I think trades can be negotiated in chat, as it is commonly done in other MMORPGs, and they'll actually perform the trade in your system.

    The 2nd player should accept the trade by dragging the items into their inventory. They deny it by closing the inventory screen without taking the items.
  28. Offline


    If you never see the other player's inventory - how do you know what to request? How do you know if the other player isn't just going to take your stuff and leave? I though the point of trading was so that both sides give something. How is your idea any better than the current system?
  29. I would think when a trade is initiated, both players would see an empty trunk dialog. They would both put their offerings in an empty virtual trunk. When they both close their dialogs, they would both see another trunk dialog this time with the other player's offering in the trunk section. How to decline or accept I don't know.

    Steps are:
    Player A - offer trade
    Player B - accept trade offer
    Player A & B - choose from their inventory and place trade offering in empty trunk dialog
    Player A & B - view offered trade items from other player
    Player A & B - close dialog (trade is still pending).
    Player A & B - say /trade accept or /trade review or /trade deny (or just wait for say a 30 second time out or a new trade)
  30. Offline


    Here's my idea for the steps:

    1. Players negotiate the terms of the trade in chat (ie "wanna trade X for Y?" "Sure")
    2. Player A initiates trade (right click)
    3. Player B is notified of trade, and accepts (right click)
    4. Player A and B both see an empty chest on top, and their own inventory on bottom.
      Player A and B drag the items they're offering into the empty chest.
      Once both Player A and B's chest are closed the trade continues.
      Note: Automatically cancels if trade timeout (player takes too long)
    5. Player A now sees chest with Player B's offerings on top.
      Player B sees chest with Player A's offerings on top.
      Trade is considered accepted if both players drag the items into their inventory.
      Note: Another step that needs a timeout if player takes too long.
    6. If either chest still has items in it, the trade is considered cancelled, and the items are returned to their original Player's inventory.
  31. Hehe, step 5 and 6 where my first idea, but i thought having to drag all the items was a little tedious. It would certainly make sure both players really really wanted to complete the trade though :)

Share This Page