[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

    HoloProject

    New Error code after switching to Essentials and Groupmanager/Fakepermissions

    Code:
    18:07:34 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'npc'
    in plugin NPCTrader v1.1.2
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:80
    )
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:2
    54)
            at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:626)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:589)
    
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:583)
            at net.minecraft.server.Packet3Chat.a(SourceFile:24)
            at net.minecraft.server.NetworkManager.a(NetworkManager.java:198)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:72)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:368)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    Caused by: java.lang.NullPointerException
            at com.MatCat.NPCTrader.Commands.npcCommand.Run(npcCommand.java:75)
            at com.MatCat.NPCTrader.Commands.npcOwnerCommand.Run(npcOwnerCommand.jav
    a:18)
            at com.MatCat.NPCTrader.Commands.npcRemoveCommand.Run(npcRemoveCommand.j
    ava:21)
            at com.MatCat.NPCTrader.NPCTrader.onCommand(NPCTrader.java:380)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
            ... 12 more
     
  3. Offline

    MatCat

    Please post a copy of your npctrader's config.yml...
     
  4. Offline

    HoloProject

    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: "root"
      Pass: "mc"
    # This is the configuration for maxium allowed NPCs based on
    # Permissions or GroupManager FakePermissions AKA EssentialsGroupBridge
    # It is sectioned into 2 sections, Groups and Players.  Either
    # configuration tree takes the respective name with Count as the value
    # holder.  Examples shown below.
    # 0 means none
    # -1 means Unlimited
    # Any other negative number would equate to unlimited
    # Any posative number would be the limit of NPC's the player may be
    # owner flagged on.
    
    MaxNPCGroupsCount:
        Default: 2
        Moderator: 10
        Admin: -1
    MaxNPCPPlayersCount:
        matcat: -1
     
  5. Offline

    BSPiotr

    :( So it was answered somewhere in this thread? I've gone over it with both search and a fine toothed comb...
     
  6. Offline

    MatCat

    I will check into is...
     
  7. Offline

    Pontus Lantz

    I'l pray that you get the time to fix so permissions work to <3. I don't really know why but i hate GroupManager for some reason... Just something im born with i guess ;).
    And ofcourse noone can make any kind of demands and be rude. This is your project that you are nice enough to share with us [meat]
     
  8. Offline

    tommy99

    i have a problem with npc trader you can se the error in my last post
     
  9. Offline

    god_chris

    im confused about the driver part, ive got it linked into a brand new table, but i have no idea about the driver? ive tried the deafult one but i always get an error :(
     
  10. Offline

    Navist

    Code:
    08:30:45 [INFO] Database error trying to check database.
    08:30:45 [INFO] NPCTrader version 1.1.2 is disabled!
    
    config.yml (open)
    # 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.odbc.Driver
    Database: jdbc:mysql://localhost:3306/minecraft
    User: censored
    Pass: censored
    # This is the configuration for maxium allowed NPCs based on
    # Permissions or GroupManager FakePermissions AKA EssentialsGroupBridge
    # It is sectioned into 2 sections, Groups and Players. Either
    # configuration tree takes the respective name with Count as the value
    # holder. Examples shown below.
    # 0 means none
    # -1 means Unlimited
    # Any other negative number would equate to unlimited
    # Any posative number would be the limit of NPC's the player may be
    # owner flagged on.

    MaxNPCGroupsCount:
    Peon: 0
    Donator: 10
    Moderator: 10
    Admin: -1
    MaxNPCPPlayersCount:
    matcat: -1
     
  11. Offline

    DaddyCool64

    I need help.
    I type /npc create Bob 6 10
    I get an internal Server error
    This the log file entry:
    Code:
    2011-04-24 02:17:33 [SEVERE] Nag author: 'MatCat' of 'NPCTrader' about the following: onPlayerCommandPreprocess has been replaced with a new signature, (PlayerCommandPreprocessEvent)
    2011-04-24 02:17:33 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'npc' in plugin NPCTrader v1.1.2
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:80)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:254)
        at net.minecraft.server.NetServerHandler.c(NetServerHandler.java:637)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:600)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:594)
        at net.minecraft.server.Packet3Chat.a(SourceFile:24)
        at net.minecraft.server.NetworkManager.a(NetworkManager.java:198)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:72)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:100)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:368)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:375)
    Caused by: java.lang.NoSuchMethodError: com.nijiko.permissions.PermissionHandler.getGroup(Ljava/lang/String;)Ljava/lang/String;
        at com.MatCat.NPCTrader.NPCTrader.CanCreate(NPCTrader.java:118)
        at com.MatCat.NPCTrader.Commands.npcCreateCommand.Run(npcCreateCommand.java:42)
        at com.MatCat.NPCTrader.NPCTrader.onCommand(NPCTrader.java:354)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
        ... 12 more
    My config.yml:
    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: 1
      Unit: 1
      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/c1bukkit"
      User: "*****"
      Pass: "*****"
    # This is the configuration for maxium allowed NPCs based on
    # Permissions or GroupManager FakePermissions AKA EssentialsGroupBridge
    # It is sectioned into 2 sections, Groups and Players.  Either
    # configuration tree takes the respective name with Count as the value
    # holder.  Examples shown below.
    # 0 means none
    # -1 means Unlimited
    # Any other negative number would equate to unlimited
    # Any posative number would be the limit of NPC's the player may be
    # owner flagged on.
    MaxNPCGroupsCount:
        Default: 0
        Moderator: 0
        Admin: -1
     MaxNPCPPlayersCount:
        DaddyCool64: -1
    My Permissions:
    Code:
            permissions:
                - '*'
    Where is the error?
    I like this Mod, but it don't work vor me

    -----
    Sorry for my bad english
     
    GingernutRanger likes this.
  12. Offline

    woodzy

    weres the update? CB has a test build of 1.5_2
     
  13. Offline

    CyborgOne

    Recommended 733 is out :)
    what do you think, which time you need for update?
     
  14. Offline

    swedish2011

    pls #CB733 (L)
     
  15. Offline

    MatCat

    I am considering open sourcing this plugin... With 1.5 I switched over to the new lib Kekec852 wrote, and I got it to work... However I am experiencing massive lag on my own server (100+ NPC's, 10 to 20 players connected). I have rewrote and rewrote again the system that handles keeping NPC's visible, but I cannot determine what is causing lag. I suspect it has something to do with DB queries as I notice the mysql process gets rather CPU intensive when running... If anyone out there is interested in helping me solve the lag, and refine this plugin, as I just do not have the time I wish I did have. If I can get someone willing to help I will open source this plugin completely on github.
     
  16. Offline

    Kongolan

    Maybe you should release it as a beta and so everyone can test the new build.
    I hate to debug without the running result ;)
     
  17. Offline

    MatCat

    Its completely lagged... I have the source up at https://github.com/MatCat/NPCTrader if anyone is interested in helping me figure it out and polish up the code, it really needs to be made current with the API.
     
  18. Offline

    arsenic87

    I looked trough the code, and think I can help with the MySQL querries. My java skills are not top notch (get it?), but we might be able to see what the problem against MySQL is. Im on IRC if you want to contact me =)
     
  19. Offline

    DJHenjin

    I know your in the process of upgrading the plugins MatCat, but i would like to suggest something. Have you thought of using a chest like interface for the NPC GUI? or is it even possible to trigger a chest interface on something other than a chest.
     
  20. Offline

    MatCat

    Someone I believe is doing an api for object interfaces, I will look into it.
     
  21. Offline

    Hretsam

    Its possible (i've done it before) and if MatCat would like it, i can help with it.
    Was going to check if i can help make this more efficient anyways.
     
  22. Offline

    MatCat

    Im trying to find someone to help me :p IF you want to take a look at the git and tell me what you think, you can fork it too if you want. My main goal right now is to get it running as efficiently as possible.
     
  23. Offline

    DJHenjin

    I tried to look at your source, But your directory sturcture on github is really confusing.
     
  24. Offline

    MatCat

    src/com/matcat is my plugin, src/org/martin is the NPC Library
     
  25. Offline

    Hretsam

    Ok, i downloaded your source. Will take a look at it, and will see if i can help.
    I think i got an idea where it lags the server, gonna check if i am right
     
  26. Offline

    SvenBrnn

    I will try to take a look over your Source, too.

    MFG Sven
     
  27. Offline

    MatCat

    Appreciate it looking it over.
     
  28. Offline

    Frag_Me

    Plz Can you send a test version ?
    Because i have only 1 npc but he is the base of the economy on my server !
    My members ask me alltime : When the NPC come back ???
    So Great plugin
     
  29. Offline

    MatCat

    My server relies on 100 or so NPC's! Believe me I am trying to get it working right.
     
  30. Offline

    firewalled

    I am patiently waiting for a new working release too. This is the last plugin I need after upgrading to CB#733.
    Luckily I had less than 5 NPCs, so the server works without but it is really a nice addition
     
  31. Offline

    MatCat

    I'm starting to think its a bug with mc1.5, I have some changes I will experiment with to see, but this might not work until 1.6, but I am working on it :).
     

Share This Page