Export using the /lp alias

This commit is contained in:
Luck 2017-10-12 18:47:35 +01:00
parent 6dec1ba8af
commit de4c6b384c
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
8 changed files with 17 additions and 25 deletions

View File

@ -113,7 +113,7 @@ public class Exporter implements Runnable {
for (Group group : groups) { for (Group group : groups) {
if (!group.getName().equals("default")) { if (!group.getName().equals("default")) {
write(writer, "/luckperms creategroup " + group.getName()); write(writer, "/lp creategroup " + group.getName());
} }
} }
@ -124,7 +124,7 @@ public class Exporter implements Runnable {
write(writer, "# Export group: " + group.getName()); write(writer, "# Export group: " + group.getName());
for (Node node : group.getEnduringNodes().values()) { for (Node node : group.getEnduringNodes().values()) {
write(writer, NodeFactory.nodeAsCommand(node, group.getName(), true, true)); write(writer, "/lp " + NodeFactory.nodeAsCommand(node, group.getName(), true, true));
} }
write(writer, ""); write(writer, "");
log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet()); log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet());
@ -144,7 +144,7 @@ public class Exporter implements Runnable {
// Create the actual tracks first // Create the actual tracks first
write(writer, "# Create tracks"); write(writer, "# Create tracks");
for (Track track : tracks) { for (Track track : tracks) {
write(writer, "/luckperms createtrack " + track.getName()); write(writer, "/lp createtrack " + track.getName());
} }
write(writer, ""); write(writer, "");
@ -153,7 +153,7 @@ public class Exporter implements Runnable {
for (Track track : plugin.getTrackManager().getAll().values()) { for (Track track : plugin.getTrackManager().getAll().values()) {
write(writer, "# Export track: " + track.getName()); write(writer, "# Export track: " + track.getName());
for (String group : track.getGroups()) { for (String group : track.getGroups()) {
write(writer, "/luckperms track " + track.getName() + " append " + group); write(writer, "/lp track " + track.getName() + " append " + group);
} }
write(writer, ""); write(writer, "");
log.logAllProgress("Exported {} tracks so far.", trackCount.incrementAndGet()); log.logAllProgress("Exported {} tracks so far.", trackCount.incrementAndGet());
@ -230,15 +230,15 @@ public class Exporter implements Runnable {
continue; continue;
} }
output.add(NodeFactory.nodeAsCommand(node, user.getUuid().toString(), false, true)); output.add("/lp" + NodeFactory.nodeAsCommand(node, user.getUuid().toString(), false, true));
} }
if (!user.getPrimaryGroup().getStoredValue().equalsIgnoreCase("default")) { if (!user.getPrimaryGroup().getStoredValue().equalsIgnoreCase("default")) {
output.add("/luckperms user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue()); output.add("/lp user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue());
} }
if (!inDefault) { if (!inDefault) {
output.add("/luckperms user " + user.getUuid().toString() + " parent remove default"); output.add("/lp user " + user.getUuid().toString() + " parent remove default");
} }
plugin.getUserManager().cleanup(user); plugin.getUserManager().cleanup(user);

View File

@ -72,10 +72,8 @@ public class Importer implements Runnable {
.filter(s -> !s.isEmpty()) .filter(s -> !s.isEmpty())
.filter(s -> !s.startsWith("#")) .filter(s -> !s.startsWith("#"))
.filter(s -> !s.startsWith("//")) .filter(s -> !s.startsWith("//"))
.map(s -> s.startsWith("/") ? s.substring("/".length()) : s) .map(s -> s.startsWith("/luckperms ") ? s.substring("/luckperms ".length()) : s)
.map(s -> s.startsWith("perms ") ? s.substring("perms ".length()) : s) .map(s -> s.startsWith("/lp ") ? s.substring("/lp ".length()) : s)
.map(s -> s.startsWith("lp ") ? s.substring("lp ".length()) : s)
.map(s -> s.startsWith("luckperms ") ? s.substring("luckperms ".length()) : s)
.collect(Collectors.toList()); .collect(Collectors.toList());
this.toExecute = new ArrayList<>(); this.toExecute = new ArrayList<>();
} }
@ -91,7 +89,7 @@ public class Importer implements Runnable {
ImportCommand cmd = new ImportCommand(commandManager, index, command); ImportCommand cmd = new ImportCommand(commandManager, index, command);
toExecute.add(cmd); toExecute.add(cmd);
if (cmd.getCommand().startsWith("creategroup ") || cmd.getCommand().startsWith("createtrack")) { if (cmd.getCommand().startsWith("creategroup ") || cmd.getCommand().startsWith("createtrack ")) {
cmd.process(); // process immediately cmd.process(); // process immediately
} }

View File

@ -169,8 +169,7 @@ public class MetaInfo extends SharedSubCommand {
), '¥')); ), '¥'));
boolean group = !(holder instanceof User); boolean group = !(holder instanceof User);
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);
@ -194,8 +193,7 @@ public class MetaInfo extends SharedSubCommand {
), '¥')); ), '¥'));
boolean group = !(holder instanceof User); boolean group = !(holder instanceof User);
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);

View File

@ -129,8 +129,7 @@ public class ParentInfo extends SharedSubCommand {
), Constants.FORMAT_CHAR)); ), Constants.FORMAT_CHAR));
boolean group = !(holder instanceof User); boolean group = !(holder instanceof User);
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);

View File

@ -190,8 +190,7 @@ public class PermissionInfo extends SharedSubCommand {
), '¥')); ), '¥'));
boolean group = !(holder instanceof User); boolean group = !(holder instanceof User);
String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);

View File

@ -197,8 +197,7 @@ public class GroupListMembers extends SubCommand<Group> {
"&7Click to remove this parent from " + holderName "&7Click to remove this parent from " + holderName
), Constants.FORMAT_CHAR)); ), Constants.FORMAT_CHAR));
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);

View File

@ -196,8 +196,7 @@ public class SearchCommand extends SingleCommand {
"&7Click to remove this node from " + holderName "&7Click to remove this node from " + holderName
), Constants.FORMAT_CHAR)); ), Constants.FORMAT_CHAR));
String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false) String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false);
.replace("/luckperms", "/" + label);
return component -> { return component -> {
component.hoverEvent(hoverEvent); component.hoverEvent(hoverEvent);

View File

@ -137,7 +137,7 @@ public class NodeFactory {
public static String nodeAsCommand(Node node, String id, boolean group, boolean set) { public static String nodeAsCommand(Node node, String id, boolean group, boolean set) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("/luckperms ").append(group ? "group " : "user ").append(id).append(" "); sb.append(group ? "group " : "user ").append(id).append(" ");
if (node.isGroupNode()) { if (node.isGroupNode()) {
sb.append(node.isTemporary() ? (set ? "parent addtemp " : "parent removetemp ") : (set ? "parent add " : "parent remove ")); sb.append(node.isTemporary() ? (set ? "parent addtemp " : "parent removetemp ") : (set ? "parent add " : "parent remove "));