AbilityTrader

39.7k Downloads

About

AbilityTrader allows your players to buy and rent commands and permissions using an economy or experience points.

This plugin was created because the server I run has a particular problem with a few players having significantly more money than the rest, so having this plugin allows them to get a few more features and reduces their balance accordingly.

Setup

Copy AbilityTrader.jar into your plugins directory. The first time it runs, a configuration file will be created in AbilityTrader/config.yml. You should edit this to add abilities that you want to sell or rent to players.

Permissions

  • abilitytrader.use - Allow players to use AbilityTrader (default: true)
  • abilitytrader.showhidden - Allow players to see hidden abilities in the list (default: op)
  • abilitytrader.admin.reload - Reload the configuration (default: op)
  • abilitytrader.admin.players - See a list of players and abilities they have (default: op)
  • abilitytrader.admin.add - Add abilities to players (default: op)
  • abilitytrader.admin.remove - Remove abilities from players (default: op)
  • abilitytrader.admin.* - Provides showhidden, reload, players, add and remove permissions (default: op)

Commands

There are very few commands for AbilityTrader - type /ability help for a short list. All of these work (with the exception of info, rent and buy) on the console as well as in-game.

For administrators, you can view a list of players with abilities by typing /ability players - this will show all players with abilities, along with their expiry times if applicable. You can also reload the configuration file with /ability reload if you make any changes to the file itself.

Administrators are also able to remove player abilities without having to manually edit the file. To do this, type /ability remove <player> <ability>. You will see error messages if something goes wrong.

Administrators can also give abilities to players by typing /ability add <player> <rent/buy> <ability> <true/false>. The true/false at the end determines whether AbilityTrader should charge the player for the ability (it won't charge the administrator).

Alternatively, you can use /ab, /at or /abt as a shortcut to /ability.

Configuration

The default configuration is as follows:

log: false
page_results: 10
global:
  commands:
    add: []
    remove: []
abilities:
  workbench:
    description: No need for real workbenches any more!
    permissions:
      - essentials.workbench
    commands:
      add: []
      remove:
        - msg {0} Removing workbench ability
    rent_cost: 100
    duration: 300
  me:
    description: Say stuff third-person style
    permissions:
      - essentials.me
    commands:
      add: []
      remove: []
    buy_cost: 5000
    rent_cost: 15
    duration: 60
  hat:
    description: Look dapper in your choice of hat
    groups:
      add: Fashionable
      remove: PREVIOUS_GROUP
    permissions:
      - essentials.hat
    buy_cost: 1000
players: []

You should add abilities that you want to buy or rent under the abilities section. Keep the ability name short and meaningful. You can expand on what the ability provides with the description.

Each ability can assign zero or more permissions to players. If you don't want to give any permissions, just set this to permissions: [].

Each ability can also execute commands when abilities are added and removed (when players buy/rent, and when they expire, if rented). Again, this can be one or more commands, or none at all. You can use the placeholder {0} to pass the player's name to the command. This is useful if you want to message them when the ability is removed, etc. The commands should not have a slash (/) at the start, and will be run automatically when a player buys or rents an ability, and run automatically when abilities expire or admins remove them from players, if any remove commands have been specified. You can also use additional placeholders for commands - {1} is the ability name, {2} is the price of the ability (if they rented, it'll be the rent price - if they bought, it'll be the buy price), and {3} is the same as {2} except it includes currency formatting (i.e. adding $ to the amount, or however you have your economy setup. If you're using experience, it will suffix the cost with 'exp'). Global commands can be run as well as or instead of individual ability commands. The special placeholders work here too.

You can specify a rent price and buy price with money or experience, either individually or together. If renting, simply call this rent_cost. For buying, it's buy_cost, and if you want to allow buying and renting of the ability, just specify both options. If you prefer to use experience points rather than an economy system, use buy_exp and rent_exp.

The duration specifies (in seconds) how long a player will have the ability for. After this time, the ability will be removed and any remove commands will be executed. The duration only applies to rentable abilities.

Each ability can optionally move players to and from groups when adding or removing the ability. You can only specify one group when adding or removing (multiple groups wouldn't make sense). An example can be seen for the hat ability above. This example uses the special keyword _PREVIOUSGROUP - if that's specified for the 'remove' group, AbilityTrader will assign the player's previous group to them when removing the ability. This is useful if you have a complex hierarchy of groups.

You can add hidden: true to an ability if you don't want players to see it in the list (or on their info screen if they already have it). This is ideal if you're testing abilities or don't want players to have access to certain abilities. Any players with the abilitytrader.showhidden permission will be able to see these (op by default). Administrators can give hidden abilities to regular players if necessary.

You should avoid modifying the players section - this tracks which players have abilities, when they were given and when they will expire (if they were rented).

Other

AbilityTrader runs a task every minute to remove expired abilities - you may notice that /ability info may still show these if they have expired but the task hasn't run yet.

This is my first Bukkit plugin and the first time I've used Java, so please bear in mind that this won't be perfect and may well have bugs. Having said that, I have tested it on one production server without any issues, as well as extensive testing on a development machine.

If you find any bugs or would like to suggest features or improvements, please click the Tickets link above.

If you would like to test this plugin, you're welcome to connect to PlayPyxis.com in-game and use the commands above.

Check out my other plugin, AreaTP if you want to allow your players to create their own public warp points.