简介:
你是否需要一条命令,能够针对不同的权限组执行多种不同的操作?
我确实有这样的需求,但未能找到任何能实现该功能的插件,因此我决定自己开发一个。
Group Command 允许用户运行单个命令,并根据其所属的权限组触发不同的操作。所有命令均通过 /gcmd <子命令> 执行,其中子命令在 config.yml 中定义。
用途:
那么,究竟在什么情况下会用到这样的功能呢?在我管理的服务器上,我曾遇到两个非常具体的问题,都通过这个插件得到了解决。
我们之前使用另一个插件来自动奖励推荐新玩家加入服务器的老玩家,但希望将一种特殊等级作为奖励发放。Group Command 使我们能够将推荐插件设置为运行 config 中定义的命令,从而提升那些低于该等级的用户(例如成员)的等级,但不“提升”如 VIP 等高等级用户的等级,而是改为给予他们一些物品。
另一个用途是自动化通过 Buycraft 进行 VIP 等级升级的操作。在购买了相应的套餐后,Buycraft 会运行一组 Group Command 并将用户提升一个等级。
它也可以从控制台执行所需的命令,因此对于让用户仅访问特定形式的命令而非整个命令非常有用(如下例所示,新手和建造者可以踢自己,但不能踢其他人)。
使用方法:
首次加载时,插件会在 plugins 文件夹的子文件夹中生成一个默认的 config.yml,内容如下:
#Config layout:
#
#subcommand:
# set1:
# groups:
# - group1
# - group2
# commands:
# - somecommand
# - somecommand
#
# Commands are run like: /gcmd <subcommand>
#
# Below is a sample command group that will kick noobs that think they
# can op themselves but will actually op staff groups.
#
# Note that @p will be replaced by the player executing the command
# unless otherwise specified by a player with op (or the console).
#
# /gcmd list will list all the sub commands available
op:
set1:
groups:
- noob
- builder
commands:
- kick @p You can't op yourself idiot!
set2:
groups:
- owner
- admin
commands:
- op @p
你可以添加任意数量的子命令、集合、组和命令,只要保持格式一致,它们就能正常工作。
如果玩家(无论是明确指定的,还是未指定玩家时直接运行命令的玩家)属于对应集合 'groups' 中列出的任何一组,那么 'commands:' 中设置的所有命令都将被执行。集合和子命令可以随意命名。
命令:
/gcmd <子命令> [玩家] - 运行配置文件中定义的子命令。只有控制台或拥有 OP 权限的玩家才能指定玩家。
/gcreload - 从配置文件重新加载命令。
权限:
groupcommand.gcmd - 授予对 /gcmd 命令的访问权限
groupcommand.reload - 授予对 /gcreload 的访问权限,以便加载配置文件的更改
依赖项:
Vault,用于读取玩家的权限组。
Intro:
Do you need one command that can do multiple different things for different permission groups?
I certainly did, but was unable to find any plugin that could do that, so I decided to create my very own.
Group Command will allow users to run a single command and have different things happen depending on their permission group. All the commands are run from /gcmd <subcommand> with the sub command being defined in the config.yml.
Purpose:
So what on earth would you ever use something like this for? Well, there were two very specific issues I ran into on the server I run which were both solved with this plugin.
We had been using another plugin to automatically reward people that referred other players to the server, but wanted to add a special rank as a reward. Group Command allowed us to set the referral plugin to run a command defined in the config to promote users that were below that rank (members, for example) but not "promote" the higher ranks like vip, and to instead give them some items.
Another use was to automate vip rank upgrades from buycraft. Upon buying the appropriate package, buycraft would run a group command set and promote the user up by one rank.
It runs the desired command from the console as well, so it could be useful for giving users access to a specific form of a command instead of the whole command (like the example below where noobs and builders can kick themselves, but not others).
Usage:
Upon first loading, the plugin will generate a default config.yml in it's subfolder inside the plugins folder with the following:
#Config layout:
#
#subcommand:
# set1:
# groups:
# - group1
# - group2
# commands:
# - somecommand
# - somecommand
#
# Commands are run like: /gcmd <subcommand>
#
# Below is a sample command group that will kick noobs that think they
# can op themselves but will actually op staff groups.
#
# Note that @p will be replaced by the player executing the command
# unless otherwise specified by a player with op (or the console).
#
# /gcmd list will list all the sub commands available
op:
set1:
groups:
- noob
- builder
commands:
- kick @p You can't op yourself idiot!
set2:
groups:
- owner
- admin
commands:
- op @p
You can add as many sub commands, sets, groups, and commands as you want, so long as you keep the format the same, they should work fine.
All the commands set in 'commands:' will be run if the player (either specifically defined, or running the command if no player is specified) is in any of the groups listed in 'groups' for the corresponding set. Sets and sub commands can be named whatever you want.
Commands:
/gcmd <subcommand> [player] - runs the sub command defined in the config. Player can only be defined by the console, or an OP.
/gcreload - reloads commands from the config.
Permissions:
groupcommand.gcmd - grants access to the /gcmd command
groupcommand.reload - grants access to /gcreload to load changes to the config
Dependencies:
Vault so it can read a player's group.
评论 0
登录后参与评分
还没有评论,来抢沙发吧