mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-20 16:59:41 +00:00
Refactor group name parsing in commands
This commit is contained in:
2 files changed
+14
-13
No files matched your search
@@ -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) {
|
||||
|
||||
+6
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user