mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-03-02 11:31:13 +01:00
Correctly export meta/prefix/suffix nodes to command strings
This commit is contained in:
parent
ed15e2838d
commit
046202719a
@ -9,13 +9,14 @@ import javax.annotation.Nonnull;
|
||||
/**
|
||||
* A special instance of {@link Contexts}, which when passed to:
|
||||
*
|
||||
* <p><ul>
|
||||
* <li>{@link UserData#getPermissionData(Contexts)}</li>
|
||||
* <li>{@link UserData#getMetaData(Contexts)}</li>
|
||||
* <li>{@link UserData#getMetaData(MetaContexts)}</li>
|
||||
* </ul></p>
|
||||
* <p></p>
|
||||
* <ul>
|
||||
* <li>{@link UserData#getPermissionData(Contexts)}</li>
|
||||
* <li>{@link UserData#getMetaData(Contexts)}</li>
|
||||
* <li>{@link UserData#getMetaData(MetaContexts)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>will always satisfy all contextual requirements.</p>
|
||||
* <p>... will always satisfy all contextual requirements.</p>
|
||||
*
|
||||
* <p>This effectively allows you to do lookups which ignore context.</p>
|
||||
*
|
||||
|
@ -151,6 +151,50 @@ public class NodeFactory {
|
||||
return appendContextToCommand(sb, node).toString();
|
||||
}
|
||||
|
||||
if (node.getValue() && (node.isPrefix() || node.isSuffix())) {
|
||||
ChatMetaType type = node.isPrefix() ? ChatMetaType.PREFIX : ChatMetaType.SUFFIX;
|
||||
String typeName = type.name().toLowerCase();
|
||||
|
||||
|
||||
sb.append(node.isTemporary() ? (set ? "meta addtemp" + typeName + " " : "meta removetemp" + typeName + " ") : (set ? "meta add" + typeName + " " : "meta remove" + typeName + " "));
|
||||
sb.append(type.getEntry(node).getKey()).append(" ");
|
||||
|
||||
if (type.getEntry(node).getValue().contains(" ")) {
|
||||
sb.append("\"").append(type.getEntry(node).getValue()).append("\"");
|
||||
} else {
|
||||
sb.append(type.getEntry(node).getValue());
|
||||
}
|
||||
if (node.isTemporary()) {
|
||||
sb.append(" ").append(node.getExpiryUnixTime());
|
||||
}
|
||||
|
||||
return appendContextToCommand(sb, node).toString();
|
||||
}
|
||||
|
||||
if (node.getValue() && node.isMeta()) {
|
||||
sb.append(node.isTemporary() ? (set ? "meta settemp " : "meta unsettemp ") : (set ? "meta set " : "meta unset "));
|
||||
|
||||
if (node.getMeta().getKey().contains(" ")) {
|
||||
sb.append("\"").append(node.getMeta().getKey()).append("\"");
|
||||
} else {
|
||||
sb.append(node.getMeta().getKey());
|
||||
}
|
||||
|
||||
sb.append(" ");
|
||||
|
||||
if (node.getMeta().getValue().contains(" ")) {
|
||||
sb.append("\"").append(node.getMeta().getValue()).append("\"");
|
||||
} else {
|
||||
sb.append(node.getMeta().getValue());
|
||||
}
|
||||
|
||||
if (node.isTemporary()) {
|
||||
sb.append(" ").append(node.getExpiryUnixTime());
|
||||
}
|
||||
|
||||
return appendContextToCommand(sb, node).toString();
|
||||
}
|
||||
|
||||
sb.append(node.isTemporary() ? (set ? "permission settemp " : "permission unsettemp ") : (set ? "permission set " : "permission unset "));
|
||||
if (node.getPermission().contains(" ")) {
|
||||
sb.append("\"").append(node.getPermission()).append("\"");
|
||||
|
Loading…
Reference in New Issue
Block a user