mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-01 14:07:56 +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() {}
|
private StorageAssistant() {}
|
||||||
|
|
||||||
public static Group loadGroup(String target, Sender sender, LuckPermsPlugin plugin, boolean auditTemporary) {
|
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) {
|
if (group == null) {
|
||||||
// failed to load, but it might be a display name.
|
Message.GROUP_NOT_FOUND.send(sender, target);
|
||||||
group = plugin.getGroupManager().getByDisplayName(target);
|
return null;
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auditTemporary) {
|
if (auditTemporary) {
|
||||||
|
@ -80,7 +80,12 @@ public class GroupParentCommand extends ParentCommand<Group, String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String parseTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user