[INACTIVE][ECON] TraderChest v2.0 - A chest shop [260+]

Discussion in 'Inactive/Unsupported Plugins' started by lucky456, Feb 11, 2011.

  1. Offline

    lucky456

    Introduction
    It takes me so long to do the debug things. And finally I finish it!
    It is not be exactly as hmod because I write every code by myself.
    However, I am very happy to share it, I know people always want to make gold useful somehow.
    And so, there is it. The new type of trader chest.

    Installation
    There is no commend base, data base, it just work without any extra file.
    The way to install it, just simply put jar file in the plugin folder, restart server, and it works!!

    Instruction
    The only thing you need to know it how to make shop active.
    1. place one sign and two chests line up like this.
    sign
    chest
    chest

    2.what to write on sign?
    Because I was using the sign as information source. So you must follow the format to make this shop work.

    first line of sign: user's name (it must be the same as user)
    second line: Item name
    third line : buy sell (one space between two words, you can switch order, it also will work)
    fourth line : trade rate

    EX:
    lucky456 (Lucky456 will not work because L is up case letter)
    dirt (for this line, you can use both up case or lower case)
    buy sell (same here, the case won't effect at all, but remember to have a space between two words)
    1:2 4:3 (and buy / sell rate, left is item amount, right is goal amount, from example, every 2 goal, you can trade for 1 dirt, and every 4 item, you can sell for 3 goal)

    3.how to active trading?
    After gold or item been place in the first chest. just hit it once, it will show the massage if the trading is success.

    Protection
    And for some security reason, this combination shop set can only be destroy by owner, or TNT and creeper. I wasn't do protection on these part because I think it will be much more fun to see how people will do about it :p
    It also prevent people who try to put chest that attach it to steal items. (chest will disappear)
    If the second chest is full, this trading won't continue, and it will send out the massage to the person who is trying to buy/sell things. Also, if the items in chest2 are not enough to trade, it won't continue.

    Code Sharing
    The original code is save in the .jar file. And because this is my first mod, it really kind messy. But I do put a lot conman to help people to understand what the code does.


    PS:
    The last bukkit I test is 168~260. Beside BUG report. Please also do English grammar correction for me. English is not my native language. X(

    Bug Fixed
    v1.0 - duplicate item
    v1.0 - block that contain sign get protection

    Changelog:

    v2.0 - Rewrite code inside and fix knowing bug
    v1.0 - plugin release.
     

    Attached Files:

  2. Offline

    uncovery

    this sounds great! I have to try this! do you think you could integrate this with iconomy? it would be great to be able to exchange money instead!
     
  3. Offline

    Acrobot

    I was doing almost the same thing :/
    But my plugin is going to work with iConomy :)
     
  4. Offline

    anon

    YES! just what I was looking for.


    Please make it to not conflict with this plugin here. Why choose between gold ecomony or iconomy whyle you can have both? :D

    EDIT:
    also, is there a way for this to have permissions (Niji permission plugin suport would be perfect)? Like everybody could buy from those chests, but only some people could actually make them...
     
  5. Offline

    Mercury

    Interesting, gonna try soon as I get home.
    Can you add please permissions and iConomy support?
     
  6. Offline

    lucky456

    But why would you want to do that? This shop system is actually trading stuff 1 for 1. It won't make any extra stuff to owner either seller. But if you really want to work that way, please give some detail about how you would want it to do. Then, I will see how to add the fiction.
    --- merged: Feb 11, 2011 8:20 PM ---
    Sounds great! So, I guess I don't have to change this plug in anymore lol.
    Take look my code first, see if it would help you a little bit or not. Then you would make uncovery's dream come true :p
     
  7. Offline

    anon

    Oh im not concerned about iten duplication and stuff, its just how my server works...
    I have a class based server. Miners, Farmers, Healers, Crafstmen and Traders. So every class have a particular ability, and traders ability would be to create those autmated shops.
    So for this to work nice, the only groups that would be able to create those shops would be those traders, while everybody would be able to buy.

    Another thing that I dont know if happens on your plugin, but on old hmod tradecraft happened, its that people could buy on their own shop. This did not duplicated anything, but when they did that their tools auto repaired. While this makes sense, for people not selling broken stuff, I think I shouldnt let everybody do this. But as I said, I didnt tested this yet to see if you plugin has this issue.
     
  8. Offline

    lucky456

    OK. I got it. But give me time to find out how to read file from niji permission, then I could make that happen. And would you mine give me you host ip, I would like to take look how your host fiction. :)
     
  9. Offline

    anon

    yes sure... right now the classes dont work thou :p It worked on old hmod and i just changed to bukkit 3 days ago. This weekend I will travel, but on monday i will make everything work. I just say the guy from spell plugin made permissions work so, I can already set the diferences between classes.
     
  10. Offline

    bdot

    THANK YOU SO MUCH! I have been waiting for this for so long!

    It does not work on CB295+.

    I tried to update this with better English translation for you, but it failed to compile against Craftbukkit 295.

    Code:
    BBlockListener.java:55: array required, but java.util.List<org.bukkit.World> found
        if (getChestID == this.plugin.getServer().getWorlds()[0].getBlockTypeIdAt(X+1, Y-1, Z)
    
    I believe they changed how getWorld works around CB270 for multiworld support.

    You should also update your namespace.
     
  11. Offline

    lucky456

    I have same issue also. And I try to change the code to.
    Code:
    this.world.getBlockTypeIdAt(X+1, Y-1, Z)
    Then it is no problem with compile. But I don't get what's wrong with the server.
    The error is like this.
    Maybe you can tell me whats the problem here. :(
     
  12. Offline

    bdot

    Your plugin.yml file is missing a space in the first line between "name:" and "ATM"
     
  13. Offline

    lucky456

    Thank you so much. I can't believe I just makes this stupid mistake. [​IMG]
     
  14. Offline

    bdot

    No problem. Let me know when you finish updating if you'd like me to help with the english translation :)
     
  15. Offline

    lucky456

    I just update it after I see your post. And it has no problem now. :)
    I'm working on permissions supporting, I hope I can finish it today. lol
     
  16. Offline

    bdot

    OK but the updated file no longer contains source! Please include, or send to me privately,updated source code and I will help translate.

    If you like I can help translate your original post and instructions as well if people do not understand how to use this.

    Support for Permissions would be perfect! :)

    Also, you must change your package namespace from com.bukkit.whatever to com.whatever.whatever or it will stop working soon!
     
  17. Offline

    pixelbat

    This is pretty cool. Any plans for a version with permissions and iconomy support? :D
     
  18. Offline

    lucky456

    Finally fix the getWorld() error.
    Now it should be functional. [​IMG]
     
  19. Offline

    AntonyDream

    Actually it does 8)
    I don't sure about other counts or goods but it works with this:
    sign lines: "tester | cobblestone | buy sell | 10:1 8:1"
    put 2 cobblestone, 64 gold, 8 cobblestone in the lower chest (cobblestone stacks must be in separate cells! I think it's the reason for all of this), then try to by with 1 gold, you receive 10 cobblestone as expect, but the lower chest still have 2 and 8 cobblestone, 64 and 1 gold!
     
  20. Offline

    bdot

    I'm having trouble understanding what you mean. Could you explain what you did step by step and any messages displayed?
    --- merged: Feb 13, 2011 3:51 AM ---
    @lucky456 Here is the source modified with better english wording if you'd like to use it in your next update.
     

    Attached Files:

  21. Offline

    AntonyDream

    ok, here's step-by-step screens
    tc.jpg
     
  22. Offline

    bdot

    Ahh OK I see now.

    Does that happen if you place the stacks of cobblestone right night to each other? I will try to reproduce this tonight and confirm if its happens to me too.

    Update: Bug confirmed. I think this happens because it only checks each slot in the chest to see if it holds enough of the selected item, not if the chest contains enough of the item in total.

    Proposed quick-fix would be something like:
    Code:
    //temp number of material that we need to remove from chest2
    int temp = (totalGold / Integer.parseInt(buyRate[1])) * Integer.parseInt(buyRate[0]);
    //we check 27 slots in chest2 to find the selling goods
    for(int i=0;i<27;i++)
    {
      //if we find the goods, then we do the subtraction
      if (chest2_save[i].getType()==Material.getMaterial(tradeItem))
      {
        if (temp >= 64 && chest2_save[i].getAmount() == 64)
        {
        chest2_save[i].setAmount(0);
        temp -= 64;
        }
        else if (temp < 64 && chest2_save[i].getAmount() >= temp)
        {
        chest2_save[i].setAmount(chest2_save[i].getAmount()-temp);
        temp = 0;
        }
        //---FIX: If there are slots that have stacks of item that do not meet the amount requested, we send an error
        else if (temp < 64 && chest2_save[i].getAmount() < temp)
        {
        e.getPlayer().sendMessage("Error: Owner must arrange stock items into stacks!");
        break;
        }
      }
      if (temp == 0)
      {
      break;
      }
    }
    
    The "fix" is pseudo-code that may or may not work, but it illustrates the point.
     
  23. Offline

    EvilSeph Retired Staff

  24. Offline

    lucky456

    Oh man. I just get sick again. :(
    I will fix it when I get better....
     
  25. Offline

    enkryptor

    I usually get the following exception:
    Code:
    14.02.2011 23:56:18 org.bukkit.plugin.SimplePluginManager callEvent
    SEVERE: Could not pass event BLOCK_DAMAGED to ATM Trader Chest
    java.lang.NullPointerException
            at com.bukkit.lucky456.tradecraft.BBlockListener.onBlockDamage(BBlockListener.java:117)
            at org.bukkit.plugin.java.JavaPluginLoader$22.execute(JavaPluginLoader.java:231)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:60)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:214)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:359)
            at net.minecraft.server.Packet14BlockDig.a(SourceFile:42)
            at net.minecraft.server.NetworkManager.a(SourceFile:232)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:74)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:104)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:317)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:232)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    How can I help to diagnose the problem?
     
  26. Offline

    bdot

    This shouldn't be happening with the latest version.

    I assume it throws this when you try to hit/break the chest?
    Are you running any other plugins?
     
  27. Offline

    Maluzis

    Good plugin. Add the options that you can only sell or only buy at the store. Currently, as I gave the option:
    "Nickname
    diamond
    sell
    1:16 "
    ... nothing happens.
     
  28. Offline

    bdot

    Not really needed as you can accomplish this by not placing any gold in the initial chest. The chest can't buy/sell what's not inside it. Using a ratio like 0:1 should let players know you aren't buying.
     
  29. Offline

    Maluzis

    Two errors.

    1) You can not buy or sell 'lapis', and other derivatives of the dyes.

    2) On the server, each plate is superimposed protect.
     
  30. Offline

    lucky456

    1)Because those item has different name in coding, which it won't work if we just type the name in game.
    The way to fix it, which I have to write my own String translator to this mod.
    2)I may just make more statement to make sure protection will only work on the shop.

    However, I have to fix the main bug to make sure this mod is basically trading 1 for 1.

    After that, I will going on other stuff, such as permissions support, and more bug fix.
     

Share This Page