[ECON] NPCTrader v1.1.4 - The Full featured localized shop system [RB740 - 766]

Discussion in 'Inactive/Unsupported Plugins' started by MatCat, Feb 13, 2011.

  1. Offline

    MatCat

    NPC Trader - The Full featured localized shop system

    Version 1.1.4 (Testing Version!)



    The first localized full featured shop system for Bukkit/iConomy, in NPC Form!

    What's better for a localized shop system then your very own NPC Clerk / Teller / Worker / Slave / Whatever word you want to call your NPC!

    Features
    • Localized system
    • Fully player controlled (No admin intervention needed)
    • Full Item and Metadata support (Colored wools, etc)
    • Item name or ID recognition
    • Partial name recognition (If online)
    • Complete internal permissions system for managers of the NPC
    • iConomy Based
    • MySQL data storage
    • Item stocking system
    • In-Game help for everything
    • Supports Permissions and GroupManager (Using FakePermissions) Plugins!
    Installation / Setup

    1. Put NPCTrader.jar in your plugins folder
    2. Put mysql-connector-java-bin.jar in your main minecraft folder
    3. Restart your server (Auto-generates config.yml in plugins/NPCTrader/)
    4. Edit the config.yml for MySQL and other config settings.
    5. Restart once more
    6. Enjoy!
    If for some reason the folder / config does not auto-generate, then you can open the .jar file with 7zip or winzip or other archiving utility that supports jars and extract the config.yml from the jar.


    NOTE: If you do not have or do not know if you have MySQL setup then you either have to setup MySQL or not use this plugin for now. Please do not post questions asking how to install MySQL as that is outside of the scope of this post. You can follow this tutorial (Thanks @Germata!) for detailed windows installation and setup, but I cannot provide support for installing and setting up MySQL, only support for my plugin specifically.

    Permissions

    Permissions will only be used if it is installed. The following is the permissions list:

    Code:
    npc.admin      - Give to admins for full access to all NPCs
    npc.admin.list - Access to /npc list npcs
    npc.user.*     - General user commands, you can specify by replacing * with command name, I.E. buy
    npc.manager.*  - NPC Manager commands
    npc.owner.*    - NPC Owner commands
    npc.create     - Ability to create an NPC 
    If permissions is used you may also specify limits on how many NPCs a specific player or group may have ownership flag on, please see config file for more information.

    Usage

    Once the plugin is installed and running, you can see the in-game help by typing /npc in your chat window. To interact with an NPC just right click on it first.

    Here is a simple tutorial for setting up an NPC named Bob that sell's bread, cooked fish, and cooked pork, and buys wheat, raw fish, and raw pork.

    1. Stand exactly where you want your NPC, including head position and body rotation.
    2. Type: /npc create Bob 6 10 This will create the NPC with 6 Item Slots, each holding 10 units.
    3. Right click on the newly created NPC
    4. Type: /npc setup 1 bread 1 2 0 true false This will setup Slot 1 with Bread, selling lots of 1 at 2 Coins, buying them from players at 0, True for NPC Selling it, False for buying from players.
    5. Repeat step 4 for Cooked fish and Pork
    6. Type: /npc setup 4 wheat 64 0 10 false true This will setup Slot 4 with Wheat, buying lots of 64 at 10 Coins. This one is set False to selling it to players, but true to buy from players.
    7. Type: /npc stock 1 20 This will stock the NPC with 20 breads on slot 1 (Assuming you have enough bread).
    8. Repeat step 7 for raw fish and pork.
    You know have a fully setup and functioning NPC.


    Known Issues / Bugs

    • Config folder does not get generated on Linux - Works on Windows
    • Cookies and beds, and pretty much any other 1.4/1.5 items.
    • Spams console when you stand close to an NPC
    • Gives error when an NPC is spawned (Can be ignored)
    • Head / Rotation is not being properly set on spawn / move. (Fixed in 1.14)
    • Does not work with actual permissions (works with GroupManager)
    • Rename command is broken
    Things Todo

    • Re-write item handling
    • Support for both GroupManager and Permissions
    • iConomy 5 Support
    • Add armor capacity
    • Tie into WorldGuard for checking for build rights (Will be optional)
    Misc


    If you installed MySQL for Windows just to run this plugin then check out this link to see how to create the initial minecraft database you will need.


    *** NOTE: SQLite IS NEVER GONNA HAPPEN! If you want to see an alternative, fork the src, make it work as an option, and I will include it in.***

    Changelog
    • Version 1.1.4
      • Changed out item name / id handling system
      • Now supports all current official items
      • Fixed Move Bug
      • Fixed NPC Creation Errors
      • Fixed a few other errors
      • Fixed Config creation on linux (hopefully!)
    • Version 1.1.3
      • Completely rewrote most of the code that directly interfaces with the NPC Library.
      • Now uses chunk loading/unloading to make sure only NPC's in loaded chunks are loaded (Way more efficient)
      • Changed banker command to only allow setting yourself as banker (to stop an exploit situation).
    • Version 1.1.2
      • Fixed upgrading stack counts for free bug
      • Fixed rename command not working on linux
      • Made it so an NPC must have 1 item slot to be created
      • Added permissions support for owned npc limits (By group or player)
    • Version 1.1.1
      • Fixed issues with quantities of '0'
      • Added rename command
      • Fixed iConomy hooking on startup
    • Version 1.1.0
      • Fixed Admin Override Permissions not working
      • Added Half and Double Slabs
      • Updated to work with B612+
    • Version 1.0.9
      • Updated to work on B531+
      • Updated to work with iConomy 4.*
      • Much needed overhaul of error handling and disabling procedures.
      • Converted integer based money to decimal based.
    • Version 1.0.8
      • Updated for newer builds
    • Version 1.0.7
      • Fixed more issues with ItemData, hopefully they are fixed for good.
      • Added log names
      • Added Coal/Charcoal distinction
      • Order of slots listed will always be in ascending order
    • Version 1.0.6
      • More meta-data issues, resolved.
    • Version 1.0.5
      • My restructuring of the code to try to support SQlite completely foobared the connect and close code, causing timeouts and errors. Fixed it.
    • Version 1.0.3
      • Fixed buy/sell/stock/unstock to use absolute values so that negatives cannot happen.
    • Version 1.0.2
      • Fixed bug where db connection was closed on /npc create
    • Version 1.0.1
      • Fixed bug with null Item Datas
    • Version 1.0.0
      • Fixed many many bugs
      • Added /npc list npcs as an admin command to let you see a full list of NPCs
      • Added recording transactions.
      • Added full permissions support
      • Better error handling and message delivery.
    • Version 0.94
      • Fixed not checking stock when doing /npc setup
      • Made the setup's error messages way more intuitive
    • Version 0.93
      • Fixed disappearing NPC bug.
    • Version 0.92
      • Fixed bug where selling was not checking player inventory.
    • Version 0.91
      • Fixed bug where giving improper arguments for upgrading and creating reported iConomy and NPC Trader out of sync.
    • Version 0.9
      • Initial Release
    You can download the jar here.



    You can download the mysql connector jar here.
     
  2. Offline

    Kegan187

    Would it work with a lower version of iConomy? like 4.0 or something?
     
  3. Offline

    MatCat

    It work's with the newest 4.4 build of iConomy, there are still some random errors but everything still works, it's running stable on my server, though I am trying to figure it out.
     
  4. Offline

    David McCahon

    Yea same prob works on 556 but iconomy error 4.5
     
  5. Offline

    Kegan187

    ty
     
  6. Offline

    David McCahon

    EDIT: Fixed, but still problems with iconomy 4.5
    -------
    11:46:21 [INFO] Starting minecraft server version Beta 1.3
    11:46:21 [INFO] Loading properties
    11:46:21 [INFO] Starting Minecraft server on *:25565
    11:46:21 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-516-
    gdf87bb3-b531jnks (MC: 1.3)
    11:46:21 [INFO] Preparing level "world"
    11:46:21 [INFO] Preparing start region
    11:46:23 [INFO] [iConomy] Logging is currently disabled.
    11:46:23 [INFO] [iConomy] v4.4 (Arcadia) loaded.
    11:46:23 [INFO] [iConomy] Developed by: [Nijikokun, Coelho]
    11:46:23 [SEVERE] java.io.IOException: The system cannot find the path specified
    11:46:23 [SEVERE] at java.io.WinNTFileSystem.createFileExclusively(Native
    Method)
    11:46:23 [SEVERE] at java.io.File.createNewFile(Unknown Source)
    11:46:23 [SEVERE] at com.MatCat.NPCTrader.Resources.writeResource(Resource
    s.java:10)
    11:46:23 [SEVERE] at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.jav
    a:158)
    11:46:23 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlug
    in.java:118)
    11:46:23 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(
    JavaPluginLoader.java:451)
    11:46:23 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(Si
    mplePluginManager.java:217)
    11:46:23 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftSe
    rver.java:83)
    11:46:23 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftS
    erver.java:61)
    11:46:23 [SEVERE] at net.minecraft.server.MinecraftServer.e(MinecraftServe
    r.java:204)
    11:46:23 [SEVERE] at net.minecraft.server.MinecraftServer.a(MinecraftServe
    r.java:191)
    11:46:23 [SEVERE] at net.minecraft.server.MinecraftServer.d(MinecraftServe
    r.java:131)
    11:46:23 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftSer
    ver.java:246)
    11:46:23 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(Sour
    ceFile:366)
    11:46:23 [INFO] Database configuration Error!
    Verify your config.yml settings are correct and valid for your MySQL setup.
    Returned Error: java.lang.NullPointerException
    11:46:23 [INFO] NPCTrader version 1.0.9 is disabled!
    11:46:23 [INFO] Done (0.135s)! For help, type "help" or "?"
    >

    ... I could configure my .yml file if it would even create one lol

    Alright for anyone with troubles with iconomy 4.5 the error is most likely coming from your database configuration, i currently have npc trader working perfectly with iconomy 4.5 and craftbukkit build 556, I would like to thank MatCat for this amazing plugin, GREAT WORK!!!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  7. Offline

    MatCat

    Yeah for some reason its not doing config file properly... I need to fix it, you can open the .jar file with winrar or 7zip or any other program that supports it, and grab the config.yml out.

    In the mean time David, I am curious because I had troubles with it myself working on 4.5.

    I can confirm that as long as iConomy 4.5 is setup and running properly, and NPCTrader is configured properly, everything will run stable on 556. Though I will be doing a 556 dependent build today with some fixes.

    I really do appreciate any feedback anyone can give, I want to fine tune this plugin to be efficient and reliable.

    Technically it is now possible to setup an NPC that uses a non player bank account thanks to iConomies setup in 4.x. However for the moment you would have to change the banker field in the database directly to make this happen. I will be adding a way to handle this in game for those that want NPC's not attached to a players account.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  8. Advise you how to edit the message when going to the NPC
    "Can I interest you in anythig"
    In the database, this item is not.

    Thank
     
  9. Offline

    Rilly

    Hi - how do I set myself as an owner? I'm in the admins group, and the ops.txt file, but I can't seem to set myself as an owner of a new NPC (that I created). I wanted to actually remove it so I can fix the direction its facing (body all twisted!!).
    Whenever i try (where npcname is my NPC)

    /npc remove npcname it says I must be owner OR
    /npc addowner Rilly npcname it says I must be owner

    using 556 / 1.09
     
  10. Offline

    MatCat

    Right click on the NPC first (If you created it you are the owner), then just type /npc remove, no need to type the name. Same for addowner, as a matter of fact the only command that let's you specify the npc's name is the create one, other then that you right click on an NPC to interact with it and issue commands.

    I plan on doing a good detailed YouTube tutorial on them soon.
     
  11. Offline

    Rilly

    thanks - that worked..

    Now.. HOW do i get him to stand straight! lol I press f5 and I can see my character is perfectly straight.. i type /npc create npcname, and the NPC appears with his body facing sideways!.. I've tried 5 times now

    Woodzy - Did you keep the full jdbc:// URL and replace the word minecraft with your db name? (as this is required for it to work)

    i.e.: Database: "jdbc:mysql://localhost:3306/npctrader"

    I had tried just putting npctrader in there like I see on other dbconnect files, but it didn't work

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  12. Offline

    woodzy

    not working it broke XD,
    i had to make the folder and place the config in it, i get a data base config error it it possable that it is conflicting with a diffrent plugin? i have 5 outher plugins that use MYSQL so i know how to set it up
     
  13. Offline

    MatCat

    My server runs with about 15 plugins that use MySQL and I have no issues, so I do no think it is a conflict. I think it is a configuration error.

    The config file should be as follows, please note the DB section does require the full jdbc connection string which contains the host, port, and database name in the format of:

    jdbc:mysql://<MySQL HOST ADDR>:<MySQL PORT>/<DATABASE NAME>

    So let's say for example your website is hosted on a shared hosting account which also hosts your MySQL, and it's IP address is 174.111.111.42, and using the default port of 3306, with a database name of my_mcdb, the proper string to use would be:

    jdbc:mysql://174.111.111.42:3306/my_mcdb

    Hope this clarifies database configuration settings!

    Code:
    # NPC Trader Configuration File
    
    # Price settings.  ItemSlot is the cost per item slot, Units are how much each unit per slot costs.   The formula
    # is ((Units * Units Cost) * ItemSlots) + (ItemSlots * ItemSlot Cost) I.E., An NPC with 5 ItemSlots and 5 Units would
    # be: ((5 * 5)[25] * 5)[125] + (5 * 100)[500] = 625
    # RefundPercentage is how many money to refund the owner either when removing or downgrading the npc.  50% will give half
    # of their money back.
    Prices:
      ItemSlot: 100
      Unit: 5
      RefundPercentage: 50
    
    # UnitStack is how big a stack size per unit.  an NPC with 5 Units and a UnitStack of 64 will hold 320 (5*64) items per slot.
    UnitStack: 64
    
    # Name prefix to put before NPC Names and Suffix to put after NPC Names.
    NPC:
      Prefix: "[NPC]"
      Suffix: ""
    
      # DB
    DB:
      # For MySQL
      Driver: "com.mysql.jdbc.Driver"
      Database: "jdbc:mysql://localhost:3306/minecraft"
      User: "user"
      Pass: "pass"
    Also to append for those that are much more technically savvy, it is setup so that you could theoretically use any database type as long as you have the proper connector jar in your class path, however the db would have to support mysql style sql queries.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 8, 2016
  14. Offline

    woodzy

    wondering if the mysql for ubunto10 X64 would make a diffrence i did like u said and its ok there so ikd, well everyone lose there npc's if i reboot the server if the mysql isnt workign right?
     
  15. Offline

    MatCat

    It is possible if the MySQL is only storing it in memory and not saving it, that is an odd one.
     
  16. Offline

    Rilly

    MatCat - whats the trick to getting the body orientation straight? I have my characters body straight (confirmed by f5), but the NPC created isn't matching.
     
  17. Offline

    MatCat

    Yeah it's a bug, I need to figure it out.
     
  18. Offline

    Rilly

    ok cool.. at least i know its a bug heh.. i can continue just making them then anyway :)


    edit: I guess a bed isn't a sellable item? It's not in the list (and says unrecognized)
     
  19. Offline

    MatCat

    I need to add the b1.3 blocks... I will try to get that out tomorrow
     
  20. Offline

    Amin Azman

    the config file doesn created automaticly. need to generate manually?
     
  21. Offline

    Rilly

    Open the NPCTrader.jar file with winrar and extract the config.yml. Then make a folder in you plugins folder named NPCTrader and put the file in that. Then edit the config
     
  22. Please help.

    How to edit message on the approach to NPC? "Can I interest youin anythig"
    One can also set the radius to see this report?

    Thank you for your help

    MatCat thank you for the great plugin.
     
  23. Offline

    MatCat

    That message isn't configurable yet... I will put that out in the next release
     
  24. Thank you.

    Will be able to set the radius in which the message is activated?
     
  25. Offline

    MatCat

    I will see about it... Most certainly will be able to be turned off too, as it does spam sometimes.
    Tonight I am also going to try to put armor support too.
     
  26. Offline

    Nafds

    I am currently using a data base online.
    Is there a way to configure the plugin to connect in a way like

    Port: "3306"
    Database: ""
    User: ""
    Pass: ""
     
  27. Offline

    MatCat

    The format of the config is so that the connector could be changed simply by adjusting the config, and covers already port, db, user, and pass.
     
  28. Offline

    woodzy

    hello plugin maker can u please update this plugin to work with CD#556?
    i installed it and and dubble rebooted server and add permisson nodes and i type the command to make an NPC and nothing, yes it is running and i have mysql set up
     
  29. Offline

    MatCat

    IT works fine on 556, as a matter of fact on my own server I am running it on cb556 :)
     
  30. Offline

    swedish2011

    do you think you can fix it?

    you're a bug.

    http://forums.bukkit.org/threads/ad...on-plugin-mysql-custom-tables-colum-440.1605/

    1. Bug confirmed: Incompatibilty with plugins, that create NPCs like Citizens. This is because these plugins emulate a player, and AuthMe can't check, if this player is a human or a computer. So if a NPC tries to move, a lot of errors will get spammed in console. The error messages are not serious and will not put the functionality of AuthMe at risk. The only problem is, that the NPC can't move, because he is not allowed to do so.
    This issue will be fixed in Citizens 1.07.
    2. Bug confirmed: AuthMe can NOT be reloaded! On reload the internal player cache gets removed and some errors will show up on console!

    ;(
     
  31. Offline

    woodzy

    in not getting any errors it seems to be loading just fine but noone of the commads are working.\
    any ideas?
     

Share This Page