[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

    Hooked entity events to check for right/left clicking and running my npcListCommand class.

    Also Version 1.0.7 is out.
     
  3. Offline

    turtlelink2

    I just updated bukkit about 10 seconds ago and now this doesnt work =( although it gives me no errors, npc commands and the exiting npc's dont load
     
  4. Offline

    MatCat

    I haven't had a chance to run it on the newest build yet.
     
  5. Offline

    turtlelink2

    yea the new build is a little odd, gives me crap that the plugins are messy but it still all works except this plugin im going back a version untill its supported because our server is largely based on this mod =)
     
  6. Offline

    MatCat

    Yeah unless worldguard and worldedit 4 force me to I am not updating to the newest until its all stable
     
  7. Offline

    turtlelink2

    well that might be soon because worldguard pops up tons of errors...i didn't actually check if it still works though...
     
  8. Offline

    Darkwizard98

    worldedit 4 beta require's the latest build of bukkit
     
  9. Offline

    Avous

    i have a request. im starting a rp server and i have dungeons that reward diamond/iron from chests. would it be at all possible to have a merchant with inf amount of money to buy the diamond/iron without using a players money? and have a inf stock of goods? again belonging to no one that way npcs could buy the iron/diamond blocks and in other shops sell the goods i list as a infinite quantity

    but ya i dont care if the shop holds the iron or diamond they buy it can be deleted for all i care. i just want a place to trade in currency from the metal bars from chest into cash then buy from city npcs that are owned by no one.
     
  10. Offline

    MatCat

    I am working on adding this feature.
     
  11. Offline

    BeerBaron

    do i need iConomy to get this plugin working?
     
  12. Offline

    sumTard

    yes
     
  13. Offline

    LokeDK

    You can already do this. On my server, we've made a "ServerBank" that trades gold ingots at a fixed price, as a base of our currency. We manually added a iConomy account with a non-player name and funded it with a very large amount (we can always add if needed). Admin created the NPC and transfered banker and ownership to the non-player account. Now we have a bank that always buys gold ingots at a fixed price - and we have disabled iConomy's "money for nothing" scheme.
     
    bandit6789 likes this.
  14. Offline

    Cryoffun

    very promising, only thing is that my server doesnt run mysql, hope to see support for normal version soon
     
  15. Offline

    zajacmp3

    Running #303
    Launched plugin with no errors.
    Modified database manually cause commands did not add items to shop.
    Admin can buy, and normal users with permisson npc.user.* can't
    They have this msg about no permisson or not enough rank?
     
  16. just installed this, using mysql database fine, but get this error when starting server:
    Code:
    NPCTrader version 1.0.7: Found iConomy
    NPC Trader is Using Permissions
    jdbc:mysql://localhost:3306/minecraft
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2334)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at com.MatCat.NPCTrader.NPCTraderMySQL.dbConnect(NPCTraderMySQL.java:1211)
        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:430)
        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)
    Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at java.net.Socket.<init>(Socket.java:375)
        at java.net.Socket.<init>(Socket.java:218)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
        at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
        ... 26 more
    Datbase configuration Error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
    
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    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:430)
        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 1.0.7 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:430)
        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 1.0.7 is enabled!
    Feb 20, 2011 3:28:12 PM org.bukkit.craftbukkit.CraftServer loadPlugins
    SEVERE: com/nijikokun/bukkit/Permissions/Permissions (Is it up to date?)
    java.lang.NoClassDefFoundError: com/nijikokun/bukkit/Permissions/Permissions
        at com.edwardhand.signColours.SignColours.setupPermissions(SignColours.java:35)
        at com.edwardhand.signColours.SignColours.onEnable(SignColours.java:55)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:135)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:430)
        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)
    Caused by: java.lang.ClassNotFoundException: com.nijikokun.bukkit.Permissions.Permissions
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:30)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 12 more
    
     
  17. Offline

    xCode

    Ok got it to work...now when i create npc it doesnt let me /npc setup or anything says i need to be manager or owner to do that even though I am an admin :(
    Console says:
    Checking permissions
    xcode fails for 0
    xcode fails for 0
     
  18. Offline

    rockNme2349

    First of all, thanks for the update! Dyes are now working properly!

    I'm currently doing something similar. I wanted to back my currency in diamond, so I just used the simple shop plugin to buy/sell diamonds with infinite stock. This might interest you.
     
  19. Offline

    Wulfspider

    Any possibility of integrating with the iConomyChestShop plugin so that the NPC can control the chest and allow you to look through it and buy what you'd like? If not that, then how about the ability to have a virtual chest inventory window that pops up when you right or left click on the NPC?
     
  20. Offline

    DOOMTOWNE

    I noticed when right-clicking on an NPC, their Greeting message doesn't come up at first click. I have to click on them a couple times before the message pops up.
     
  21. Offline

    xCode

    NVM got it..had to right click on him first :D
     
  22. Offline

    Aatu

    Nice work :) I love this plugin. I was wondering if y can open chest GUI on right-click? or have y tried that?
     
  23. anyone know why i keep getting this error when i try to run the npctrader plugin? i have mysql running fine (its a webserver) and the minecraft database is there, all info was added to the config.

    I posted my error here:
    http://forums.bukkit.org/threads/econ-npctrader-v1-0-7-b339.4232/page-13#post-69355

    I have no idea what might be causing this, i downloaded the latest files (1.0.7 b339), so i have no idea what i'm doing wrong, someone please help
     
  24. Offline

    MatCat

    Communications link failure happens when the plugin has lost connection to the DB, it sound's like to me like your MySQL is configured with a very low connection count allowance.
     
  25. the config is set to allow 151 at max (didn't change this, it's how it was from install of mysql)
    --- merged: Feb 20, 2011 6:47 PM ---
    i literally have no idea how to fix that if it's some setting in the mysql config, please help :(
     
  26. Offline

    crohakon

    Found a major bug in NPCtrader...

    A setup a shop to sell stacks of, say, logs.
    So, when you buy from slot 1 for the amount 1 you get 64 logs..
    And, when you sell to slot 1 for 1 you sell 64 logs...

    Say the sell price is 10 and the buy price is 8 for 64

    So... I have one log in my inventory (not a stack) and I go and sell to slot 1... I get the 8 even though I only had 1 log, not a stack. But the NPC informs me I sold a stack..

    Well, not I have 8... I sell one more log and I have 16... enough to buy another stack...

    I can continue to do this loop and screw over the person who own the NPC...


    Hope that made sense...
     
  27. Offline

    Avous

    also for the non owned npc traders could you have it auto replenish stock?
     
  28. Offline

    MatCat

    Can you confirm you are running 1.0.7?
     
  29. Offline

    crohakon

    Is there a way in game to check version number?
     
  30. Offline

    Dere011

    I have a problem with the plugin and a multiworlds plugin:


    Code:
        public void onPlayerJoin(PlayerEvent event) {
            if(parent.npc_load == false) {
                parent.LoadNPC();
                parent.npc_load = true;
            }
        }
    Thank you :)
     
  31. Offline

    Springrolls

    The ownership doesn't work. OPs cannot delete the npcs.
     

Share This Page