Skip to content
IzzelAliz edited this page Aug 6, 2017 · 2 revisions

我在 LuckPerms 里处理默认和默认组的方法可能是整个插件里最不受喜爱的特性了。最新我做了一些添加/调整,做了一些替代的特性,允许最大程度的控制像其他权限插件的方法,希望这会成为插件最好的方面,而不是最差的方面。 The way I handle defaults and default groups in LuckPerms is probably the most disliked feature in the whole plugin. Recently I've been adding some additional / alternative features to the plugin to allow a greater degree of control compared with what's seen in any of the other permission plugins out there, and hopefully making my approach people's favourite part of the plugin, not their least favourite.

从何开始

Where to start

这是我的想法。 So, here's my thinking.

你的服务器的用户可以分为两种。 Users on your server are likely to be split into two types.

  1. 基础玩家
  2. The standard player.
  3. 加入不同的组的玩家,或者有他们特别权限的玩家。
  4. Players who have been added to a different group, or given their own special permissions.

你不希望浪费宝贵的硬盘空间来存储第一种玩家,你只希望存储你的职员,或者有特殊等级的玩家。平凡的"成员"就只是平凡,没有必要存储他们的信息。 You don't want to waste precious disk space storing data about Player Type #1. You only want to store data about your staff members, and people with special ranks. Regular "members" are just that, regular. There's no need to store any data about them.

下一个问题是如何确定一个用户是"平凡的"或不是,想象一下情景。 The next issue I face is how to decide if a user is "regular" or not. Imagine the following situation.

  1. 默认的组设置为"默认",当玩家加入,他们被设置为"默认",并被保存。
  2. The default group is set to "default". When players join, they're given "default", and then get saved.
  3. 过了一会儿,你想将默认的组更改为"成员"。
  4. A little while down the line, you decide you want to change the default group to "member".
  5. 接着你的老的成员全部在"默认"组里,剩下的人都在"成员",这不好。
  6. You then have all of your old players in the "default" group, and everyone else in "member". Not good.

甚至我们没有"平凡"的用户,这个问题依然会出现。 Even if we don't save "regular" users, this issue can still happen.

  1. 默认组设置为"默认"
  2. The default group is set to "default".
  3. 你想给 "Notch" 一个特殊的 "essentials.fly" 权限,Notch 的权限被保存,标记为"默认组"的成员,有特殊的飞行权限。
  4. You want to give "Notch" a special "essentials.fly" permission. Notch's permissions are saved, indicating he's a member of the "default" group, and has the special fly permission.
  5. 接着你编辑了默认的组,所有的"平凡的"成员全部进入了新的组,但是 Notch 还是默认组的。
  6. You then edit the default group. All of your "regular" members get the new default group, but Notch still has default!

因为这个原因,我让默认的组不可配置,这让所有对我的事情都简单了 10 倍,这意味着我可以写有效率的存储系统,并且不用担心一些稀有的情况下服务器的管理员更改了默认组,但是,我知道这对一些人很反感。 For this reason, I made it so that the default group is not configurable. It makes things 10x easier for me. It means I can write efficient storage systems, with no chance of nasty race conditions occurring when a server admin decides to change the default group. However, I understand this is annoying for some people.

这对一些等级插件也有问题,如果你想要一个"主"组,并且分离"升级"组,你需要多于一个的默认组。 There's also issues with rankup plugins. If you want a "main" group, and then separate "level" ranks, you need to be able to grant more than one group by default.

这里是你的选项。 Here are your options.

继续使用默认组,但是只是更改"显示名"

Keep using the default group, but just modify the "display name"

我非常推荐这个做法,因为你继续使用默认组。 I strongly recommend for the reasons above that you keep using the default group.

如果你只是想简单的更改默认组的显示名,(比如在 Vault),我推荐你配置一个 group-name-rewrite 规则,通过添加这些到你的 config.yml/luckperms.conf 来实现。 If you want to simply change the visible name of the default group, (in Vault for example), I suggest you configure a group-name-rewrite rule, by adding the following to your config.yml/luckperms.conf file.

# Rewrites group names. The underlying name of the group does not change, just the output in commands / placeholders / Vault.
group-name-rewrite:
  default: Member

你也可以使用这个:https://github.com/lucko/LuckPerms/wiki/Primary-Groups You can also use this approach: https://github.com/lucko/LuckPerms/wiki/Primary-Groups

配置继承

Configure inheritance

这个选项意味着所有的用户都还在"默认"的组里,但是这个默认组作为父组,这样他就可以将配置继承给不同的组。 This option would mean that all users are still in the "default" group. However, a parent group is configured for default, so it can inherit permissions from a group with a different name.

/luckperms creategroup member
/luckperms group default parents add member

配置默认分配

Configure default assignments

如果你有更多的特殊需要,你可以使用这个选项,但是,这将否定我们在这个页面的第一节讨论的存储空间规划,所有的用户都会被存储,无论是"平凡的"成员还是不是。 If you have more specific needs, then you can use this option. However, be aware that it will negate the storage space optimisations discussed in the first section of this page. All users will be explicitly saved, whether they are a "regular" user or not.

注意:查看 "Default Assignments" 章节
Note: see the "Default Assignments" section of the config for more detail on this.

接下来的规则将会创建一个不同的默认的组。 The following rule will configure a different default group.

default-assignments:
  my-defaults-rule:
    if:
      has-true: <group.default>
    take:
      - group.default
    give:
      - group.member
    set-primary-group: member

放入以后,每次玩家登入时,插件会检测这个玩家是不是"默认"组的成员,如果是,插件将会把玩家从"默认"组移除,将他们添加至"成员"组,将他们的主组也设置为"成员"组。 Simply put, every time a user logs in, the plugin will check if they are a member of the "default" group. If they are, it will remove them from "default", add them to "member", and set their primary group to "member".

这个系统非常强力,允许你配置按你自己的需求而定的默认组,记住你可以将玩家添加至不止一个的"默认"组。 This system is very powerful, and allows you to configure defaults to your exact needs. Remember you could add users to more than one "default" group.