Skip to content

LuckPerms Command - #456

Open
MC-Samuel wants to merge 1 commit into
DenizenScript:masterfrom
MC-Samuel:feature/luckperms_command
Open

LuckPerms Command#456
MC-Samuel wants to merge 1 commit into
DenizenScript:masterfrom
MC-Samuel:feature/luckperms_command

Conversation

@MC-Samuel

Copy link
Copy Markdown
Contributor
  • Adds a command to adjust permissions specifically for LuckPerms. Vault's permission editing doesn't have API that would make negatory or temporary permissions clean, so this was the cleanest more useful option (requested at https://discord.com/channels/315163488085475337/1306569854299410443).
  • Adds a DurationTag tag for how long a PlayerTag has a specific permission. If the player does not have the permission set specifically on them, this will check to see if there are any wildcard permissions that contain the permission. If not, will return null. Permissions from inherited sources (i.e. groups) are not included in this tag and will have to be checked separately.
  • Adds a DurationTag tag for how long a LuckPermsGroupTag has a specific permission. If the group does not have the permission set specifically on it, this will check to see if there are any wildcard permissions that contain the permission. If not, will return null. Permissions from inherited sources (i.e. parent groups) are not included in this tag and will have to be checked separately.

Given the command gives the ability to set temporary permissions, having a tag to get their duration seems like it would be helpful to those using it.


public LuckPermsCommand() {
setName("luckperms");
setSyntax("luckperms [{set}/unset] [user:<player>/group:<group>] [permission] (state:{true}/false) (duration:<duration>) (contexts:<map>)");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably make this take users and groups as ListTag rather than only one value.
Which would allow to do easier things like this rather than foreach:

- luckperms set users:<server.online_players> bonus duration:2h

}
Node node = nodeBuilder.build();
switch (action) {
case SET: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could use that new switch without needing to break it

Comment on lines +172 to +188
for (PermissionNode node : object.getGroup().getNodes(NodeType.PERMISSION)) {
if (node.getKey().equalsIgnoreCase(permission)) {
bestNode = node;
break;
}
else if (node.isWildcard() && node.getWildcardLevel().isPresent()) {
int size = node.getKey().substring(0, node.getKey().length() - 1).length();
if (permission.length() < size || !permission.substring(0, size).equalsIgnoreCase(node.getKey().substring(0, size))) {
continue;
}
if (node.getWildcardLevel().getAsInt() > wildcardLevel) {
bestNode = node;
wildcardLevel = node.getWildcardLevel().getAsInt();
}
}
}
return bestNode != null ? new DurationTag(bestNode.getExpiryDuration() != null ? (int) bestNode.getExpiryDuration().getSeconds() : 0) : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could probably extract this to a method since its the same for both tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants