Economy plugin

  • I have been working on an economy plugin for my personal server. I figured I'd share with others. The mod adds a virtual wallet for players and works via chat commands. Over half the items have been priced. I'll work on pricing the rest over the next couple days. It will take a while as there are lots of items in game.


    commands:
    /ebalance - check wallet balance.
    /eprice - check price of item held.
    /ebuy - buy item held. is optional. If no amount is specified, one will be bought.
    /esell - sell stack held. is optional. If no amount is specified, whole stack will be sold.


    admin commands:
    /egivecoins - give specified player coins. All command options required.
    /economy set - set price of item held. is required.
    /economy export - export pricelist table to csv file in plugin folder.
    /economy import - import pricelist.csv from plugin folder.


    Downloads: https://github.com/notabadminer/rw-economy/releases


    BUGS? Please file an issue here: economy issues


    KNOWN ISSUES: players cannot buy objectkits. The API doesn't have a way to add objects to inventory. I've disabled buying for now.


    WANTED: Help with german transaltion support. PM me if interested.

  • Good job @notabadminer! May I raise a few details?


    1) Is there a reason for using the world database as database? I understand this simplify some things, but I would refrain from 'polluting' the world database as, for instance, if something goes wrong there is a risk of corrupting the whole world and who knows if in the future the dev team adds a new table with the same name of one of yours table?


    2) I have not tried the plug-in yet, just browsed the code. Are you sure i18n works by simply dropping a language file in the plug-in directory? The code reads the language file from the resources and this requires the language file to be in the .jar.


    3) If am not mistaken, the code reads each localised string from the resources each time it is needed. This seems a waste of storage and CPU usage. As currently there are only about 20 strings (and there might be a few more in the future but not hundreds and hundreds) and RW only supports two languages, I would pre-load all the strings at plug-in start in an array / container and then access the needed one from memory.


    3b) Same for built-in default strings, which are all loaded each time one is needed: these are a rather obvious candidate for pre-loading.


    4) I am not sure that localising commands is a good thing, as this may require that players learn new commands for the same things when switching from one server to another.


    5) Also about commands, commands with very generic names like "/buy" and "/sell" are likely to clash with other plug-ins implementing some kind of buying and selling. My approach is to use a plug-in specific prefix for all commands, as for instance "/econ buy ...", "/econ sell ..."

  • @Miwarre You havegood points. This is very much a work in progress. I am a sloppycoder both to inexperience and laziness. It will take severalrevisions before the code becomes anything resembling good.



    1) I used the world database out of ease of implementation. I willlook into changing to a separate database.
    2) the function tries to load the lang file from the plugin dir,then from the jar, then defaults back to the en.lang file from thejar. I'm looking into how to implement loading once on plugin init.I'm not sure how to do that yet. I've been working off tutorialsonline.
    3) it is a major overhead and needs to be corrected. I'm not surehow to fix it at the moment. I'm still learning
    4/5) I see your point. I will revert to static command names thatshouldn't conflict

  • 1) I used the world database out of ease of implementation. I will look into changing to a separate database.

    As we are speaking of just two tables with at most a couple of hundreds of rows each, there are little reasons for not using SQLite, which is simple, fast and easy. Using a plug-in specific SQLite DB is just a matter of replacing


    WorldDatabase database = getWorldDatabase();


    with


    Datatase database = getSQLiteConnection(getPath() + "/myDBname.db");


    or, if you want to have a separate DB for each world (mostly for use with single player installations, where multiple worlds normally coexist):


    Datatase database = getSQLiteConnection(getPath() + "/myDBname-" + getWorld().getName()+".db");


    I would use database as a class field, so that you can open it at plug-in start-up (onEnable()) and close it at plug-in close-down (onDisable()) and have it ready to use any time you need it (database.executeQuery(...);, database.executeUpdate(...);, etc).


    About the other points, I see you have quickly found a solution. Great!

  • Thanks for the help. That was easier than I was expecting. release 0.6 has the new database and a lot of code cleanup. I removed some of the horrible workarounds that I was playing around with trying to avoid delayed database writes. It seems to be working much better.

  • Is there an easy way to clear all prices and make them manually only for those items that I need? I can export a pricelist. And change values to -1. But there are hundreds of strings.


    May be you have a clean pricelist?

  • I don't think this has been updated in quite a while. Last time the creator was online on the forum was May 6th 2017, so almost a year ago :/

  • Ok, help please


    I know this thread is cold, but I have been trying out the plugin. So to those who might be using it.


    Do you have to set all the prices for goods? As the plugin when I have run it returns the message, NO PRICE FOR '......' when '.....' is any item? I see a csv file in the zip that accompanies the jar file but when the zip is opened this ends up in a subfolder of a subfolder. Now my programming skills are as about accomplished as my acrobatic skills on a trapeze, which means if I try to do acrobatics on a trapeze I would end up as a puddle of goo and bones on the floor. So I'm guessing the csv file is not being read or I have to place it somewhere else?

  • Ok, help please


    I know this thread is cold, but I have been trying out the plugin. So to those who might be using it.


    Do you have to set all the prices for goods? As the plugin when I have run it returns the message, NO PRICE FOR '......' when '.....' is any item? I see a csv file in the zip that accompanies the jar file but when the zip is opened this ends up in a subfolder of a subfolder. Now my programming skills are as about accomplished as my acrobatic skills on a trapeze, which means if I try to do acrobatics on a trapeze I would end up as a puddle of goo and bones on the floor. So I'm guessing the csv file is not being read or I have to place it somewhere else?

    I just recently installed this plugin, but so far I have found that only some of the items have prices by default. I had the same question you did, so I downloaded the source code and found that the .csv file inside the jar file is only used to populate a database the first time you start with the plugin, or I guess if you do an import. Also, if that .csv file is not in the jar file, it will also look for a .csv file with the same name inside the plugin directory. Once the database is initialized, you can use a SQLITE database tool to modify the pricelist table, or I suppose you could delete that database file, modify the .csv file and then restart and it should import all the prices. This would lose account balances for all players though.


    I ended up modifying the code a bit to allow any player to transfer money to another player and have it deduct from their account and credit the recipient.


    Hope that helps.


    Trint

  • It needs to be updated for UID reference not name reference for the general reasons for this. The autologon account setup was not functioning in my server so you have to sell something for the account to show up. I have done a minor patch that allowed that as well as transfer between people if you need it contact me. It is functional, if rather crude, as I am not an expert Javasmith by any stretch of the words.


    There is a command for exporting and importing a .csv file that you can edit the prices. It is an admin command. /economy export and /economy import. The file has to be .csv but you can edit it in Excel or a good text editor. The price item list is woefully out of date. You will have to update this with new items such as saddles or saddlebags.

  • Hi ! Thanks a lot for this plugin ! Rising world is SO GREAT and with your plugin it can become AMAZING :)


    But i've got problems with it :(


    When i type /egivecoins 1 toto it tell me "Invalid Amount!" and i got coins in my wallet :(


    What's wrong with my command please ?


    Thanks a lot !

  • The problem is most likely not with your command but with the fact that this plugin hasn't been updated in more than a year with 2 major updates changing a lot of things in the game and Java API in that year.


    tl;dr this plugin most likely doesn't fully function anymore

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!