[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

    Yeah if you get db errors trying to start up it crashes permissions I think, which would cause permissions to not load, I need to fix that but it's an issue of your configuration.
     
  3. Offline

    supermaxman

    Ok Im Not an idiot, i have it running, it's working fine, but this won't connect with it. I have it running, but the database wont work...
     
  4. Offline

    Meteo

    Mat can u give me a detailed version on how to correctly install this plugin? i have no idea about the mysql..
     
  5. Offline

    Nykhola

    Mat, i follow your instructions in the first post
     
  6. Offline

    MatCat

    IF your on linux and mac installing MySQL is a bit complicated... but on windows you just go to mysql's website and download the windows version, install it, then follow the link in the original post on how to create a database in your mysql, then you change /minecraft in the database: field of your config to whatever you named your database, or if you name it minecraft you don't have to, then change user: and pass: to whatever you setup.
    --- merged: Feb 18, 2011 2:51 AM ---
    Sorry but I do not have time to try to help everyone install MySQL, it is outside of the scope of this post. If you need help installing MySQL then please check out the link to a tutorial I have put under the Installation help of my original post. Please limit your questions to problems specific to the plugin. If you just plop the .jar file in your plugins/ folder and do not properly configure your config.yml then this plugin is just not going to work plain and simple as it REQUIRES MySQL.
     
  7. Offline

    supermaxman

    So in the end, you have a folder called minecraft with one file called an ope or something? Because I did the equivalent of what you said above, and it gives that error, so if you could possibly explain what the database has within it, and if you could possibly send me a video/forum link of someone who has done it on a Mac because i really want this mod, and there Is little support here for a unix system.
     
  8. Offline

    MatCat

    As a sice note I am working hard at getting SQLite to work as an option! But it may take a few days.
    --- merged: Feb 18, 2011 2:54 AM ---
    I googled "Installing MySQL mac tutorial" and the very first link explains how to setup MySQL on a mac.
    This is the last post I will reply to that concerns how to configure or setup MySQL.
     
  9. Offline

    supermaxman

    I've said this like 3 times now, I have it set up, but the minecraft database is killing it somehow.
     
  10. Offline

    Plyz

    2011-02-18 04:02:38 [WARNING] Failed to handle packet: java.lang.NullPointerException
    java.lang.NullPointerException
    at com.MatCat.NPCTrader.NPCTrader.PlayerItemCount(NPCTrader.java:444)
    at com.MatCat.NPCTrader.Commands.npcSellCommand.Run(npcSellCommand.java:59)
    at com.MatCat.NPCTrader.NPCTrader.onCommand(NPCTrader.java:338)
    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:610)
    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)
     
  11. Offline

    SSA

    Its on /npc stock, I don't know the version number other than that. How do I check it?
     
  12. Offline

    MatCat

    In game do /version, this will tell you your bukkit build, and just for the heck of it do /version NPCTrader
    --- merged: Feb 18, 2011 3:42 AM ---
    I have tried many various combinations to try to recreate your issue SSA but I cannot get any error to happen. I tried doing buy/sell stock/unstock commands on unsetup slots, I setup slots and tried them all, I cannot recreate your error, everything works just as it should on my end.
     
  13. Offline

    Nykhola

    We are already 3 guys with the same error...

    Maybe conflict with another plugin ?

    With previous version of this plugin, i've not any problem.
     
  14. Offline

    SSA

    It still says Craftbukkit version git-Bukkit-0.0.0-409-gcb2bced (MC: 1.2_01)

    NPC Trader 1.0.0

    Ill go get the most recent CB and try again

    Tried on 339 still doesnt work.
     
  15. Offline

    MatCat

    I need you guys to tell me exactly what you are typing, I.E. from the moment you put 1.0.0 on, what series of commands did you type to get this error? I don't see how it could be a conflict with any other plugins.
     
  16. Offline

    Nykhola

    Mat, I follow exacty your explanation at the first post. I notice a new column in db "itemdata" but after creating npc, it value is null.
     
  17. Offline

    omgmac

    i get a database failure trying to add npc.
    Please help
     
  18. Offline

    turtlelink2

    after updateing to 1.0.0 i get this error
    Code:
    java.sql.SQLException: No suitable driver found for
            at java.sql.DriverManager.getConnection(Unknown Source)
            at java.sql.DriverManager.getConnection(Unknown Source)
            at com.MatCat.NPCTrader.NPCTraderMySQL.dbConnect(NPCTraderMySQL.java:120
    8)
            at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:181)
            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(SimplePluginManage
    r.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)
    Datbase configuration Error: java.sql.SQLException: No suitable driver found for
    
    java.lang.NullPointerException
            at com.MatCat.NPCTrader.NPCTraderMySQL.CheckDB(NPCTraderMySQL.java:226)
            at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:183)
            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(SimplePluginManage
    r.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 1.0.0 is disabled!
    java.lang.NullPointerException
            at com.MatCat.NPCTrader.NPCTraderMySQL.SetupNPC(NPCTraderMySQL.java:968)
    
            at com.MatCat.NPCTrader.NPCTrader.onEnable(NPCTrader.java:187)
            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(SimplePluginManage
    r.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 1.0.0 is enabled!
     
  19. Offline

    MatCat

    Yeah that is one message not on the editable messages list, I will work on that for next release.
    --- merged: Feb 18, 2011 4:40 AM ---
    Turtlelink2, that means your Database: field in the config is not properly configured.
     
  20. Offline

    turtlelink2

    but it worked before i updated it so i dont understand..
    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: 25
      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: ""
      Suffix: ""
    
    # MySQL Settings
    MySQL:
      Database: "jdbc:mysql://localhost/minecraft"
      User: "root"
      Pass: ""
    useing wampserver
     
  21. Offline

    MatCat

    What did you type to setup the slot? you would have had to do /npc setup ???? What did you type
    --- merged: Feb 18, 2011 4:43 AM ---
    Turtlelink2, copy and paste a copy of your config.yml
     
  22. Offline

    turtlelink2

    Oh i also enabled plugins
     
  23. sadly, i updated this plugin, and it decided to throw a wrench in with permissions.... not only did it not keep any NPC's, but it caused nearly everything else that deals with the permissions plugin to not be able to load
     
  24. Offline

    silentdojo

    Same thing happened for me...
     
  25. Offline

    turtlelink2

    ok i figured it out, deleting the config and creating a new one showed this
    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: ""
      Suffix: ""
    
      # DB
    DB:
      # For MySQL
      Driver: "com.mysql.jdbc.Driver"
      Database: "jdbc:mysql://localhost:3306/minecraft"
      User: "root"
      Pass: ""
    looks like you have to add that database feild now
     
  26. Offline

    inkwriter

    I'm getting the same error as nykhola, when I type "/npc stock 1 64" the client crashes
     
  27. Offline

    jdrez

    Yep this is the error that is logged before crashing:

    [WARNING] Failed to handle packet: java.lang.NullPointerException
    java.lang.NullPointerException
    at com.MatCat.NPCTrader.NPCTrader.PlayerItemCount(NPCTrader.java:444)
    at com.MatCat.NPCTrader.Commands.npcStockCommand.Run(npcStockCommand.java:41)
    at com.MatCat.NPCTrader.NPCTrader.onCommand(NPCTrader.java:329)
    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)
     
  28. Offline

    turtlelink2

    another error....trying to stock the store with a infinite (-1) block gets me kicked

    EDIT: I lied, stocking altoghther crashes me =/ same error otheres are getting
     
  29. Offline

    MatCat

    Everyone check your config.yml, if it says Mysql: change it to DB:
    --- merged: Feb 18, 2011 6:06 AM ---
    The default config.yml should be like the one below, if you have MySQL: then change it to DB:

    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"
    --- merged: Feb 18, 2011 6:08 AM ---
    I still cannot figure out those of you who stock buy and sell are giving errors, I cannot re-produce this and no one has told me even though I asked 3 times what you typed. I need to know what you did for the initial /npc setup on the slot that you are trying to stock/buy/sell.
     
  30. Offline

    SSA

    Here is exactly what I did. I can repeat this everytime.

    /npc create John 4 10
    right click on john
    /npc setup 1 1 1 10 4 true true
    /npc stock 1 1
    *server crash*
     
  31. Offline

    inkwriter

    actually it only crashes the client, the server doesn't go down.
     

Share This Page