Purchasable Permissions/Abilities

Discussion in 'Archived: Plugin Requests' started by Johannes, Feb 26, 2011.

  1. Offline


    Note: I am aware that similar idea have been suggested before, but so far none of the requests have gone into much detail about how it should be implemented (or have been replied to at all). I hope that my idea here is a little more concrete and might inspire an awesome developer to give it a shot.

    The main reason that I have so far not implemented a server-wide economy on my server is that there isn't any real goal to work for, and no fun reason for players to try work to get a lot of money.

    Sure, there might be plugins that provide a limited number of 'spells' users can buy through an economy, but these don't extend to whatever awesome stuff you can do with the huge number of other plugins available.

    Allowing users to buy access to abilities and permissions from other plugins with money they have earned through a server-wide economy would give a large incentive for users to really work on amassing wealth, and provide a kind of extended end-game to SMP.

    I would like to request a plugin that ties into various economy plugins, like iConomy and EssentialsEco and such, and would allow users to buy any permission that could be applied to them via Permissions or GroupManager. Such purchased 'rights' would be called 'Abilities'.

    The Plugin would consist of four components:
    1. a list of abilities you want users to be able to buy, and purchasing details
    2. a list of players and the permissions they have purchased.
    3. an interface in the game for browsing and purchasing abilities.
    4. an interface in the game for viewing purchased abilities.
    1 and 2 could be stored in flat-file or database format. I want to make sure that purchased abilities are stored in their own file, and not tacked onto the files that permissions or GroupManager use.

    Here is a small list of abilities I know my users would be eager to buy:
    For the sake of explaining it I will be using some permissions from the essentials plugin.

    Four Components (open)

    1. Ability List
    (For 1. and 2. I am using a format similar to the YAML files of Permissions/GroupManager to display the data, but it likely isn't correctly formatted for YAML. The point here is really just to give a general idea how I feel it could be implemented. Also the values are completely arbitrary)

    The file containing the buyable commands would be set up like this:

    # This name is how the plugin refers to the purchaseable ability internally. It's used in the file described in 2.
    info: {name'jump to aim'description'allows user to jump to a block you are looking at'help'To jump type /jump or /j' }
    # name/description listed in game/ability inventory. changing the name here would not break the association to users that have bought it.
    permissions:  [ essentials.jump ]
    # all permission nodes the user would gain access to.
    # used to organize/filter abilities
    limits: { time_limit}
    # various limits, for example how long the user has to wait before they can use ability again
    buy: { cost10000 }
    # permanent ownership of that permission
    rent: { cost100duration30000 }
    # time-based ownership of that permission
    use: { cost20stock10 }
    # single use ownership
    info: { name'use heal chests'description'allows you to use healing chests'help'Find a chest with a sign that says [heal]. then right click it.'}
    permissions:  [ essentials.signs.protection.use ]
    limits: { }
    # time limit would not make sense since it is not a /command
    buy: { cost10000 }
    rent: { cost1000duration3000 }
    info: { name'Home'description'Allows you to set and change your home'help'Type /setHome to create your home and /home to access it.'}
    permissions:  [ essentials.sethome ]
    limits: { }
    buy: { cost1000 }
            use: { 

    2. Player List
    The file storing what abilities players have purchased should look similar to this:
    Jump: { type'buy'lastuse'time_stamp' }
    HealChest: { type'rent'purchased'time_stamp' }
    SetHome: { type'use'stock3lastuse'time_stamp' }

    HealChest type'use' }
    SetHome type'buy'lastuse'time_stamp' }


    3. Ability Store Interface
    Users could purchase abilities in-game through a store with a command like /ashop or /astore

    They would see:
    HOME - BASIC |P:1000||U:100|
    JUMP TO AIM - MOVEMENT  |P:1000 | R:100 | U:10|
    USE HEAL CHESTS - COMBAT | P: 10000 |R:1000||
    available commands would be:
    '/astore help' these commands:
    '/astore help <name>' help info for an ability
    '/astore info <name>' description for an ability
    '/astore page <#> to view different pages (8 or so entries per page, organized by category)
    '/astore category <categoryname>' to view only commands from a given category
    '/astore purchase <name>' Permanently purchase ability
    '/astore rent <name>' Rent ability
    '/astore buy <name> [#]' Buy single use of ability, or specified number

    When the user uses /astore purchase <name> they will see:
    PURCHASE <name> PERMANENTLY FOR <amount>
    When the user uses /astore rent <name> they will see:
    RENT <name> for <amount> for <duration>
    When the user uses /astore buy <name> # they will see:
    BUY # USES OF <name> FOR <amount>
    YOU OWN [mystock] OF A MAX [maxstock].
    Typing '/astore deny' or any other /astore command will cancel the transaction.

    4. Ability Inventory Interface
    Users could view purchased abilities through commands like /abilities, /ainventory or /ainv

    player_1 would see something like this:
    With relevant commands that allow them to see the description, help text, etc.

    With a plugin like this the possibilities of what you could allow users to purchase access to would be only limited to what plugins have to offer that support permissions (which hopefully will be all of them once bukkit natively supports permissions).
  2. Offline


    I'm not sure how to tie in iConomy (I've never looked at its code), but it's done fairly often.

    For the meat of the plugin, you might could simplify it with the following:
    Hook the player command function on one of the higher priorities.
    When a command comes in, check if the command is in the ability list
    If it is, and the player lacks permission, just set the event to be canceled, and it should prevent it from going to the plugin to be launched. This should work at least for MoveCraft and Ion Cannon, which are triggered by chat commands.
  3. Offline


    Sounds awsome dude! Better than my idea for firework lol
  4. Offline


    Thanks for the reply!

    Yeah, at first I wasn't sure which would be better, to keep it in terms of chat commands, or permissions that grant access to the commands, but after having thought about it for a bit, I definitely want users to be able to buy permissions alone, which often don't have any commands associated with them (see my the healchest example).

    Even with movecraft, if you want to allow a user to use all kinds of craft, just going with commands won't do it, since those can be custom defined and you would have to add them all as you add crafts. It would be far easier to just let them purchase the permission to the node 'movecraft.*' which would cover all future craft as well.

    There are a ton of great plugins that don't use chat commands but have permissions, so I definitely feel that that is necessary.

    Perhaps in the file that defines available abilities you could state if it's in terms of permissions, commands, or both.

    On a side note, it would also be fun to have it call certain commands when the user's access to them has expired (via the rent command). for example, a user could rent the magic carpet plugin, use it with the command '/mc' as often as they want, but the server would keep track of how often they used it and would call it again once the usage time has expired, if it had been used an odd number of times since the user logged in (meaning they were currently on the carpet). This would apply to any plugin where the ability you gain from it is toggled on and off.

    It would certainly be amusing, and would prevent exploitation of command effects that stay active after you no longer have permission to use them, but again that's just brainstorming and might just add unnecessary bloat, but it would apply to examples like worldedit's super pickaxe (toggled by '//')

    I think it would fundamentally change how people approach economies in minecraft. And I wouldn't mind being able to buy single-use fireworks ;)
  5. Offline


    Well, putting it that way...
    I know that Permissions (or GroupUsers, or something) has an in-game plugin or component that allows you to dynamically assign and remove nodes from a user.
    Rather than keeping purchased nodes in a different file (depending on how hard it'd be to rewrite permissions to look in that file in addition to its own), you could just use very similar functionality, except users would be able to assign permissions to themselves, if they have the iConomy currency to exchange it.

    You could have a flatfile that stores "PermissionExpiration", which the plugin itself checks regularly (using BukkitScheduler), which stores a username, permission node, and time. If current time > stored time, remove the permissions node from the user.
  6. Offline


    Hah! I was thinking about this, I was going to manually move the permissions 1 by 1, but this, this is 10x better. :O
  7. Offline

    Stephen A.

    This sounds totally AWESOME!! I would so love this, and i know someone who runs a server, who would also love this, because i am always wanting permissions on that server, but have to way to get them :(. Once again AWESOME! (If i could code bukkit plugins, i would make this ASAP, but i have no idea about bukkit programming.)
  8. Offline

    Codex Arcanum

    Sounds cool.
  9. Offline


    Well, I've actually been trying to write this, but I was kind of afraid to post. I have made some progress, but nothing working yet. This is my first Java program (I wrote C++ programs before), so help would be appreciated. You can find the source code at https://github.com/rcjrrjcr/BuyPermissions.
  10. Offline


    Looks like a good start! I wish I could be of any help, but I don't have very much java experience. Let us know when you think we can try to test something [​IMG]
  11. Offline


    Well, looking through your suggestions, I noticed the "limits" part in the YAML config file. If you're referring to warmups and cooldowns, I don't think I can implement that with the current way I am handling permissions, as I only can grant or remove permissions based on the passage of time. I'm not sure how to cancel command events correctly.

    On another note, I was thinking about a way to group purchasable permissions so that players require a special permission to buy/rent/use them.
    To give an example:
        basic: buypermissions.basic
        movement: buypermissions.movement
    This way, a player needs the permission "buypermissions.basic" before he can buy/rent/use the SetHome permissions and others of its categories. There can be "ranks" of permissions, where a "rank upgrade" permission must be purchased before having access to the next rank.

            permissions: buypermissions.rank2
            category: rank1
            permissions: buypermissions.rank3
            category: rank2
        rank1: buypermissions.rank1
        #First rank, available to all players
        rank2: buypermissions.rank2
        #Second rank, available to players who have
        #bought buypermissions.rank2 (which is found
        # rank 1)
        rank3: buypermissions.rank3
        rank4: buypermissions.rank4
  12. Offline


    wow, please get this working
  13. Offline


    Yeah, the limits part of it is not too necessary, I was really just trying to put as much down on this idea as I could come up with. It's fine if that's not there initially.

    I do really like the idea of having categories and buying ranks like this. It's wonderfully meta that these are defined as permissions and all can be made to be bought in-game.

    For example guests to the server could play and have access only to rank 1 abilities, while users or subscribers get higher ranks that they can buy. Very nice work.
  14. Offline


    Thanks for the compliment. Anyway, I have both good news and bad news.

    The good news is that I have finished all the abstraction layers that (hopefully) allow this plugin to work with either GroupManager or Permissions, and either iConomy or Essentials.

    The bad news is that I have to create and manage a buffer so that loaded data doesn't throw exceptions before the permissions plugin is loaded. Fortunately, it's quite simple. I hope I can release a working version of this soon!

    On another note: Since this plugin is already under development, should the discussion be shifted to a new thread under the Plugin Development/WIP and Development Status forum?
    Created new thread - [ECON/FUN] BuyPermissions v0.01
  15. Offline


    Sounds good, meet you there. not sure if it's standard procedure, but I guess this thread can be locked now so people can just use the new thread.

Share This Page