CommandCodes is a Bukkit plugin which allows the generation of number codes which are linked to a specific command can be redeemed a certain number of times. An example use case is to allow a player who isn't an admin to perform a command giving them an item one time only. Codes are stored in JSON format in a codes file and can be viewed even after they have been redeemed.
Note: Instead of /ccode, the commands /cc or /ccc can be used.
Note: In general, I would recommend giving administrators commandcodes.admin, commandcodes.view and commandcodes.previous, and giving normal users only commandcodes.redeem, as if they were able to see the codes they could redeem those which weren't meant for them.
Default configuration:
code-cap: 99999 multiple-redemptions: false
The 'code-cap' option modifies the highest code number which can be generated. Big servers will require a higher number here, as codes cannot be duplicates of current or previous codes. The 'multiple-redemptions' option configures whether the same player can redeem the same code multiple times.
Source code for CommandCodes is available on GitHub
If you plan on hooking into the source code in some way, I recommend doing this to get the CodeManager, which contains pretty much every method that another plugin might find in any way useful:
final CommandCodes ccPlugin = getServer().getPluginManager().getPlugin("CommandCodes"); final CodeManager codeManager = ccPlugin.getCodeManager();
From here, you can retrieve lists of current and previous command codes, and you can remove, redeem or generate command codes.