mirror of
https://github.com/lucko/LuckPerms.git
synced 2025-09-02 02:42:33 +02:00
Add config to control whether display names are returned by the Vault hook
This commit is contained in:
@@ -176,7 +176,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
|||||||
@Override
|
@Override
|
||||||
public String[] getGroups() {
|
public String[] getGroups() {
|
||||||
return this.plugin.getGroupManager().getAll().values().stream()
|
return this.plugin.getGroupManager().getAll().values().stream()
|
||||||
.map(Group::getPlainDisplayName)
|
.map(this::groupName)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,10 +252,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
|||||||
return user.getOwnNodes(NodeType.INHERITANCE, queryOptions).stream()
|
return user.getOwnNodes(NodeType.INHERITANCE, queryOptions).stream()
|
||||||
.map(n -> {
|
.map(n -> {
|
||||||
Group group = this.plugin.getGroupManager().getIfLoaded(n.getGroupName());
|
Group group = this.plugin.getGroupManager().getIfLoaded(n.getGroupName());
|
||||||
if (group != null) {
|
return group != null ? groupName(group) : n.getGroupName();
|
||||||
return group.getPlainDisplayName();
|
|
||||||
}
|
|
||||||
return n.getGroupName();
|
|
||||||
})
|
})
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
}
|
}
|
||||||
@@ -274,11 +271,7 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
|||||||
String value = metaData.getPrimaryGroup(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
String value = metaData.getPrimaryGroup(MetaCheckEvent.Origin.THIRD_PARTY_API);
|
||||||
|
|
||||||
Group group = getGroup(value);
|
Group group = getGroup(value);
|
||||||
if (group != null) {
|
return group != null ? groupName(group) : value;
|
||||||
return group.getPlainDisplayName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -328,6 +321,14 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission {
|
|||||||
return this.plugin.getGroupManager().getByDisplayName(name);
|
return this.plugin.getGroupManager().getByDisplayName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String groupName(Group group) {
|
||||||
|
if (this.plugin.getConfiguration().get(ConfigKeys.VAULT_GROUP_USE_DISPLAYNAMES)) {
|
||||||
|
return group.getPlainDisplayName();
|
||||||
|
} else {
|
||||||
|
return group.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkGroupExists(String group) {
|
private boolean checkGroupExists(String group) {
|
||||||
return this.plugin.getGroupManager().getByDisplayName(group) != null;
|
return this.plugin.getGroupManager().getByDisplayName(group) != null;
|
||||||
}
|
}
|
||||||
|
@@ -587,6 +587,12 @@ commands-allow-op: true
|
|||||||
# option to 'true.
|
# option to 'true.
|
||||||
vault-unsafe-lookups: false
|
vault-unsafe-lookups: false
|
||||||
|
|
||||||
|
# If LuckPerms should use the 'display name' of a group when returning groups in Vault API calls.
|
||||||
|
#
|
||||||
|
# - When this option is set to true, the display name of the group is returned.
|
||||||
|
# - When this option is set to false, the standard name/id of the group is returned.
|
||||||
|
vault-group-use-displaynames: true
|
||||||
|
|
||||||
# Controls which group LuckPerms should use for NPC players when handling Vault requests.
|
# Controls which group LuckPerms should use for NPC players when handling Vault requests.
|
||||||
#
|
#
|
||||||
# - As NPCs aren't actually real players, LuckPerms does not load any user data for them. This
|
# - As NPCs aren't actually real players, LuckPerms does not load any user data for them. This
|
||||||
|
@@ -446,6 +446,11 @@ public final class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<Boolean> VAULT_UNSAFE_LOOKUPS = booleanKey("vault-unsafe-lookups", false);
|
public static final ConfigKey<Boolean> VAULT_UNSAFE_LOOKUPS = booleanKey("vault-unsafe-lookups", false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If LuckPerms should use the 'display name' of a group when returning groups in Vault API calls.
|
||||||
|
*/
|
||||||
|
public static final ConfigKey<Boolean> VAULT_GROUP_USE_DISPLAYNAMES = booleanKey("vault-group-use-displaynames", true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls which group LuckPerms should use for NPC players when handling Vault requests
|
* Controls which group LuckPerms should use for NPC players when handling Vault requests
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user