[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

    MatCat

    I am not open sourcing it, sorry.

    I used the NPC Library available in the plugin development section as the base for actually making NPCs work on the server, it includes a very basic example that will compile to be a dummy NPC essentially.

    I do however plan on making a seperate NPC plugin that is not focused on being a store but focused on utility and RP, so look forward to that.
     
  3. Offline

    ToitagL

    Love this plugin, working perfectly. Waited for this for soooo long...

    Anyway, could it be possible to add Permissions support ? I mean, on my server, i don't want that all players were allowed to create NPCs (Only staff / VIP / Shop keepers). Did you plan anything like that ?

    Thanks again, fantastic plugin...
     
  4. Offline

    RustyDagger

    i really need sql lite or a really simple mysql guide to follow im all for learning new things but need it explained well.

    Other than that it seems nice and would like to use it could be the last thing i really need oh and permissions support is kinda major cant have them noobs in noob land making shops when they have no money in the first place.
     
  5. Offline

    MatCat

    It wont let you create one if you don't have enough money :p. However I am working right now on permissions support and looking into sqllite. For mysql it depends if you are on windows or linux, windows is real easy setup, you download it and install it, and it will be fairly painless. Linux is a bit tougher.
     
  6. Offline

    crohakon

    sqllite support would be great. MySQL is not a problem, just a hassle.
     
  7. Offline

    Nate204

    Is MySQL that demanding? How much RAM are your servers running? Are they dedicated? I stopped using SQLite once I say it mad big brother worthless. I guess I never thought MySQL would be a RAM hog.
    --- merged: Feb 14, 2011 3:13 AM ---
    Also,

    When I buy and sell to a NPC, it doesn't seem to effect my iConomy. My balance going in will be 56, then I'll buy and it wont change. The same goes for selling. Any suggestions? I think it charged me for setting up the NPC though.

    The NPC will say "received one credit."
    Do I have a setting turned off that I don't know about?

    Thanks!
     
  8. Offline

    Nachocuban

    Would it be possible to have an admin be able to set up a 'stockless' npc? one that doesn't have anything to do with any players, and can say sell Iron swords, forever? It would probably have to wait for a permissions system I would imagine.
     
  9. Offline

    sumTard

    Yeah an npc with infinite stocks for items which can also buy back infinite amounts from a player would be great, that way admins can set up shops in towns that buy/sell items... basically a physical item shop :D

    A configurable limit on how many npcs a group can create would also be nice.

    Thanks!
     
  10. Offline

    Daveyo

    Code:
    NPCTrader version 0.91: Found iConomy
     Fatal Error on DBConnectjava.sql.SQLException: invalid database address: jdbc:mysql://localhost:3306/minecraft
     java.lang.NullPointerException
         at com.MatCat.NPCTrader.NPCTraderMySQL.CheckDB(NPCTraderMySQL.java:119)
         at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:127)
         at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135)
         at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:425)
         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:171)
         at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
         at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
         at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
         at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
     Database Configuration Error
     NPCTrader version 0.91 is disabled!
     Fatal Error on DBConnectjava.sql.SQLException: invalid database address: jdbc:mysql://localhost:3306/minecraft
     java.lang.NullPointerException
         at com.MatCat.NPCTrader.NPCTraderMySQL.SetupNPC(NPCTraderMySQL.java:739)
         at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:131)
         at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135)
         at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:425)
         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:171)
         at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:158)
         at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:110)
         at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:209)
         at net.minecraft.server.ThreadServerApplication.run(SourceFile:512)
     NPCTrader version 0.91 is enabled!
    
    cb 323, going to update sqlite if that's a possible issue
     
  11. Offline

    sumTard

    ...really? have you read the post? it doesnt run on sqlite
     
  12. Offline

    Daveyo

    i have both, is this working with other builds 323+?
     
  13. Offline

    Jarchuleta

    Love this thing. But i found a problem using Bukkit 297. You can sell stuff even if its not in your inv.
     
  14. Offline

    QQCucumber

    MySQL on my VPS box took up a little less than 150 MB on CentOS, which is a lot of memory for a VPS, you only get so much to work with. It's memory that needs to go toward being able to host more players, not use a couple plugins.

    But MatCat said he was looking into implementing it, so that's good enough for me.
     
  15. Offline

    MatCat

    Are you buying/selling from your own NPC? Because it will take the money from you the buyer, and give it to you the NPC owner (banker), so you would never see a money difference.

    I will put this on my todo list

    I will consider this.

    @ Daveyo, that error is because you never configured it for MySQL, at the moment there is no SQLite support.

    Speaking of SQLite, I am currently messing around to see how easy it will be to do it, and honestly it doesn't look promising. I use some fairly advanced sql queries that sqlite does not support at all.
     
  16. Offline

    QQCucumber

    :( Looks like those of us that can't afford using MySQL are going to have to wait for Jimpi's release.
     
  17. Offline

    blaize9

    I seccond the stackless NPC, also i it would be nice to have like bankers for other people to use so i you deposit it you cant only see it.
    Ive had this idea for this plugin FORVER thanks
     
  18. Offline

    ledhead900

    Im keen for this bigtime but Im just going to hang a round a bit longer and wait for a slightly improved version, I can tell you cut some things out to get it released faster.

    I appreciate it trust me I do I'm still going to wait a bit longer tho.
     
  19. Offline

    blaize9

    ya just relese some stuff now and when you can get to the other stuff.
     
  20. Offline

    MatCat

    Yeah I originally intended to have permissions support but I wanted to get it out. I am working on SQLite right now then I will work on permissions support.
     
  21. Offline

    Brack

    Hey MatCat, thanks for the work you've put in on this. I just made my first npc and this appears to have much potential. I assume if I run around and set a number of npc positions, I can just edit the tables in mysql to update their inventories? This will make setup much quicker. And I'd just like to add that I, for one, am glad you're supporting mysql.

    For those that are having issues with mysql eating their RAM, make sure you have it configured correctly. Article is a little old, but many of the points still apply: http://www.mysqlperformanceblog.com/2006/05/17/mysql-server-memory-usage/

    This would be a great feature.

    An idea I had would be if you could set a few positions per npc, and the npc would then wander between them. This would be nice to have a shopkeeper walk around the shop. This would probably take some work so I'm willing to wait. [​IMG] (if even possible)
     
  22. Offline

    nachotp

    this is the problem i get, im not very related in SQL so maybe is that :/
     

    Attached Files:

  23. Offline

    Daveyo

    i see on step 3 to edit the config file to work with MySQL. How does one go about configuring said file?
     
  24. Offline

    nachotp

    the instructions are a little bit weird
     
  25. Offline

    Brack

    All you need to do is change the username to whatever user has access to the database, and the password to their password. Assuming you have mysql installed at localhost (default) you'll be fine.
     
  26. Offline

    nachotp

    ahh, do i really need mysql because the other plugins dont get any problem without having it
     
  27. Offline

    Daveyo

    would you mind posting a link if there is one? Everyone here just knows how to do it?

    I dont know, i guess just wait till this gets support for sqlite lol. I have 12 gigs of ram, what does everyone whine about this taking 100 megs?
    --- merged: Feb 14, 2011 5:37 AM ---
    wow mysql.com has told me all i need to know. You must wait for sqlite
     
  28. Offline

    QQCucumber

    Because not everyone runs their minecraft server on their home computer? The big limiting factor on doing that is the fact most ISPs give you horrible upload rates.
     
  29. Offline

    Sparky222B

    This plugin looks really interesting and promising. However, like others have said, I am not willing to set up MySQL for a single plugin - so it's worthless to me until SQLite is added.
     
  30. SynapseSMP.com is using this plugin currently and it's very useful. I don't know why everyone is needing SQLite so much, from my experience it's much less common a web db than MySQL.

    MatCat, please check your messages soon, [​IMG]
     
  31. Offline

    QQCucumber

    As was stated before, it has a large memory consumption when Minecraft servers use up a lot of memory already, and it's difficult for Linux servers to set up.
     

Share This Page