diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java index 663e2b6d..e439f7b0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/CommandManager.java @@ -48,7 +48,6 @@ import me.lucko.luckperms.common.commands.impl.track.DeleteTrack; import me.lucko.luckperms.common.commands.impl.track.ListTracks; import me.lucko.luckperms.common.commands.impl.track.TrackMainCommand; import me.lucko.luckperms.common.commands.impl.user.UserMainCommand; -import me.lucko.luckperms.common.commands.impl.usersbulkedit.UsersBulkEditMainCommand; import me.lucko.luckperms.common.commands.sender.Sender; import me.lucko.luckperms.common.commands.utils.ArgumentUtils; import me.lucko.luckperms.common.commands.utils.Util; @@ -99,7 +98,6 @@ public class CommandManager { .add(new ExportCommand()) .add(new ReloadConfigCommand()) .add(new MigrationMainCommand()) - .add(new UsersBulkEditMainCommand()) .add(new CreateGroup()) .add(new DeleteGroup()) .add(new ListGroups()) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupBulkChange.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupBulkChange.java deleted file mode 100644 index 68406f6d..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupBulkChange.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2016 Lucko (Luck) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.commands.impl.group; - -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.core.NodeFactory; -import me.lucko.luckperms.common.core.model.Group; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.utils.Predicates; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class GroupBulkChange extends SubCommand { - public GroupBulkChange() { - super("bulkchange", "Applies a bulk permission change to the group's permissions", Permission.GROUP_BULKCHANGE, Predicates.not(3), - Arg.list( - Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), - Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), - Arg.create("to", true, "the server/world to replace 'from' (can be 'null')") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) throws CommandException { - String type = args.get(0).toLowerCase(); - String from = args.get(1); - String to = args.get(2); - if (to.equals("null")) { - to = null; - } - - Set toAdd = new HashSet<>(); - Set toRemove = new HashSet<>(); - - if (!type.equals("world") && !type.equals("server")) { - Message.BULK_CHANGE_TYPE_ERROR.send(sender); - return CommandResult.FAILURE; - } - - Iterator iterator = group.getNodes().values().iterator(); - if (type.equals("world")) { - while (iterator.hasNext()) { - Node element = iterator.next(); - String world = element.getWorld().orElse("null"); - if (!world.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setWorld(to).build()); - } - } else { - while (iterator.hasNext()) { - Node element = iterator.next(); - String server = element.getServer().orElse("global"); - if (!server.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setServer(to).build()); - } - } - - toRemove.forEach(group::unsetPermission); - toAdd.forEach(group::setPermission); - - save(group, sender, plugin); - Message.BULK_CHANGE_SUCCESS.send(sender, toAdd.size()); - return CommandResult.SUCCESS; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java index f11bd128..e2403abc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/group/GroupMainCommand.java @@ -49,7 +49,6 @@ public class GroupMainCommand extends MainCommand { .add(new GroupListMembers()) .add(new GroupSetWeight()) .add(new HolderShowTracks<>(false)) - .add(new GroupBulkChange()) .add(new HolderClear<>(false)) .add(new GroupRename()) .add(new GroupClone()) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserBulkChange.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserBulkChange.java deleted file mode 100644 index 6040a18e..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserBulkChange.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016 Lucko (Luck) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.commands.impl.user; - -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.core.NodeFactory; -import me.lucko.luckperms.common.core.model.User; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.utils.Predicates; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class UserBulkChange extends SubCommand { - public UserBulkChange() { - super("bulkchange", "Applies a bulk permission change to the user's permissions", Permission.USER_BULKCHANGE, Predicates.not(3), - Arg.list( - Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), - Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), - Arg.create("to", true, "the server/world to replace 'from' (can be 'null')") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) throws CommandException { - String type = args.get(0).toLowerCase(); - String from = args.get(1); - String to = args.get(2); - if (to.equals("null")) { - to = null; - } - - Set toAdd = new HashSet<>(); - Set toRemove = new HashSet<>(); - - if (!type.equals("world") && !type.equals("server")) { - Message.BULK_CHANGE_TYPE_ERROR.send(sender); - return CommandResult.FAILURE; - } - - Iterator iterator = user.getNodes().values().iterator(); - if (type.equals("world")) { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (element.isGroupNode()) { - continue; - } - - String world = element.getWorld().orElse("null"); - if (!world.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setWorld(to).build()); - } - } else { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (element.isGroupNode()) { - continue; - } - - String server = element.getServer().orElse("global"); - if (!server.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setServer(to).build()); - } - } - - toRemove.forEach(user::unsetPermission); - toAdd.forEach(user::setPermission); - - save(user, sender, plugin); - Message.BULK_CHANGE_SUCCESS.send(sender, toAdd.size()); - return CommandResult.SUCCESS; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java index 2c5d149e..045d074b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserMainCommand.java @@ -53,7 +53,6 @@ public class UserMainCommand extends MainCommand { .add(new UserPromote()) .add(new UserDemote()) .add(new HolderShowTracks<>(true)) - .add(new UserBulkChange()) .add(new HolderClear<>(true)) .build() ); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditGroup.java deleted file mode 100644 index 12ded1ee..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditGroup.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2016 Lucko (Luck) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.commands.impl.usersbulkedit; - -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.core.NodeFactory; -import me.lucko.luckperms.common.core.model.User; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.storage.Storage; -import me.lucko.luckperms.common.utils.Predicates; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -public class BulkEditGroup extends SubCommand { - public BulkEditGroup() { - super("group", "Bulk edit group memberships", Permission.USER_BULKCHANGE, Predicates.not(4), - Arg.list( - Arg.create("group|null", true, "the group to edit ('null' to select and edit all groups)"), - Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), - Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), - Arg.create("to", true, "the server/world to replace 'from' (can be 'null')") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Storage storage, List args, String label) throws CommandException { - String group = args.get(0); - String type = args.get(1).toLowerCase(); - String from = args.get(2); - String to = args.get(3); - if (to.equals("null")) { - to = null; - } - - if (!type.equals("world") && !type.equals("server")) { - Message.BULK_CHANGE_TYPE_ERROR.send(sender); - return CommandResult.FAILURE; - } - - Set uuids = storage.getUniqueUsers().join(); - - for (UUID u : uuids) { - plugin.getStorage().loadUser(u, "null").join(); - User user = plugin.getUserManager().get(u); - if (user == null) { - continue; - } - - Set toAdd = new HashSet<>(); - Set toRemove = new HashSet<>(); - Iterator iterator = user.getNodes().values().iterator(); - if (type.equals("world")) { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (!element.isGroupNode()) { - continue; - } - - if (element.getGroupName().equals(user.getPrimaryGroup().getStoredValue())) { - if (!element.isServerSpecific() && !element.isWorldSpecific() && !element.isTemporary()) { - continue; - } - } - - if (!group.equals("null") && !element.getGroupName().equals(group)) { - continue; - } - - String world = element.getWorld().orElse("null"); - if (!world.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setWorld(to).build()); - } - } else { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (!element.isGroupNode()) { - continue; - } - - if (element.getGroupName().equals(user.getPrimaryGroup().getStoredValue())) { - continue; - } - - if (!group.equals("null") && !element.getGroupName().equals(group)) { - continue; - } - - String server = element.getServer().orElse("global"); - if (!server.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setServer(to).build()); - } - } - - toRemove.forEach(user::unsetPermission); - toAdd.forEach(user::setPermission); - - plugin.getStorage().saveUser(user); - plugin.getUserManager().cleanup(user); - } - - Message.BULK_CHANGE_SUCCESS.send(sender, uuids.size()); - return CommandResult.SUCCESS; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditPermission.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditPermission.java deleted file mode 100644 index f9a34a6e..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/BulkEditPermission.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2016 Lucko (Luck) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.commands.impl.usersbulkedit; - -import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandException; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.abstraction.SubCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.core.NodeFactory; -import me.lucko.luckperms.common.core.model.User; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.storage.Storage; -import me.lucko.luckperms.common.utils.Predicates; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -public class BulkEditPermission extends SubCommand { - public BulkEditPermission() { - super("permission", "Bulk edit permissions", Permission.USER_BULKCHANGE, Predicates.not(4), - Arg.list( - Arg.create("node|null", true, "the node to edit ('null' to select and edit all nodes)"), - Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), - Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), - Arg.create("to", true, "the server/world to replace 'from' (can be 'null')") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Storage storage, List args, String label) throws CommandException { - String node = args.get(0); - String type = args.get(1).toLowerCase(); - String from = args.get(2); - String to = args.get(3); - if (to.equals("null")) { - to = null; - } - - if (!type.equals("world") && !type.equals("server")) { - Message.BULK_CHANGE_TYPE_ERROR.send(sender); - return CommandResult.FAILURE; - } - - Set uuids = storage.getUniqueUsers().join(); - - for (UUID u : uuids) { - plugin.getStorage().loadUser(u, "null").join(); - User user = plugin.getUserManager().get(u); - if (user == null) { - continue; - } - - Set toAdd = new HashSet<>(); - Set toRemove = new HashSet<>(); - Iterator iterator = user.getNodes().values().iterator(); - if (type.equals("world")) { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (element.isGroupNode()) { - continue; - } - - if (!node.equals("null") && !element.getPermission().equals(node)) { - continue; - } - - String world = element.getWorld().orElse("null"); - if (!world.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setWorld(to).build()); - } - } else { - while (iterator.hasNext()) { - Node element = iterator.next(); - - if (element.isGroupNode()) { - continue; - } - - if (!node.equals("null") && !element.getPermission().equals(node)) { - continue; - } - - String server = element.getServer().orElse("global"); - if (!server.equals(from)) { - continue; - } - - toRemove.add(element); - toAdd.add(NodeFactory.builderFromExisting(element).setServer(to).build()); - } - } - - toRemove.forEach(user::unsetPermission); - toAdd.forEach(user::setPermission); - - plugin.getStorage().saveUser(user); - plugin.getUserManager().cleanup(user); - } - - Message.BULK_CHANGE_SUCCESS.send(sender, uuids.size()); - return CommandResult.SUCCESS; - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/UsersBulkEditMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/UsersBulkEditMainCommand.java deleted file mode 100644 index 3497b566..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/usersbulkedit/UsersBulkEditMainCommand.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2016 Lucko (Luck) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package me.lucko.luckperms.common.commands.impl.usersbulkedit; - -import com.google.common.collect.ImmutableList; - -import me.lucko.luckperms.common.commands.abstraction.Command; -import me.lucko.luckperms.common.commands.abstraction.MainCommand; -import me.lucko.luckperms.common.commands.sender.Sender; -import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import me.lucko.luckperms.common.storage.Storage; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -public class UsersBulkEditMainCommand extends MainCommand { - - public UsersBulkEditMainCommand() { - super("UsersBulkEdit", "User bulk edit commands", "/%s usersbulkedit", 1, ImmutableList.>builder() - .add(new BulkEditGroup()) - .add(new BulkEditPermission()) - .build() - ); - } - - @Override - protected Storage getTarget(String target, LuckPermsPlugin plugin, Sender sender) { - return plugin.getStorage(); - } - - @Override - protected void cleanup(Storage storage, LuckPermsPlugin plugin) { - - } - - @Override - protected List getTargets(LuckPermsPlugin plugin) { - return null; - } - - @Override - public List tabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - final List> subs = getChildren().get().stream() - .filter(s -> s.isAuthorized(sender)) - .collect(Collectors.toList()); - - if (args.size() <= 1) { - if (args.isEmpty() || args.get(0).equalsIgnoreCase("")) { - return subs.stream() - .map(m -> m.getName().toLowerCase()) - .collect(Collectors.toList()); - } - - return subs.stream() - .map(m -> m.getName().toLowerCase()) - .filter(s -> s.toLowerCase().startsWith(args.get(0).toLowerCase())) - .collect(Collectors.toList()); - } - - Optional> o = subs.stream() - .filter(s -> s.getName().equalsIgnoreCase(args.get(0))) - .limit(1) - .findAny(); - - if (!o.isPresent()) { - return Collections.emptyList(); - } - - return o.get().tabComplete(plugin, sender, args.subList(1, args.size())); - } -}