BigSpender
BigSpender is a simple plugin for Paper and Spigot that allows players to type number abbreviations in their economy-related commands. This eliminates the need to type a bunch of zeroes into a command, which saves time and reduces typos. This is especially useful for servers with very large economies (balances reaching the trillions or even higher). In other words, if a player needed to pay someone 3 trillion dollars (commonly displayed as "3T"), they would just have to type "/pay Steve 3t" instead of having to type out nine zeroes.
New in v1.1: Format large numbers with PlaceholderAPI support! See the "Placeholders" section for more information.
Features
- Simple: Does exactly what it sets out to do; nothing more, nothing less. This simplicity allows it to work with any command from any plugin.
- Lightweight: Uses the OG Bukkit API and only registers a single event. Runs like butter and is compatible with every game version.
- Configurable: You can define exactly which commands (and subcommands!) BigSpender should process, and for which arguments. There's also support for custom number suffixes and huge numbers. Check the config.yml for more details.
How to use
Drop the jar into your plugins folder and run your server. BigSpender will start with some default settings in the config, but you should probably go in and define your own abbreviations and commands. As of now, you will need to reload the plugin to apply config changes.
Permissions
Players need permission
bigspender.use to have their commands processed. This is given to all players by default if no permissions plugin is installed.
Placeholders
BigSpender optionally supports PlaceholderAPI which allows you to format and parse numbers using the abbreviations defined in your config file. No additional download is needed - the placeholders are included with the plugin.
%bigspender_<number>% - Formats the given number. Example: 12300 -> 12.3k. Defaults to a maximum of three decimal places after the decimal point.
%bigspender_<number>_<decimal_places>% - Lets you define the maximum number of decimal points. 0 means you would get an integer (12300 -> 12k).
%bigspender_format_<number>% and
%bigspender_format_<number>_<decimal_places>% - Same as above, just explicitly specifies a format operation.
%bigspender_parse_<formatted_number>% - Works in reverse, taking a formatted number and giving the raw number. Example: 12.3k -> 12300
All arguments support bracket placeholders, for example if you have the rng module you could do
%bigspender_{rng_random}%. The main use case for this would be to format a player's balance.
Example Config
If you want a better idea about how to use the plugin, check out the
default configuration file.
Support
If you're having problems, a good start is to enable "verbose mode" in the config and try running a problematic command. This will print extra info to the console that will help you figure out what's going wrong. If that doesn't help, feel free to reach out on
Github Issues. Be sure to post your entire config and the output of verbose mode, and I'll do my best to help.
FAQ
Q: How does it work?
A: It works by reading and modifying the text of the command before it reaches the plugin that handles the command. This is done by a rarely-used event called PlayerCommandPreprocessEvent. The nice thing about this approach is that the plugin doesn't need to know any details about the actual commands, just which parts to expand number abbreviations for.
Q: How can I replace all abbreviations in every single command?
A: You can't. This would cause a lot of sneaky problems with arguments that look like an expandable number, but actually aren't - maybe they're player names or part of a message. What's worse, the player wouldn't even know why their command is going screwy. By explicitly defining which arguments of which commands are processed by BigSpender, you prevent these kinds of things from happening.
Q: Does this work for the console?
A: No, for similar reasons as above. Some plugins run commands as the console, and you definitely don't want to mess with other plugins like that. It would also be a potential security risk.
Things to improve
If I have time, these might be some things to improve:
- Command to reload config on the fly
- Option to use abbreviation prefixes instead of suffixes
- Automatic resolution of command aliases and namespaced commands
- Configurable event priority
- Better handling for commands that use argument autocompletion