[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

    SSA

    Yea, crashes the client and doesn't work. But no server crash.
     
  3. Offline

    MatCat

    Ok I finally found the error, it is that items with no item data like wool are being stored with null, needs to be atleast 0, I am going to do a quick update right now.
    --- merged: Feb 18, 2011 10:23 AM ---
    Updated to 1.0.1 to fix item data issue.
     
  4. Offline

    Nykhola

    Now : Database failure trying to add npc.
    V1.0.1
    I'tryin delete DB before, it's the same...
     
  5. Offline

    Bronski

    Any plans to allow custom dialog per NPC? I don't really have a need for shops but I'd love to add some "flavor" NPCs saying funny things :D

    EDIT: I found the npctext table, but I guess I'm wondering if there are commands for the players to do this? I see you're working on some things and maybe an RP addition so maybe that's what I'm asking about. Thanks :D

    EDIT EDIT: It doesn't look like that table is being used yet. I changed all the texts for one NPC and rebooted the server. I guess you know this though hehe.
     
  6. Offline

    inkwriter

    The stocking up on items works again :D! however I found an abuse bug while trying to stock items. If I stock an npc with eggs in slot 1 for example (/npc stock 1 20) and then I buy like THIS (/npc buy 1 -50) it'll actually stock 50 items on the npc (items which I don't even have in my inventory btw) not only that but I get 1 free item when I do it, my money doesn't go down. So this bug could easily be used to stock tons of items on an npc, or get free items from them :eek:
     
  7. Offline

    BeerBaron

    I really like this plugin but i have a problem
    if i try to create a npc i get this message:

    Iconomy and NPCTrade out of sync

    what can i do i have the newest build of both plugins
     
  8. Offline

    Nykhola

    Code:
    com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
            at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
            at com.mysql.jdbc.Util.getInstance(Util.java:382)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
            at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1213)
            at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1200)
            at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4203)
            at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4169)
            at com.MatCat.NPCTrader.NPCTraderMySQL.CreateNPC(NPCTraderMySQL.java:1108)
            at com.MatCat.NPCTrader.Commands.npcCreateCommand.Run(npcCreateCommand.java:71)
            at com.MatCat.NPCTrader.NPCTrader.onCommand(NPCTrader.java:285)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:17)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:77)
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:171)
            at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:628)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:597)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:589)
            at net.minecraft.server.Packet3Chat.a(SourceFile:24)
            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)
    
    I've got this in console after typing /npc create Bob 6 10
    In game : Database failure to trying add NPC
     
  9. Offline

    Orcworm

    Okay, caught the errors this time:

    [​IMG]

    [​IMG]

    Worth noting that the iConomy / Minequery / MyHome errors disappear once NPCTrader is taken off.
     
  10. Offline

    MatCat

    I will fix this shortly. Thank you for bringing it to my attention.
     
  11. Offline

    Nykhola

    I delete tables in DB, plugin....
    Reinstall it. After setup the config file, tables are created in DB, but always the message in game : "Database failure to trying add NPC" if I try to create Bob....
     
  12. With this latest update (1.0.0 and 1.0.1), the permissions plugin will not load into any of my plugins
    I used to have Stargate on there... but its causing some issues ever since i upgraded the NPCTrader.

    Would this be due to a change in the configuration files...i'm not 100% sure... the only thing i changed was the jar file for the plugin...
     
  13. Offline

    MatCat

    If permissions is failing out try shutting down the server and restarting, if it does not work disable npc trader until I update to 1.0.2, there is a db connection issue I think from when I was messing with trying to get SQLite to work, I am too tired right now to check.
     
  14. Offline

    TheYeti

    As the author stated, if your upgrading from an older version of this plugin the MySQL DB connector information changed in the config.yml file. You need to double check and make sure it looks like this:

    Code:
      # DB
    DB:
      # For MySQL
      Driver: "com.mysql.jdbc.Driver"
      Database: "jdbc:mysql://localhost:3306/minecraft"
      User: "user"
      Pass: "pass"
    Not this:

    Code:
    MySQL:
      # For MySQL
      Database: "jdbc:mysql://localhost:3306/minecraft"
      User: "user"
      Pass: "pass"
     
  15. Offline

    supermaxman

    Ok after fixing the yml error i get this:



    2011-02-18 08:16:35 [INFO] [Permissions] version [2.0] (Handler) loaded2011-02-18 08:16:35 [INFO] Loaded Essentials build Dev284 by Zenexer, ementalo, Eris, and EggRollNPCTrader version 0.94: Found iConomy
    java.sql.SQLException: No suitable driver found for at java.sql.DriverManager.getConnection(DriverManager.java:602) at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at com.MatCat.NPCTrader.NPCTraderMySQL.dbConnect(NPCTraderMySQL.java:1101) at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:142)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:410)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:175) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:74)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:55) at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:169)
    at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:156) at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:108)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:207) at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
    Fatal Error on DBConnectjava.sql.SQLException: No suitable driver found for java.lang.NullPointerException at com.MatCat.NPCTrader.NPCTraderMySQL.CheckDB(NPCTraderMySQL.java:221)
    at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:144) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:410) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:175)
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:74) at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:55)
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:169) at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:156)
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:108) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:207)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)Database Configuration ErrorNPCTrader version 0.94 is disabled!
    java.lang.NullPointerException at com.MatCat.NPCTrader.NPCTraderMySQL.SetupNPC(NPCTraderMySQL.java:865) at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:148)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:410)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:175) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:74)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:55) at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:169)
    at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:156) at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:108)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:207) at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)


    It's not connecting properly with the driver, which i have no clue where it is.
     
  16. Offline

    MatCat

    Ok I found a stray db close in the /npc create command, should fix the errors most are getting when trying to do anything.
    --- merged: Feb 18, 2011 2:24 PM ---
    You are still using 0.94, please update to 1.0.2
     
  17. Offline

    supermaxman

    Ok after doing everything, I just scratched my previous yml file and generated new one, ITS WORKING! I say this is not an easy feat, but working this on a Mac is Possible! Dude this is my favorite mod ever, Thank You for all the support man!
     
  18. Offline

    MatCat

    Awesome to hear its working!

    Update 1.0.3 is out! Fixed negatives in buy/sell/stock/unstock
     
  19. Lol... i had tried several restarts... and each time, permissions never passed through (things such as HeroChat wouldn't even function).

    So you think that this version (1.0.3) should fix that issue?
     
  20. Offline

    ssechaud

    Can you update the first post with an example config so people know what they should have?
     
  21. Offline

    MatCat

    ROfl I know what you mean, there is a post somewhere above here that has the proper config.yml
     
  22. Offline

    inkwriter

    Great work yet again! the npcs work wonderfully right now! :D
    I noticed the shop lists seem to count down item slots though, for example
    [3]
    [2]
    [1]
    [4]
    is how it appears in all the npc shops I made :p
    didn't report it until now since it's just a visual bug, but it's a little discomforting <3

    ...also I know I'm lame for asking but how do I setup infinite stock of an item?
     
  23. Offline

    MatCat

    That is wierd.... I will fix it next release, also there is no infinite stock yet, what you could do is connect to your DB directly and just give it a really large stock :)

    Also please update to 1.0.5 ;)
     
  24. Offline

    inkwriter

    Alright thanks a ton :D
     
  25. what exactly are the different commands given to 'owner' , or 'manager', or 'user'?

    Specifically? I want to make sure that users can stock product, and setup slots... but not do much else.... so i'm just wondering what exactly the permission/command correlation is.


    Also, does anyone know if the bug where you buy a negative amount increases their stock got fixed? I dont really wanna re-implement this plugin, unless that is fixed :S
     
  26. Offline

    inkwriter

    the stock bug is fixed
     
  27. Offline

    MatCat

    I fixed buy/sell/stock/unstock to convert any negative to an absolute... As far as the full permissions set:
    npc.user.:buy, sell, list
    npc.manager.: stock, unstock, setup, adjust, move, message
    npc.owner.: remove, addowner, addmanager, removeowner, removemanager, banker
    npc.create: create
    npc.admin: can do any command on any npc
    npc.admin.list: can use /npc list npcs
    --- merged: Feb 19, 2011 12:06 AM ---
    I'm pretty sure we are at a stable bug free build, someone let me know if they discover otherwise ;)
     
  28. Offline

    jinrey

    I have a question, must I create a mysql database for this plugin? Because when I trying create a new npc i have error:[​IMG]
     
  29. small issue... when you right click the npc, it says %p... not the players name... not sure why.
    Also, do you think it would be possible to somehow make it easier to get to the second page of the list with the right click? :p
     
  30. Offline

    MatCat

    Yes you HAVE to have a working MySQL DB, this plugin requires it.
     
  31. Offline

    jinrey

    :( jesus! I will never make this :( this is to hard for me :( Can you send me simple mysql? because i havent idea how this make, i dont understand many english words and I dont know what is wrote in instrunction with making mysql
     

Share This Page