
BigSpender
BigSpender 是一个适用于 Paper 和 Spigot 的简单插件,允许玩家在与经济相关的命令中使用数字缩写。这消除了输入大量零的需求,从而节省时间并减少拼写错误。这对于拥有庞大经济系统的服务器(余额达到万亿甚至更高)尤其有用。换句话说,如果玩家需要支付某人 3 万亿美元(通常显示为 "3T"),他们只需输入 "/pay Steve 3t",而不必输入九个零。
v1.1 新增:支持通过 PlaceholderAPI 格式化大数字! 请参阅“占位符”部分以获取更多信息。
功能
- 简单: 只做它该做的事;不多不少。这种简洁性使其能够与任何插件的任何命令配合使用。
- 轻量级: 使用原始的 Bukkit API,仅注册一个事件。运行流畅,兼容所有游戏版本。
- 可配置: 你可以精确指定 BigSpender 应处理哪些命令(以及子命令!)及其对应的参数。还支持自定义数字后缀和超大数字。请查看 config.yml 了解更多详情。
使用方法
将 jar 文件放入你的 plugins 文件夹并启动服务器。BigSpender 将以配置文件中的一些默认设置开始运行,但你可能应该进去定义自己的缩写和命令。目前,你需要重新加载插件才能使配置更改生效。
权限
玩家需要 bigspender.use 权限才能让其命令被处理。如果未安装权限插件,则默认授予所有玩家此权限。
占位符
BigSpender 可选地支持 PlaceholderAPI,允许你使用配置文件中定义的缩写来格式化和解析数字。无需额外下载——占位符已包含在插件中。
%bigspender_<number>% - 格式化给定的数字。示例:12300 -> 12.3k。默认最多保留小数点后三位。
%bigspender_<number>_<decimal_places>% - 让你定义最大小数位数。0 表示你将获得整数(12300 -> 12k)。
%bigspender_format_<number>% 和 %bigspender_format_<number>_<decimal_places>% - 与上述相同,只是明确指定了格式化操作。
%bigspender_parse_<formatted_number>% - 反向工作,接受一个格式化后的数字并返回原始数字。示例:12.3k -> 12300
所有参数都支持括号占位符,例如如果你有 rng 模块,你可以使用 %bigspender_{rng_random}%。其主要用途是格式化玩家的余额。
示例配置
如果你想更好地了解如何使用该插件,请查看 默认配置文件。
支持
如果你遇到问题,一个好的起点是在配置中启用“详细模式”并尝试运行有问题的命令。这将向控制台打印额外信息,帮助你找出问题所在。如果这没有帮助,欢迎在 Github Issues 上联系我。请务必发布你的完整配置和详细模式的输出,我会尽力提供帮助。
常见问题
问:它是如何工作的?
答: 它通过在命令到达处理该命令的插件之前读取并修改命令文本来工作。这是通过一个很少使用的事件 PlayerCommandPreprocessEvent 完成的。这种方法的好处是插件不需要了解实际命令的任何细节,只需知道要扩展哪些部分的数字缩写即可。
问:我如何在每个命令中替换所有缩写?
答: 你不能这样做。这会导致许多隐蔽的问题,因为有些参数看起来像可扩展的数字,但实际上并不是——也许它们是玩家名称或消息的一部分。更糟糕的是,玩家甚至不知道他们的命令为什么会出现混乱。通过明确定义哪些命令的哪些参数由 BigSpender 处理,你可以防止此类事情发生。
问:这对控制台有效吗?
答: 不,原因与上述类似。一些插件以控制台身份运行命令,而你绝对不想那样搞乱其他插件。这也可能构成安全风险。
改进事项
如果我有时间,以下是一些可以改进的地方:
- 实时重载配置的命令
- 使用缩写前缀而不是后缀的选项
- 自动解析命令别名和命名空间命令
- 可配置的事件优先级
- 更好地处理使用参数自动补全的命令

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
评论 0
登录后参与评分
还没有评论,来抢沙发吧