mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Refactor group name parsing in commands
This commit is contained in:
parent
8771d4c5e5
commit
308356de80
@ -45,19 +45,15 @@ public final class StorageAssistant {
|
||||
private StorageAssistant() {}
|
||||
|
||||
public static Group loadGroup(String target, Sender sender, LuckPermsPlugin plugin, boolean auditTemporary) {
|
||||
Group group = plugin.getStorage().loadGroup(target).join().orElse(null);
|
||||
Group group = plugin.getGroupManager().getByDisplayName(target);
|
||||
if (group != null) {
|
||||
target = group.getName();
|
||||
}
|
||||
|
||||
group = plugin.getStorage().loadGroup(target).join().orElse(null);
|
||||
if (group == null) {
|
||||
// failed to load, but it might be a display name.
|
||||
group = plugin.getGroupManager().getByDisplayName(target);
|
||||
|
||||
// nope, not a display name
|
||||
if (group == null) {
|
||||
Message.GROUP_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
|
||||
// it was a display name, we need to reload
|
||||
plugin.getStorage().loadGroup(group.getName()).join();
|
||||
Message.GROUP_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (auditTemporary) {
|
||||
|
@ -80,7 +80,12 @@ public class GroupParentCommand extends ParentCommand<Group, String> {
|
||||
|
||||
@Override
|
||||
protected String parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
return target.toLowerCase();
|
||||
Group group = plugin.getGroupManager().getByDisplayName(target);
|
||||
if (group != null) {
|
||||
return group.getName();
|
||||
} else {
|
||||
return target.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user