[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

    darkshino

    do u have the lastest build of iconomy
     
  3. Did you type "http://.." in your mysql configuration ? That'll be wrong since mysql doesn't connect through http.
    That web page is your mysql ADMIN page, not the actual database.
     
  4. Offline

    DaddyCool64

    No, the errors come from NPC Trader. Many other plugins works very well with iConomy 5.
    Look at that link to use some economy systems:
    http://forums.bukkit.org/threads/register-now-accepting-all-payment-methods-economy-api.16849/

    In the OP is that:
    • Supports Permissions and GroupManager (Using FakePermissions) Plugins!
    but it don't work with Permissions, not with older versions, not yet.

    So the errors are in NPC Trader, not in the other plugins.
    Many Users, like me, are waiting for a working version of NPC Trader, because we love the idea for this plugin.

    sorry for my bad english
     
  5. Offline

    tombik

    I have tryed everything - with httpp without, with mysql: without...idk.
    No, i haven't, should i?
     
  6. Offline

    Sim121

    I've got a problem with NPCTrader and iConomy... When I launch the server, I've got this error :

    17:37:40 [INFO] NPCTrader Successfully linked with iConomy.
    17:37:40 [INFO] NPCTrader version 1.1.3: No iConomy, disabling plugin
    17:37:40 [INFO] NPCTrader version 1.1.3 is disabled!

    ... WtF ?

    EDIT : Sorry, I used iConomy 5 ><
     
  7. Offline

    mitrandir

    i have trouble starting plugin. For what versionof iConomy it designed?
    Code:
    22:29:52 [INFO] [iConomy] Logging is currently disabled.
    22:29:52 [INFO] [iConomy] v5.0 (Eruanna) loaded.
    22:29:52 [INFO] [iConomy] Developed by: [Nijikokun]
    22:29:52 [INFO] [BankAccount] Running interest every 5 minutes by 0.1%
    22:29:52 [INFO] [BankAccount] Established connection with iConomy!
    22:29:52 [INFO] Jobs 1.3.3 started
    22:29:52 [INFO] [Jobs] Successfully linked with iConomy.
    22:29:54 [INFO] NPCTrader Successfully linked with iConomy.
    22:29:54 [INFO] NPCTrader version 1.1.3: No iConomy, disabling plugin
    22:29:54 [INFO] NPCTrader version 1.1.3 is disabled!
    22:29:54 [SEVERE] Could not pass event PLUGIN_ENABLE to NPCTrader
    java.lang.NoClassDefFoundError: com/nijiko/coelho/iConomy/iConomy
            at com.MatCat.NPCTrader.PluginListener.onPluginEnable(PluginListener.jav
    a:24)
            at org.bukkit.plugin.java.JavaPluginLoader$37.execute(JavaPluginLoader.j
    ava:452)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
     
  8. Offline

    MatCat

    Updated item handling, now should work with all official in game items and block types, fixed npc creation error spam, fixed move command, fixed config creation error.

    This is still a testing version, please report any and all bugs.

    Currently the renaming command is broken.
     
  9. Offline

    snickerless1

    Grrr, I get an error whenever I try to enable it. Here is the error itself:

    19:54:50 [INFO] Database configuration Error!
    Verify your config.yml settings are correct and valid for your MySQL setup.
    Returned 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.
    19:54:50 [INFO] NPCTrader version 1.1.4 is disabled!

    So then here is the relative part of my config file for NPCTrader, the part about mysql:

    DB:
    Driver: "com.mysql.jdbc.Driver"
    Database: "jdbc:mysql://localhost/minecraft"
    User: "root"
    Pass: "bacon"

    I know my username and password are correct, not certain about the database and driver. Halp?
     
  10. Offline

    MatCat

    That should work... Assuming localhost is working for you, I assume you are on windows? Do you have the mysql connector installed?

    Oh and no not iConomy 5 yet, that will be next.

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

    snickerless1

    I'm on a mac actually and I don't have iConomy (I have it but I keep it in a seperate folder where i keep all my disabled plugins and yes, it is iConomy 5 but it's not even enabled) but the plugin itself should still enable right? Because it's not. And what do you mean localhost? Like on the actual game, or what? ARGH
     
  12. Offline

    MatCat

    No it requires iConomy.
     
  13. Offline

    snickerless1

    Didn't work, got 4.6 and stuck it in there but it still says the same error. :(
     
  14. Offline

    MatCat

    Well the error is clearly an SQL issue, try replacing localhost with 127.0.0.1
     
  15. Offline

    snickerless1

    nope, stuck my internal ip into both config files (bukkit.yml and NPCTrader/config.yml) but no dice.
     
  16. Offline

    MatCat

    Weird not sure, I will check the db code out and see whats going on. Plus look to make sure I am properly closing all objects out properly (prevent loops and leaks). Also I will be changing out the system to use the Register API which allows all the major economy plugins to be used.

    I am not even sure how many people are using my plugin, show of hands? If no one is really using it I might just stop support and keep it as part of my private plugins just for my server. If enough show support though I will polish it up real good, make sure it's as stable as possible, etc and work on adding features a little faster.
     
  17. Offline

    alta189

    @MatCat
    I can add SQLite support :D can you send me the github link?
     
  18. Offline

    MatCat

    I need to push the most recent changes to the github first, its slightly outdated :p
     
  19. Offline

    alta189

    OK :D
     
  20. Offline

    DaddyCool64

    I would like to use it. Im waiting some weeks, but i can't use it atm because using iConomy5.
    Don't stop support, please.
    Look at the iConomy Tread: some people write the problem with NPC Trader. So i think some people like to use it.
     
  21. Offline

    alta189

    I would really like to use this! When you update the github I can add SQLite support for you :D
     
  22. Offline

    rockNme2349

    I've been waiting patiently for the iConomy 5 update, please don't stop support!
     
  23. Offline

    MatCat

    Cool, well just an update. I am going to use the Register plugin which will bring support for iCo4, 5, Bose, and Essentials economies! Also I am re-designing how NPC's work. Because I have a server that has climbed to nearly 200 NPC's and mostly in my server's main city, it becomes largely laggy when a lot of NPC's are in one idea. My solution is to only make them visible when close. This will be a feature you can turn off or on, as well as configure the distance. Server's with only a few NPC's will be fine leaving them run the classic way, but once you start getting a large quantity of NPC's in one area, it is necessary.

    Hopefully I will have a working version up tonight.
     
  24. Offline

    jamescosten

    Have tried everything and cannot get to work. Downgraded iconomy to 4.6 and i keep getting this wall of spam

    Show Spoiler
    15:53:00 [SEVERE] Could not pass event PLUGIN_ENABLE to LoginMessage
    java.lang.NoClassDefFoundError: com/iConomy/iConomy
    at com.tahkeh.loginmessage.LoginMessageServerListener.onPluginEnable(LoginMessageServerListener.java:31)
    at org.bukkit.plugin.java.JavaPluginLoader$37.execute(JavaPluginLoader.java:497)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:757)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:253)
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:132)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:110)
    at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:337)
    at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleCommandMap.java:243)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:127)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:271)
    at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:401)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:386)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:292)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:394)
    15:53:00 [INFO] WorldEdit 4.4 enabled.
    15:53:00 [INFO] WorldEdit: Permissions plugin detected! Using Permissions plugin for permissions.
    15:53:00 [SEVERE] Could not pass event PLUGIN_ENABLE to LoginMessage
    java.lang.NoClassDefFoundError: com/iConomy/iConomy
    at com.tahkeh.loginmessage.LoginMessageServerListener.onPluginEnable(LoginMessageServerListener.java:31)
    at org.bukkit.plugin.java.JavaPluginLoader$37.execute(JavaPluginLoader.java:497)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:757)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:253)
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:132)
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:110)
    at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:337)
    at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleCommandMap.java:243)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:127)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:271)
    at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:401)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:386)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:292)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:394)


    Am trying to do a review on this plugin but not going very well so far :(
     
  25. Offline

    DaddyCool64

    @MatCat
    forgot to update the Link in OP?

    Code:
    2011-05-26 17:50:57 [SEVERE] Could not pass event PLUGIN_ENABLE to NPCTrader
    java.lang.NoClassDefFoundError: com/nijiko/coelho/iConomy/iConomy
     at com.MatCat.NPCTrader.PluginListener.onPluginEnable(PluginListener.java:24)
     at org.bukkit.plugin.java.JavaPluginLoader$37.execute(JavaPluginLoader.java:497)
     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:310)
     at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:757)
     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:253)
     at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:132)
     at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:110)
     at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:218)
     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:205)
     at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:145)
     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:265)
     at net.minecraft.server.ThreadServerApplication.run(SourceFile:394)
    Caused by: java.lang.ClassNotFoundException: com.nijiko.coelho.iConomy.iConomy
     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:36)
     at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:24)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
     ... 13 more
     
  26. Could you add an API to your plugin so other plugins can see if it ist a NPCTrader?
     
  27. Offline

    fullwall

    @MatCat - possible fix for lag (may cause irregularities) -
    worldserver.players.remove((EntityHuman) eh); on spawn.
     
  28. Offline

    MatCat

    What kind of irregularities?

    I have it working but buggy on my server, there are still economy issues I need to fix, though the NPC handling routine is working well, basically I have a thread safe thread running every second to loop through all npc's and players and put the ones needing turned on/off into a hashmap (it's really lightweight as it only passes the ones needing toggling, and only stores a string, string hashmap), then a bukkit safe schedule is ran to remove/turn on npc's every half second. Because the time consuming part is handled on a thread safe thread, it does not impact the main server thread (maybe on a single core setup, haven't tried that). Point is there is only ever maybe a couple of NPC's being turned off and on at any given time, so it's very fast. On my server with 30 to 40 people and about 100 active NPC's in a 200x200 city, generally there are only ever 1 to 10 NPC's showing at one time, and turn off's / turn on's are maybe once every 10 to 20 seconds, so it's pretty efficient. Until a better idea comes along it's all I can think of, we need to partition Notch to add NPC entity to the game with a simple API that isn't tied to the player entity and networking :p
     
  29. Offline

    fullwall

    Or bukkit. :p. I haven't found any irregularities yet with my method, but it's hard to tell because of 1.6.4 lag.
     
  30. Offline

    MatCat

    Once you spawn the NPC you remove it from the player list? This does not interfere with events?
     
  31. Offline

    fullwall

    Not as far as I can tell. As I say, it *might* do something, but the player is still on the entity list so.
     

Share This Page