From de4c6b384c2c5236b180323001647818627d8c6b Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 12 Oct 2017 18:47:35 +0100 Subject: [PATCH] Export using the /lp alias --- .../me/lucko/luckperms/common/backup/Exporter.java | 14 +++++++------- .../me/lucko/luckperms/common/backup/Importer.java | 8 +++----- .../commands/impl/generic/meta/MetaInfo.java | 6 ++---- .../commands/impl/generic/parent/ParentInfo.java | 3 +-- .../impl/generic/permission/PermissionInfo.java | 3 +-- .../commands/impl/group/GroupListMembers.java | 3 +-- .../common/commands/impl/misc/SearchCommand.java | 3 +-- .../lucko/luckperms/common/node/NodeFactory.java | 2 +- 8 files changed, 17 insertions(+), 25 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java index 4d7873d51..ea7548f72 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java @@ -113,7 +113,7 @@ public class Exporter implements Runnable { for (Group group : groups) { 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()); 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, ""); log.logAllProgress("Exported {} groups so far.", groupCount.incrementAndGet()); @@ -144,7 +144,7 @@ public class Exporter implements Runnable { // Create the actual tracks first write(writer, "# Create tracks"); for (Track track : tracks) { - write(writer, "/luckperms createtrack " + track.getName()); + write(writer, "/lp createtrack " + track.getName()); } write(writer, ""); @@ -153,7 +153,7 @@ public class Exporter implements Runnable { for (Track track : plugin.getTrackManager().getAll().values()) { write(writer, "# Export track: " + track.getName()); for (String group : track.getGroups()) { - write(writer, "/luckperms track " + track.getName() + " append " + group); + write(writer, "/lp track " + track.getName() + " append " + group); } write(writer, ""); log.logAllProgress("Exported {} tracks so far.", trackCount.incrementAndGet()); @@ -230,15 +230,15 @@ public class Exporter implements Runnable { 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")) { - output.add("/luckperms user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue()); + output.add("/lp user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue()); } 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); diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java index 7f8336dd8..9b2a59767 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java @@ -72,10 +72,8 @@ public class Importer implements Runnable { .filter(s -> !s.isEmpty()) .filter(s -> !s.startsWith("#")) .filter(s -> !s.startsWith("//")) - .map(s -> s.startsWith("/") ? s.substring("/".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("luckperms ") ? s.substring("luckperms ".length()) : s) + .map(s -> s.startsWith("/luckperms ") ? s.substring("/luckperms ".length()) : s) + .map(s -> s.startsWith("/lp ") ? s.substring("/lp ".length()) : s) .collect(Collectors.toList()); this.toExecute = new ArrayList<>(); } @@ -91,7 +89,7 @@ public class Importer implements Runnable { ImportCommand cmd = new ImportCommand(commandManager, index, command); 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 } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java index ee9d99622..9f2aa014a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/meta/MetaInfo.java @@ -169,8 +169,7 @@ public class MetaInfo extends SharedSubCommand { ), '¥')); boolean group = !(holder instanceof User); - String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false); return component -> { component.hoverEvent(hoverEvent); @@ -194,8 +193,7 @@ public class MetaInfo extends SharedSubCommand { ), '¥')); boolean group = !(holder instanceof User); - String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false); return component -> { component.hoverEvent(hoverEvent); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java index ddfeafd4f..703543674 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentInfo.java @@ -129,8 +129,7 @@ public class ParentInfo extends SharedSubCommand { ), Constants.FORMAT_CHAR)); boolean group = !(holder instanceof User); - String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false); return component -> { component.hoverEvent(hoverEvent); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java index cbf2b25c1..384be3c37 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/permission/PermissionInfo.java @@ -190,8 +190,7 @@ public class PermissionInfo extends SharedSubCommand { ), '¥')); boolean group = !(holder instanceof User); - String command = NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, group ? holder.getObjectName() : holder.getFriendlyName(), group, false); return component -> { component.hoverEvent(hoverEvent); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java index dd1dcaa48..d48011f53 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupListMembers.java @@ -197,8 +197,7 @@ public class GroupListMembers extends SubCommand { "&7Click to remove this parent from " + holderName ), Constants.FORMAT_CHAR)); - String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false); return component -> { component.hoverEvent(hoverEvent); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java index 7910b917e..40bbe80d9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/SearchCommand.java @@ -196,8 +196,7 @@ public class SearchCommand extends SingleCommand { "&7Click to remove this node from " + holderName ), Constants.FORMAT_CHAR)); - String command = NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false) - .replace("/luckperms", "/" + label); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(perm.asNode(), holderName, group, false); return component -> { component.hoverEvent(hoverEvent); diff --git a/common/src/main/java/me/lucko/luckperms/common/node/NodeFactory.java b/common/src/main/java/me/lucko/luckperms/common/node/NodeFactory.java index 50681b4c5..847f0469f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/NodeFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/NodeFactory.java @@ -137,7 +137,7 @@ public class NodeFactory { 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(" "); + sb.append(group ? "group " : "user ").append(id).append(" "); if (node.isGroupNode()) { sb.append(node.isTemporary() ? (set ? "parent addtemp " : "parent removetemp ") : (set ? "parent add " : "parent remove "));