mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-08-31 00:20:34 +02:00
Fix generating unset commands for temporary nodes
This commit is contained in:
parent
b12ce943f7
commit
0befa6a491
|
@ -169,12 +169,8 @@ public class MetaInfo extends SharedSubCommand {
|
|||
), '¥'));
|
||||
|
||||
boolean group = !(holder instanceof User);
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
@ -198,12 +194,8 @@ public class MetaInfo extends SharedSubCommand {
|
|||
), '¥'));
|
||||
|
||||
boolean group = !(holder instanceof User);
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
|
|
@ -128,12 +128,8 @@ public class ParentInfo extends SharedSubCommand {
|
|||
), Constants.FORMAT_CHAR));
|
||||
|
||||
boolean group = !(holder instanceof User);
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
|
|
@ -159,12 +159,8 @@ public class PermissionInfo extends SharedSubCommand {
|
|||
), '¥'));
|
||||
|
||||
boolean group = !(holder instanceof User);
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
|
|
@ -196,12 +196,8 @@ public class GroupListMembers extends SubCommand<Group> {
|
|||
"&7Click to remove this parent from " + holderName
|
||||
), Constants.FORMAT_CHAR));
|
||||
|
||||
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
|
|
@ -195,12 +195,8 @@ public class SearchCommand extends SingleCommand {
|
|||
"&7Click to remove this node from " + holderName
|
||||
), Constants.FORMAT_CHAR));
|
||||
|
||||
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group)
|
||||
.replace("/luckperms", "/" + label)
|
||||
.replace("permission set", "permission unset")
|
||||
.replace("parent add", "parent remove")
|
||||
.replace(" true", "")
|
||||
.replace(" false", "");
|
||||
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false)
|
||||
.replace("/luckperms", "/" + label);
|
||||
|
||||
return component -> {
|
||||
component.hoverEvent(hoverEvent);
|
||||
|
|
|
@ -135,33 +135,34 @@ public class NodeFactory {
|
|||
return new NodeBuilder("suffix." + priority + "." + MetaUtils.escapeCharacters(suffix));
|
||||
}
|
||||
|
||||
public static String nodeAsCommand(Node node, String id, boolean group) {
|
||||
public static String nodeAsCommand(Node node, String id, boolean group, boolean set) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("/luckperms ").append(group ? "group " : "user ").append(id).append(" ");
|
||||
|
||||
if (node.isGroupNode()) {
|
||||
if (node.isTemporary()) {
|
||||
sb.append("parent addtemp ");
|
||||
sb.append(set ? "parent addtemp " : "parent removetemp ");
|
||||
sb.append(node.getGroupName());
|
||||
sb.append(" ").append(node.getExpiryUnixTime());
|
||||
} else {
|
||||
sb.append("parent add ");
|
||||
sb.append(set ? "parent add " : "parent remove ");
|
||||
sb.append(node.getGroupName());
|
||||
}
|
||||
|
||||
return appendContextToCommand(sb, node).toString();
|
||||
}
|
||||
|
||||
sb.append(node.isTemporary() ? "permission settemp " : "permission set ");
|
||||
sb.append(node.isTemporary() ? (set ? "permission settemp " : "permission unsettemp ") : (set ? "permission set " : "permission unset "));
|
||||
if (node.getPermission().contains(" ")) {
|
||||
sb.append("\"").append(node.getPermission()).append("\"");
|
||||
} else {
|
||||
sb.append(node.getPermission());
|
||||
}
|
||||
sb.append(" ").append(node.getValue());
|
||||
if (set) {
|
||||
sb.append(" ").append(node.getValue());
|
||||
|
||||
if (node.isTemporary()) {
|
||||
sb.append(" ").append(node.getExpiryUnixTime());
|
||||
if (node.isTemporary()) {
|
||||
sb.append(" ").append(node.getExpiryUnixTime());
|
||||
}
|
||||
}
|
||||
|
||||
return appendContextToCommand(sb, node).toString();
|
||||
|
|
|
@ -132,7 +132,7 @@ public class Exporter implements Runnable {
|
|||
.forEach(group -> {
|
||||
write(writer, "# Export group: " + group.getName());
|
||||
for (Node node : group.getNodes().values()) {
|
||||
write(writer, NodeFactory.nodeAsCommand(node, group.getName(), true));
|
||||
write(writer, NodeFactory.nodeAsCommand(node, group.getName(), true, true));
|
||||
}
|
||||
write(writer, "");
|
||||
log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet());
|
||||
|
@ -240,7 +240,7 @@ public class Exporter implements Runnable {
|
|||
continue;
|
||||
}
|
||||
|
||||
output.add(NodeFactory.nodeAsCommand(node, user.getUuid().toString(), false));
|
||||
output.add(NodeFactory.nodeAsCommand(node, user.getUuid().toString(), false, true));
|
||||
}
|
||||
|
||||
if (!user.getPrimaryGroup().getStoredValue().equalsIgnoreCase("default")) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user