From 045539c75245e0f52e0974302ddf98a7cc8e16bb Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 14 Oct 2016 19:19:57 +0100 Subject: [PATCH] refactor inheritance commands --- .../bukkit/vault/VaultPermissionHook.java | 8 +- .../common/api/internal/UserLink.java | 30 +-- .../luckperms/common/commands/SubCommand.java | 12 +- .../SecondaryMainCommand.java} | 75 ++++--- .../SecondarySubCommand.java} | 32 ++- .../commands/generic/meta/CommandMeta.java | 45 +++++ .../meta}/MetaAddPrefix.java | 6 +- .../meta}/MetaAddSuffix.java | 6 +- .../meta}/MetaAddTempPrefix.java | 6 +- .../meta}/MetaAddTempSuffix.java | 6 +- .../meta}/MetaClear.java | 6 +- .../meta}/MetaInfo.java | 6 +- .../meta}/MetaRemovePrefix.java | 6 +- .../meta}/MetaRemoveSuffix.java | 6 +- .../meta}/MetaRemoveTempPrefix.java | 6 +- .../meta}/MetaRemoveTempSuffix.java | 6 +- .../parent/CommandParent.java} | 32 ++- .../parent/ParentAdd.java} | 55 ++--- .../parent/ParentAddTemp.java} | 53 ++--- .../parent/ParentInfo.java} | 24 ++- .../parent/ParentRemove.java} | 59 ++++-- .../parent/ParentRemoveTemp.java} | 57 +++--- .../commands/group/GroupMainCommand.java | 11 +- .../group/subcommands/GroupSetInherit.java | 111 ---------- .../subcommands/GroupSetTempInherit.java | 132 ------------ .../group/subcommands/GroupUnsetInherit.java | 100 --------- .../subcommands/GroupUnsetTempInherit.java | 100 --------- .../common/commands/user/UserMainCommand.java | 11 +- .../commands/user/subcommands/UserDemote.java | 2 +- .../user/subcommands/UserPromote.java | 2 +- .../user/subcommands/UserSetPrimaryGroup.java | 4 +- .../subcommands/BulkEditGroup.java | 1 - .../luckperms/common/constants/Message.java | 52 ++--- .../common/core/PermissionHolder.java | 96 ++++++++- .../lucko/luckperms/common/groups/Group.java | 191 ------------------ .../me/lucko/luckperms/common/users/User.java | 168 --------------- 36 files changed, 438 insertions(+), 1085 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/MetaCommands.java => generic/SecondaryMainCommand.java} (56%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/MetaSubCommand.java => generic/SecondarySubCommand.java} (82%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaAddPrefix.java (96%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaAddSuffix.java (96%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaAddTempPrefix.java (96%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaAddTempSuffix.java (96%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaClear.java (94%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaInfo.java (95%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaRemovePrefix.java (97%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaRemoveSuffix.java (97%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaRemoveTempPrefix.java (97%) rename common/src/main/java/me/lucko/luckperms/common/commands/{meta/subcommands => generic/meta}/MetaRemoveTempSuffix.java (97%) rename common/src/main/java/me/lucko/luckperms/common/commands/{user/subcommands/UserListGroups.java => generic/parent/CommandParent.java} (54%) rename common/src/main/java/me/lucko/luckperms/common/commands/{user/subcommands/UserAddGroup.java => generic/parent/ParentAdd.java} (63%) rename common/src/main/java/me/lucko/luckperms/common/commands/{user/subcommands/UserAddTempGroup.java => generic/parent/ParentAddTemp.java} (66%) rename common/src/main/java/me/lucko/luckperms/common/commands/{group/subcommands/GroupListParents.java => generic/parent/ParentInfo.java} (60%) rename common/src/main/java/me/lucko/luckperms/common/commands/{user/subcommands/UserRemoveTempGroup.java => generic/parent/ParentRemove.java} (57%) rename common/src/main/java/me/lucko/luckperms/common/commands/{user/subcommands/UserRemoveGroup.java => generic/parent/ParentRemoveTemp.java} (60%) delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetInherit.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetTempInherit.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetInherit.java delete mode 100644 common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetTempInherit.java diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java index a981160c..c10b95ce 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/VaultPermissionHook.java @@ -258,9 +258,9 @@ public class VaultPermissionHook extends Permission { scheduler.scheduleTask(() -> { try { if (finalWorld != null && !finalWorld.equals("")) { - user.addGroup(group, server, finalWorld); + user.setInheritGroup(group, server, finalWorld); } else { - user.addGroup(group, server); + user.setInheritGroup(group, server); } } catch (ObjectAlreadyHasException ignored) {} save(user); @@ -282,9 +282,9 @@ public class VaultPermissionHook extends Permission { scheduler.scheduleTask(() -> { try { if (finalWorld != null && !finalWorld.equals("")) { - user.removeGroup(group, server, finalWorld); + user.unsetInheritGroup(group, server, finalWorld); } else { - user.removeGroup(group, server); + user.unsetInheritGroup(group, server); } } catch (ObjectLacksException ignored) {} save(user); diff --git a/common/src/main/java/me/lucko/luckperms/common/api/internal/UserLink.java b/common/src/main/java/me/lucko/luckperms/common/api/internal/UserLink.java index cd5f0220..c81ea224 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/internal/UserLink.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/internal/UserLink.java @@ -85,91 +85,91 @@ public class UserLink extends PermissionHolderLink implements User { @Override public boolean isInGroup(@NonNull Group group) { checkGroup(group); - return master.isInGroup(((GroupLink) group).getMaster()); + return master.inheritsGroup(((GroupLink) group).getMaster()); } @Override public boolean isInGroup(@NonNull Group group, @NonNull String server) { checkGroup(group); - return master.isInGroup(((GroupLink) group).getMaster(), server); + return master.inheritsGroup(((GroupLink) group).getMaster(), server); } @Override public boolean isInGroup(@NonNull Group group, @NonNull String server, @NonNull String world) { checkGroup(group); - return master.isInGroup(((GroupLink) group).getMaster(), server, world); + return master.inheritsGroup(((GroupLink) group).getMaster(), server, world); } @Override public void addGroup(@NonNull Group group) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster()); + master.setInheritGroup(((GroupLink) group).getMaster()); } @Override public void addGroup(@NonNull Group group, @NonNull String server) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster(), checkServer(server)); + master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); } @Override public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster(), checkServer(server), world); + master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); } @Override public void addGroup(@NonNull Group group, @NonNull long expireAt) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster(), checkTime(expireAt)); + master.setInheritGroup(((GroupLink) group).getMaster(), checkTime(expireAt)); } @Override public void addGroup(@NonNull Group group, @NonNull String server, @NonNull long expireAt) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster(), checkServer(server), checkTime(expireAt)); + master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), checkTime(expireAt)); } @Override public void addGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull long expireAt) throws ObjectAlreadyHasException { checkGroup(group); - master.addGroup(((GroupLink) group).getMaster(), checkServer(server), world, checkTime(expireAt)); + master.setInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, checkTime(expireAt)); } @Override public void removeGroup(@NonNull Group group) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster()); + master.unsetInheritGroup(((GroupLink) group).getMaster()); } @Override public void removeGroup(@NonNull Group group, @NonNull boolean temporary) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster(), temporary); + master.unsetInheritGroup(((GroupLink) group).getMaster(), temporary); } @Override public void removeGroup(@NonNull Group group, @NonNull String server) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster(), checkServer(server)); + master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server)); } @Override public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster(), checkServer(server), world); + master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world); } @Override public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull boolean temporary) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster(), checkServer(server), temporary); + master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), temporary); } @Override public void removeGroup(@NonNull Group group, @NonNull String server, @NonNull String world, @NonNull boolean temporary) throws ObjectLacksException { checkGroup(group); - master.removeGroup(((GroupLink) group).getMaster(), checkServer(server), world, temporary); + master.unsetInheritGroup(((GroupLink) group).getMaster(), checkServer(server), world, temporary); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java index 67363ed4..5b62bb2e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/SubCommand.java @@ -133,15 +133,15 @@ public abstract class SubCommand { * ---------------------------------------------------------------------------------- */ - protected static List getGroupTabComplete(List args, LuckPermsPlugin plugin) { + public static List getGroupTabComplete(List args, LuckPermsPlugin plugin) { return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args); } - protected static List getTrackTabComplete(List args, LuckPermsPlugin plugin) { + public static List getTrackTabComplete(List args, LuckPermsPlugin plugin) { return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args); } - protected static List getBoolTabComplete(List args) { + public static List getBoolTabComplete(List args) { if (args.size() == 2) { return Arrays.asList("true", "false"); } else { @@ -161,7 +161,7 @@ public abstract class SubCommand { return Collections.emptyList(); } - protected static void save(User user, Sender sender, LuckPermsPlugin plugin) { + public static void save(User user, Sender sender, LuckPermsPlugin plugin) { if (plugin.getDatastore().saveUser(user)) { Message.USER_SAVE_SUCCESS.send(sender); } else { @@ -171,7 +171,7 @@ public abstract class SubCommand { user.refreshPermissions(); } - protected static void save(Group group, Sender sender, LuckPermsPlugin plugin) { + public static void save(Group group, Sender sender, LuckPermsPlugin plugin) { if (plugin.getDatastore().saveGroup(group)) { Message.GROUP_SAVE_SUCCESS.send(sender); } else { @@ -181,7 +181,7 @@ public abstract class SubCommand { plugin.runUpdateTask(); } - protected static void save(Track track, Sender sender, LuckPermsPlugin plugin) { + public static void save(Track track, Sender sender, LuckPermsPlugin plugin) { if (plugin.getDatastore().saveTrack(track)) { Message.TRACK_SAVE_SUCCESS.send(sender); } else { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaCommands.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java similarity index 56% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaCommands.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java index 97b0f72b..ca7461f4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaCommands.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java @@ -20,49 +20,37 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta; +package me.lucko.luckperms.common.commands.generic; -import com.google.common.collect.ImmutableList; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.commands.meta.subcommands.*; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.PermissionHolder; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -public class MetaCommands extends SubCommand { +public class SecondaryMainCommand extends SubCommand { private boolean user; + private final List secondaryCommands; - private final List subCommands = ImmutableList.builder() - .add(new MetaInfo()) - .add(new MetaAddPrefix()) - .add(new MetaAddSuffix()) - .add(new MetaRemovePrefix()) - .add(new MetaRemoveSuffix()) - .add(new MetaAddTempPrefix()) - .add(new MetaAddTempSuffix()) - .add(new MetaRemoveTempPrefix()) - .add(new MetaRemoveTempSuffix()) - .add(new MetaClear()) - .build(); - - public MetaCommands(boolean user) { - super("meta", "Edit metadata values", null, Predicate.alwaysFalse(), null); + public SecondaryMainCommand(String name, String description, boolean user, List secondaryCommands) { + super(name, description, null, Predicate.alwaysFalse(), null); + this.secondaryCommands = secondaryCommands; this.user = user; } @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T t, List args, String label) { if (args.size() == 0) { - sendUsageMeta(sender, user, label); + sendUsageDetailed(sender, user, label); return CommandResult.INVALID_ARGS; } - Optional o = subCommands.stream() + Optional o = secondaryCommands.stream() .filter(s -> s.getName().equalsIgnoreCase(args.get(0))) .limit(1) .findAny(); @@ -72,7 +60,7 @@ public class MetaCommands extends SubCommand { return CommandResult.INVALID_ARGS; } - final MetaSubCommand sub = o.get(); + final SecondarySubCommand sub = o.get(); if (!sub.isAuthorized(sender, user)) { Message.COMMAND_NO_PERMISSION.send(sender); return CommandResult.NO_PERMISSION; @@ -91,9 +79,40 @@ public class MetaCommands extends SubCommand { return sub.execute(plugin, sender, t, strippedArgs); } + @Override + public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { + final List subs = secondaryCommands.stream() + .filter(s -> s.isAuthorized(sender, user)) + .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().onTabComplete(plugin, sender, args.subList(1, args.size())); + } + @Override public boolean isAuthorized(Sender sender) { - for (MetaSubCommand subCommand : subCommands) { + for (SecondarySubCommand subCommand : secondaryCommands) { if (subCommand.isAuthorized(sender, user)) { return true; } @@ -101,19 +120,19 @@ public class MetaCommands extends SubCommand { return false; } - private void sendUsageMeta(Sender sender, boolean user, String label) { - List subs = subCommands.stream() + private void sendUsageDetailed(Sender sender, boolean user, String label) { + List subs = secondaryCommands.stream() .filter(s -> s.isAuthorized(sender, user)) .collect(Collectors.toList()); if (subs.size() > 0) { if (user) { - Util.sendPluginMessage(sender, "&bMeta Sub Commands: &7(" + String.format("/%s user meta ...)", label)); + Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user " + getName().toLowerCase() + " ...)", label)); } else { - Util.sendPluginMessage(sender, "&bMeta Sub Commands: &7(" + String.format("/%s group meta ...)", label)); + Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group " + getName().toLowerCase() + " ...)", label)); } - for (MetaSubCommand s : subs) { + for (SecondarySubCommand s : subs) { s.sendUsage(sender); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaSubCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondarySubCommand.java similarity index 82% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaSubCommand.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondarySubCommand.java index 8e8d1d5f..c1399450 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/MetaSubCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondarySubCommand.java @@ -20,28 +20,27 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta; +package me.lucko.luckperms.common.commands.generic; import com.google.common.collect.ImmutableList; import lombok.AllArgsConstructor; import lombok.Getter; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.Arg; -import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.Util; +import me.lucko.luckperms.common.commands.*; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.users.User; +import java.util.Collections; import java.util.List; import java.util.function.Predicate; @Getter @AllArgsConstructor -public abstract class MetaSubCommand { +public abstract class SecondarySubCommand { + /** * The name of the sub command */ @@ -67,6 +66,10 @@ public abstract class MetaSubCommand { public abstract CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args); + public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { + return Collections.emptyList(); + } + public void sendUsage(Sender sender) { String usage = ""; if (args != null) { @@ -97,28 +100,17 @@ public abstract class MetaSubCommand { protected static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { if (holder instanceof User) { User user = ((User) holder); - if (plugin.getDatastore().saveUser(user)) { - Message.USER_SAVE_SUCCESS.send(sender); - } else { - Message.USER_SAVE_ERROR.send(sender); - } - - user.refreshPermissions(); + SubCommand.save(user, sender, plugin); return; } if (holder instanceof Group) { Group group = ((Group) holder); - if (plugin.getDatastore().saveGroup(group)) { - Message.GROUP_SAVE_SUCCESS.send(sender); - } else { - Message.GROUP_SAVE_ERROR.send(sender); - } - - plugin.runUpdateTask(); + SubCommand.save(group, sender, plugin); return; } throw new IllegalArgumentException(); } + } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java new file mode 100644 index 00000000..54309657 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/CommandMeta.java @@ -0,0 +1,45 @@ +/* + * 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.generic.meta; + +import com.google.common.collect.ImmutableList; +import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; +import me.lucko.luckperms.common.core.PermissionHolder; + +public class CommandMeta extends SecondaryMainCommand { + public CommandMeta(boolean user) { + super("Meta", "Edit metadata values", user, ImmutableList.builder() + .add(new MetaInfo()) + .add(new MetaAddPrefix()) + .add(new MetaAddSuffix()) + .add(new MetaRemovePrefix()) + .add(new MetaRemoveSuffix()) + .add(new MetaAddTempPrefix()) + .add(new MetaAddTempSuffix()) + .add(new MetaRemoveTempPrefix()) + .add(new MetaRemoveTempSuffix()) + .add(new MetaClear()) + .build()); + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddPrefix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java index c6715298..450e1a08 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java @@ -20,14 +20,14 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class MetaAddPrefix extends MetaSubCommand { +public class MetaAddPrefix extends SecondarySubCommand { public MetaAddPrefix() { super("addprefix", "Adds a prefix", Permission.USER_ADDPREFIX, Permission.GROUP_ADDPREFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddSuffix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java index 9c082b42..3bb495d6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java @@ -20,14 +20,14 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -37,7 +37,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class MetaAddSuffix extends MetaSubCommand { +public class MetaAddSuffix extends SecondarySubCommand { public MetaAddSuffix() { super("addsuffix", "Adds a suffix", Permission.USER_ADDSUFFIX, Permission.GROUP_ADDSUFFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempPrefix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java index 25c22dad..0e38fc99 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java @@ -20,14 +20,14 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -38,7 +38,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class MetaAddTempPrefix extends MetaSubCommand { +public class MetaAddTempPrefix extends SecondarySubCommand { public MetaAddTempPrefix() { super("addtempprefix", "Adds a prefix temporarily", Permission.USER_ADD_TEMP_PREFIX, Permission.GROUP_ADD_TEMP_PREFIX, Predicate.notInRange(3, 5), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempSuffix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java index cc5b2173..185f1a64 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaAddTempSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java @@ -20,14 +20,14 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -38,7 +38,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class MetaAddTempSuffix extends MetaSubCommand { +public class MetaAddTempSuffix extends SecondarySubCommand { public MetaAddTempSuffix() { super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_ADD_TEMP_SUFFIX, Permission.GROUP_ADD_TEMP_SUFFIX, Predicate.notInRange(3, 5), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java similarity index 94% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaClear.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index 54111ba2..e99c13f7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -20,14 +20,14 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -37,7 +37,7 @@ import me.lucko.luckperms.common.utils.ArgumentChecker; import java.util.List; import java.util.stream.Collectors; -public class MetaClear extends MetaSubCommand { +public class MetaClear extends SecondarySubCommand { public MetaClear() { super("clear", "Clears all chat meta", Permission.USER_CLEARMETA, Permission.GROUP_CLEARMETA, Predicate.notInRange(0, 2), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java similarity index 95% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaInfo.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java index 1aa8a0b1..340af42b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Node; @@ -29,14 +29,14 @@ import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.Util; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import java.util.*; -public class MetaInfo extends MetaSubCommand { +public class MetaInfo extends SecondarySubCommand { public MetaInfo() { super("info", "Shows all chat meta", Permission.USER_CHATMETA, Permission.GROUP_CHATMETA, Predicate.alwaysFalse(), null); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemovePrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemovePrefix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java index 4dbde7bd..936f0a81 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemovePrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; @@ -28,7 +28,7 @@ import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; import java.util.List; -public class MetaRemovePrefix extends MetaSubCommand { +public class MetaRemovePrefix extends SecondarySubCommand { public MetaRemovePrefix() { super("removeprefix", "Removes a prefix", Permission.USER_REMOVEPREFIX, Permission.GROUP_REMOVEPREFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveSuffix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java index 2725071b..7f5939c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; @@ -28,7 +28,7 @@ import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; import java.util.List; -public class MetaRemoveSuffix extends MetaSubCommand { +public class MetaRemoveSuffix extends SecondarySubCommand { public MetaRemoveSuffix() { super("removesuffix", "Removes a suffix", Permission.USER_REMOVESUFFIX, Permission.GROUP_REMOVESUFFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempPrefix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java index 5b568844..41626ddd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; @@ -28,7 +28,7 @@ import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; import java.util.List; -public class MetaRemoveTempPrefix extends MetaSubCommand { +public class MetaRemoveTempPrefix extends SecondarySubCommand { public MetaRemoveTempPrefix() { super("removetempprefix", "Removes a temporary prefix", Permission.USER_REMOVE_TEMP_PREFIX, Permission.GROUP_REMOVE_TEMP_PREFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempSuffix.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java index 20d14636..ab057899 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/meta/subcommands/MetaRemoveTempSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.meta.subcommands; +package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; @@ -28,7 +28,7 @@ import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; -import me.lucko.luckperms.common.commands.meta.MetaSubCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; @@ -39,7 +39,7 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; import java.util.List; -public class MetaRemoveTempSuffix extends MetaSubCommand { +public class MetaRemoveTempSuffix extends SecondarySubCommand { public MetaRemoveTempSuffix() { super("removetempsuffix", "Removes a temporary suffix", Permission.USER_REMOVE_TEMP_SUFFIX, Permission.GROUP_REMOVE_TEMP_SUFFIX, Predicate.notInRange(2, 4), Arg.list( diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserListGroups.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java similarity index 54% rename from common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserListGroups.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java index e203cd72..9676e63e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/CommandParent.java @@ -20,25 +20,21 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.user.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; -import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.users.User; +import com.google.common.collect.ImmutableList; +import me.lucko.luckperms.common.commands.generic.SecondaryMainCommand; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; +import me.lucko.luckperms.common.core.PermissionHolder; -import java.util.List; - -public class UserListGroups extends SubCommand { - public UserListGroups() { - super("listgroups", "Lists the groups the user is a member of", Permission.USER_LISTGROUPS, Predicate.alwaysFalse(), null); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { - Message.LISTGROUPS.send(sender, user.getName(), Util.permGroupsToString(user.getPermissions(false))); - Message.LISTGROUPS_TEMP.send(sender, user.getName(), Util.tempGroupsToString(user.getPermissions(false))); - return CommandResult.SUCCESS; +public class CommandParent extends SecondaryMainCommand { + public CommandParent(boolean user) { + super("Parent", "Edit inheritances", user, ImmutableList.builder() + .add(new ParentInfo()) + .add(new ParentAdd()) + .add(new ParentRemove()) + .add(new ParentAddTemp()) + .add(new ParentRemoveTemp()) + .build()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java similarity index 63% rename from common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java index 1fb5c914..7243ea9a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java @@ -20,33 +20,40 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.user.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Predicate; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class UserAddGroup extends SubCommand { - public UserAddGroup() { - super("addgroup", "Adds the user to a group", Permission.USER_ADDGROUP, Predicate.notInRange(1, 3), +import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; + +public class ParentAdd extends SecondarySubCommand { + public ParentAdd() { + super("add", "Sets another group for the object to inherit permissions from", + Permission.USER_ADDGROUP, Permission.GROUP_SETINHERIT, Predicate.notInRange(1, 3), Arg.list( - Arg.create("group", true, "the group to add the user to"), - Arg.create("server", false, "the server to add the group on"), - Arg.create("world", false, "the world to add the group on") + Arg.create("group", true, "the group to inherit from"), + Arg.create("server", false, "the server to inherit the group on"), + Arg.create("world", false, "the world to inherit the group on") ) ); } @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { + public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args) { String groupName = args.get(0).toLowerCase(); if (ArgumentChecker.checkNode(groupName)) { @@ -74,32 +81,32 @@ public class UserAddGroup extends SubCommand { } if (args.size() == 2) { - user.addGroup(group, server); - Message.USER_ADDGROUP_SERVER_SUCCESS.send(sender, user.getName(), group.getDisplayName(), server); - LogEntry.build().actor(sender).acted(user) - .action("addgroup " + group.getName() + " " + server) + holder.setInheritGroup(group, server); + Message.SET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server); + LogEntry.build().actor(sender).acted(holder) + .action("parent add " + group.getName() + " " + server) .build().submit(plugin, sender); } else { final String world = args.get(2).toLowerCase(); - user.addGroup(group, server, world); - Message.USER_ADDGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), group.getDisplayName(), server, world); - LogEntry.build().actor(sender).acted(user) - .action("addgroup " + group.getName() + " " + server + " " + world) + holder.setInheritGroup(group, server, world); + Message.SET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world); + LogEntry.build().actor(sender).acted(holder) + .action("parent add " + group.getName() + " " + server + " " + world) .build().submit(plugin, sender); } } else { - user.addGroup(group); - Message.USER_ADDGROUP_SUCCESS.send(sender, user.getName(), group.getDisplayName()); - LogEntry.build().actor(sender).acted(user) - .action("addgroup " + group.getName()) + holder.setInheritGroup(group); + Message.SET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName()); + LogEntry.build().actor(sender).acted(holder) + .action("parent add " + group.getName()) .build().submit(plugin, sender); } - save(user, sender, plugin); + save(holder, sender, plugin); return CommandResult.SUCCESS; } catch (ObjectAlreadyHasException e) { - Message.USER_ALREADY_MEMBER_OF.send(sender, user.getName(), group.getDisplayName()); + Message.ALREADY_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName()); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddTempGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java similarity index 66% rename from common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddTempGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java index b39f9253..fa87cefd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserAddTempGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java @@ -20,26 +20,33 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.user.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Predicate; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; -public class UserAddTempGroup extends SubCommand { - public UserAddTempGroup() { - super("addtempgroup", "Adds the user to a group temporarily", Permission.USER_ADDTEMPGROUP, Predicate.notInRange(2, 4), +import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; + +public class ParentAddTemp extends SecondarySubCommand { + public ParentAddTemp() { + super("addtemp", "Sets another group for the object to inherit permissions from temporarily", + Permission.USER_ADDTEMPGROUP, Permission.GROUP_SET_TEMP_INHERIT, Predicate.notInRange(2, 4), Arg.list( - Arg.create("group", true, "the group to add the user to"), + Arg.create("group", true, "the group to inherit from"), Arg.create("duration", true, "the duration of the group membership"), Arg.create("server", false, "the server to add the group on"), Arg.create("world", false, "the world to add the group on") @@ -48,7 +55,7 @@ public class UserAddTempGroup extends SubCommand { } @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { + public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args) { String groupName = args.get(0).toLowerCase(); if (ArgumentChecker.checkNode(groupName)) { @@ -81,7 +88,7 @@ public class UserAddTempGroup extends SubCommand { Group group = plugin.getGroupManager().get(groupName); if (group == null) { Message.GROUP_DOES_NOT_EXIST.send(sender); - return CommandResult.LOADING_ERROR; + return CommandResult.INVALID_ARGS; } try { @@ -93,34 +100,34 @@ public class UserAddTempGroup extends SubCommand { } if (args.size() == 3) { - user.addGroup(group, server, duration); - Message.USER_ADDTEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), group.getDisplayName(), server, + holder.setInheritGroup(group, server, duration); + Message.SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(user) - .action("addtempgroup " + group.getName() + " " + duration + " " + server) + LogEntry.build().actor(sender).acted(holder) + .action("parent addtemp " + group.getName() + " " + duration + " " + server) .build().submit(plugin, sender); } else { final String world = args.get(3).toLowerCase(); - user.addGroup(group, server, world, duration); - Message.USER_ADDTEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), group.getDisplayName(), server, + holder.setInheritGroup(group, server, world, duration); + Message.SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), server, world, DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(user) - .action("addtempgroup " + group.getName() + " " + duration + " " + server + " " + world) + LogEntry.build().actor(sender).acted(holder) + .action("parent addtemp " + group.getName() + " " + duration + " " + server + " " + world) .build().submit(plugin, sender); } } else { - user.addGroup(group, duration); - Message.USER_ADDTEMPGROUP_SUCCESS.send(sender, user.getName(), group.getDisplayName(), DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(user) - .action("addtempgroup " + group.getName() + " " + duration) + holder.setInheritGroup(group, duration); + Message.SET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), group.getDisplayName(), DateUtil.formatDateDiff(duration)); + LogEntry.build().actor(sender).acted(holder) + .action("parent addtemp " + group.getName() + " " + duration) .build().submit(plugin, sender); } - save(user, sender, plugin); + save(holder, sender, plugin); return CommandResult.SUCCESS; } catch (ObjectAlreadyHasException e) { - Message.USER_ALREADY_TEMP_MEMBER_OF.send(sender, user.getName(), group.getDisplayName()); + Message.ALREADY_TEMP_INHERITS.send(sender, holder.getFriendlyName(), group.getDisplayName()); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupListParents.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java similarity index 60% rename from common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupListParents.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java index 113382ff..ec70b99a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupListParents.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java @@ -20,26 +20,30 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.group.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Predicate; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.Util; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.groups.Group; +import me.lucko.luckperms.common.core.PermissionHolder; import java.util.List; -public class GroupListParents extends SubCommand { - public GroupListParents() { - super("listparents", "Lists the groups that this group inherits from", Permission.GROUP_LISTPARENTS, Predicate.alwaysFalse(), null); +public class ParentInfo extends SecondarySubCommand { + public ParentInfo() { + super("info", "Lists the groups that this object inherits from", + Permission.USER_LISTGROUPS, Permission.GROUP_LISTPARENTS, Predicate.alwaysFalse(), null); } @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - Message.LISTPARENTS.send(sender, group.getDisplayName(), Util.permGroupsToString(group.getPermissions(false))); - Message.LISTPARENTS_TEMP.send(sender, group.getDisplayName(), Util.tempGroupsToString(group.getPermissions(false))); + public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args) { + Message.LISTPARENTS.send(sender, holder.getFriendlyName(), Util.permGroupsToString(holder.getPermissions(false))); + Message.LISTPARENTS_TEMP.send(sender, holder.getFriendlyName(), Util.tempGroupsToString(holder.getPermissions(false))); return CommandResult.SUCCESS; } } - diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveTempGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java similarity index 57% rename from common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveTempGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java index b36fe169..647929d9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveTempGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java @@ -20,12 +20,17 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.user.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Predicate; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; @@ -33,11 +38,14 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; -public class UserRemoveTempGroup extends SubCommand { - public UserRemoveTempGroup() { - super("removetempgroup", "Removes the user from a temporary group", Permission.USER_REMOVETEMPGROUP, Predicate.notInRange(1, 3), +import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; + +public class ParentRemove extends SecondarySubCommand { + public ParentRemove() { + super("remove", "Removes a previously set inheritance rule", Permission.USER_REMOVEGROUP, Permission.GROUP_UNSETINHERIT, + Predicate.notInRange(1, 3), Arg.list( - Arg.create("group", true, "the group to remove the user from"), + Arg.create("group", true, "the group to remove"), Arg.create("server", false, "the server to remove the group on"), Arg.create("world", false, "the world to remove the group on") ) @@ -45,7 +53,7 @@ public class UserRemoveTempGroup extends SubCommand { } @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { + public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args) { String groupName = args.get(0).toLowerCase(); if (ArgumentChecker.checkNode(groupName)) { @@ -53,6 +61,15 @@ public class UserRemoveTempGroup extends SubCommand { return CommandResult.INVALID_ARGS; } + if (holder instanceof User) { + User user = (User) holder; + if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global"))) + && user.getPrimaryGroup().equalsIgnoreCase(groupName)) { + Message.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender); + return CommandResult.STATE_ERROR; + } + } + try { if (args.size() >= 2) { final String server = args.get(1).toLowerCase(); @@ -62,32 +79,32 @@ public class UserRemoveTempGroup extends SubCommand { } if (args.size() == 2) { - user.unsetPermission("group." + groupName, server, true); - Message.USER_REMOVETEMPGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server); - LogEntry.build().actor(sender).acted(user) - .action("removetempgroup " + groupName + " " + server) + holder.unsetPermission("group." + groupName, server); + Message.UNSET_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server); + LogEntry.build().actor(sender).acted(holder) + .action("parent remove " + groupName + " " + server) .build().submit(plugin, sender); } else { final String world = args.get(2).toLowerCase(); - user.unsetPermission("group." + groupName, server, world, true); - Message.USER_REMOVETEMPGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world); - LogEntry.build().actor(sender).acted(user) - .action("removetempgroup " + groupName + " " + server + " " + world) + holder.unsetPermission("group." + groupName, server, world); + Message.UNSET_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world); + LogEntry.build().actor(sender).acted(holder) + .action("parent remove " + groupName + " " + server + " " + world) .build().submit(plugin, sender); } } else { - user.unsetPermission("group." + groupName, true); - Message.USER_REMOVETEMPGROUP_SUCCESS.send(sender, user.getName(), groupName); - LogEntry.build().actor(sender).acted(user) - .action("removetempgroup " + groupName) + holder.unsetPermission("group." + groupName); + Message.UNSET_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName); + LogEntry.build().actor(sender).acted(holder) + .action("parent remove " + groupName) .build().submit(plugin, sender); } - save(user, sender, plugin); + save(holder, sender, plugin); return CommandResult.SUCCESS; } catch (ObjectLacksException e) { - Message.USER_NOT_TEMP_MEMBER_OF.send(sender, user.getName(), groupName); + Message.DOES_NOT_INHERIT.send(sender, holder.getFriendlyName(), groupName); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java similarity index 60% rename from common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveGroup.java rename to common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java index f526c036..e7a6b85e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserRemoveGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java @@ -20,24 +20,31 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands.user.subcommands; +package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Predicate; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; +import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; -import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; -public class UserRemoveGroup extends SubCommand { - public UserRemoveGroup() { - super("removegroup", "Removes the user from a group", Permission.USER_REMOVEGROUP, Predicate.notInRange(1, 3), +import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; + +public class ParentRemoveTemp extends SecondarySubCommand { + public ParentRemoveTemp() { + super("removetemp", "Removes a previously set temporary inheritance rule", + Permission.USER_REMOVETEMPGROUP, Permission.GROUP_UNSET_TEMP_INHERIT, Predicate.notInRange(1, 3), Arg.list( - Arg.create("group", true, "the group to remove the user from"), + Arg.create("group", true, "the group to remove"), Arg.create("server", false, "the server to remove the group on"), Arg.create("world", false, "the world to remove the group on") ) @@ -45,7 +52,7 @@ public class UserRemoveGroup extends SubCommand { } @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List args, String label) { + public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List args) { String groupName = args.get(0).toLowerCase(); if (ArgumentChecker.checkNode(groupName)) { @@ -53,12 +60,6 @@ public class UserRemoveGroup extends SubCommand { return CommandResult.INVALID_ARGS; } - if ((args.size() == 1 || (args.size() == 2 && args.get(1).equalsIgnoreCase("global"))) - && user.getPrimaryGroup().equalsIgnoreCase(groupName)) { - Message.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender); - return CommandResult.STATE_ERROR; - } - try { if (args.size() >= 2) { final String server = args.get(1).toLowerCase(); @@ -68,32 +69,32 @@ public class UserRemoveGroup extends SubCommand { } if (args.size() == 2) { - user.unsetPermission("group." + groupName, server); - Message.USER_REMOVEGROUP_SERVER_SUCCESS.send(sender, user.getName(), groupName, server); - LogEntry.build().actor(sender).acted(user) - .action("removegroup " + groupName + " " + server) + holder.unsetPermission("group." + groupName, server, true); + Message.UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server); + LogEntry.build().actor(sender).acted(holder) + .action("parent removetemp " + groupName + " " + server) .build().submit(plugin, sender); } else { final String world = args.get(2).toLowerCase(); - user.unsetPermission("group." + groupName, server, world); - Message.USER_REMOVEGROUP_SERVER_WORLD_SUCCESS.send(sender, user.getName(), groupName, server, world); - LogEntry.build().actor(sender).acted(user) - .action("removegroup " + groupName + " " + server + " " + world) + holder.unsetPermission("group." + groupName, server, world, true); + Message.UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, holder.getFriendlyName(), groupName, server, world); + LogEntry.build().actor(sender).acted(holder) + .action("parent removetemp " + groupName + " " + server + " " + world) .build().submit(plugin, sender); } } else { - user.unsetPermission("group." + groupName); - Message.USER_REMOVEGROUP_SUCCESS.send(sender, user.getName(), groupName); - LogEntry.build().actor(sender).acted(user) - .action("removegroup " + groupName) + holder.unsetPermission("group." + groupName, true); + Message.UNSET_TEMP_INHERIT_SUCCESS.send(sender, holder.getFriendlyName(), groupName); + LogEntry.build().actor(sender).acted(holder) + .action("parent removetemp " + groupName) .build().submit(plugin, sender); } - save(user, sender, plugin); + save(holder, sender, plugin); return CommandResult.SUCCESS; } catch (ObjectLacksException e) { - Message.USER_NOT_MEMBER_OF.send(sender, user.getName(), groupName); + Message.DOES_NOT_TEMP_INHERIT.send(sender, holder.getFriendlyName(), groupName); return CommandResult.STATE_ERROR; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java index 4bdda155..0276d984 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/GroupMainCommand.java @@ -27,8 +27,9 @@ import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.MainCommand; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; +import me.lucko.luckperms.common.commands.generic.parent.CommandParent; import me.lucko.luckperms.common.commands.group.subcommands.*; -import me.lucko.luckperms.common.commands.meta.MetaCommands; +import me.lucko.luckperms.common.commands.generic.meta.CommandMeta; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.groups.Group; @@ -39,20 +40,16 @@ public class GroupMainCommand extends MainCommand { public GroupMainCommand() { super("Group", "/%s group ", 2, ImmutableList.>builder() .add(new GroupInfo()) + .add(new CommandParent<>(false)) + .add(new CommandMeta<>(false)) .add(new GroupListNodes()) - .add(new GroupListParents()) .add(new GroupHasPerm()) .add(new GroupInheritsPerm()) .add(new GroupSetPermission()) .add(new GroupUnSetPermission()) - .add(new GroupSetInherit()) - .add(new GroupUnsetInherit()) .add(new GroupSetTempPermission()) .add(new GroupUnsetTempPermission()) - .add(new GroupSetTempInherit()) - .add(new GroupUnsetTempInherit()) .add(new GroupShowTracks()) - .add(new MetaCommands<>(false)) .add(new GroupBulkChange()) .add(new GroupClear()) .add(new GroupRename()) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetInherit.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetInherit.java deleted file mode 100644 index 7bb67604..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetInherit.java +++ /dev/null @@ -1,111 +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.group.subcommands; - -import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.data.LogEntry; -import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.utils.ArgumentChecker; -import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; - -import java.util.List; - -public class GroupSetInherit extends SubCommand { - public GroupSetInherit() { - super("setinherit", "Sets another group for the group to inherit permissions from", - Permission.GROUP_SETINHERIT, Predicate.notInRange(1, 3), - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("server", false, "the server to inherit the group on"), - Arg.create("world", false, "the world to inherit the group on") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - String groupName = args.get(0).toLowerCase(); - - if (ArgumentChecker.checkNode(groupName)) { - sendDetailedUsage(sender); - return CommandResult.INVALID_ARGS; - } - - if (!plugin.getDatastore().loadGroup(groupName)) { - Message.GROUP_DOES_NOT_EXIST.send(sender); - return CommandResult.INVALID_ARGS; - } - - Group group1 = plugin.getGroupManager().get(groupName); - if (group1 == null) { - Message.GROUP_DOES_NOT_EXIST.send(sender); - return CommandResult.LOADING_ERROR; - } - - try { - if (args.size() >= 2) { - final String server = args.get(1).toLowerCase(); - if (ArgumentChecker.checkServer(server)) { - Message.SERVER_INVALID_ENTRY.send(sender); - return CommandResult.INVALID_ARGS; - } - - if (args.size() == 2) { - group.setInheritGroup(group1, server); - Message.GROUP_SETINHERIT_SERVER_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName(), server); - LogEntry.build().actor(sender).acted(group) - .action("setinherit " + group1.getName() + " " + server) - .build().submit(plugin, sender); - } else { - final String world = args.get(2).toLowerCase(); - group.setInheritGroup(group1, server, world); - Message.GROUP_SETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName(), server, world); - LogEntry.build().actor(sender).acted(group) - .action("setinherit " + group1.getName() + " " + server + " " + world) - .build().submit(plugin, sender); - } - - } else { - group.setInheritGroup(group1); - Message.GROUP_SETINHERIT_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName()); - LogEntry.build().actor(sender).acted(group) - .action("setinherit " + group1.getName()) - .build().submit(plugin, sender); - } - - save(group, sender, plugin); - return CommandResult.SUCCESS; - } catch (ObjectAlreadyHasException e) { - Message.GROUP_ALREADY_INHERITS.send(sender, group.getDisplayName(), group1.getDisplayName()); - return CommandResult.STATE_ERROR; - } - } - - @Override - public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetTempInherit.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetTempInherit.java deleted file mode 100644 index 4e924bb3..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupSetTempInherit.java +++ /dev/null @@ -1,132 +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.group.subcommands; - -import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.data.LogEntry; -import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.utils.ArgumentChecker; -import me.lucko.luckperms.common.utils.DateUtil; -import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; - -import java.util.List; - -public class GroupSetTempInherit extends SubCommand { - public GroupSetTempInherit() { - super("settempinherit", "Sets another group for the group to inherit permissions from temporarily", - Permission.GROUP_SET_TEMP_INHERIT, Predicate.notInRange(2, 4), - Arg.list( - Arg.create("group", true, "the group to inherit from"), - Arg.create("duration", true, "the duration of the group membership"), - Arg.create("server", false, "the server to add the group on"), - Arg.create("world", false, "the world to add the group on") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - String groupName = args.get(0).toLowerCase(); - - if (ArgumentChecker.checkNode(groupName)) { - sendDetailedUsage(sender); - return CommandResult.INVALID_ARGS; - } - - long duration; - try { - duration = Long.parseLong(args.get(1)); - } catch (NumberFormatException e) { - try { - duration = DateUtil.parseDateDiff(args.get(1), true); - } catch (DateUtil.IllegalDateException e1) { - Message.ILLEGAL_DATE_ERROR.send(sender, args.get(1)); - return CommandResult.INVALID_ARGS; - } - } - - if (DateUtil.shouldExpire(duration)) { - Message.PAST_DATE_ERROR.send(sender); - return CommandResult.INVALID_ARGS; - } - - if (!plugin.getDatastore().loadGroup(groupName)) { - Message.GROUP_DOES_NOT_EXIST.send(sender); - return CommandResult.INVALID_ARGS; - } - - Group group1 = plugin.getGroupManager().get(groupName); - if (group1 == null) { - Message.GROUP_DOES_NOT_EXIST.send(sender); - return CommandResult.INVALID_ARGS; - } - - try { - if (args.size() >= 3) { - final String server = args.get(2).toLowerCase(); - if (ArgumentChecker.checkServer(server)) { - Message.SERVER_INVALID_ENTRY.send(sender); - return CommandResult.INVALID_ARGS; - } - - if (args.size() == 3) { - group.setInheritGroup(group1, server, duration); - Message.GROUP_SET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName(), server, - DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(group) - .action("settempinherit " + group1.getName() + " " + duration + " " + server) - .build().submit(plugin, sender); - } else { - final String world = args.get(3).toLowerCase(); - group.setInheritGroup(group1, server, world, duration); - Message.GROUP_SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName(), server, - world, DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(group) - .action("settempinherit " + group1.getName() + " " + duration + " " + server + " " + world) - .build().submit(plugin, sender); - } - - } else { - group.setInheritGroup(group1, duration); - Message.GROUP_SET_TEMP_INHERIT_SUCCESS.send(sender, group.getDisplayName(), group1.getDisplayName(), DateUtil.formatDateDiff(duration)); - LogEntry.build().actor(sender).acted(group) - .action("settempinherit " + group1.getName() + " " + duration) - .build().submit(plugin, sender); - } - - save(group, sender, plugin); - return CommandResult.SUCCESS; - } catch (ObjectAlreadyHasException e) { - Message.USER_ALREADY_TEMP_MEMBER_OF.send(sender, group.getDisplayName(), group1.getDisplayName()); - return CommandResult.STATE_ERROR; - } - } - - @Override - public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetInherit.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetInherit.java deleted file mode 100644 index eaaafb02..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetInherit.java +++ /dev/null @@ -1,100 +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.group.subcommands; - -import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.data.LogEntry; -import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.utils.ArgumentChecker; -import me.lucko.luckperms.exceptions.ObjectLacksException; - -import java.util.List; - -public class GroupUnsetInherit extends SubCommand { - public GroupUnsetInherit() { - super("unsetinherit", "Removes a previously set inheritance rule", Permission.GROUP_UNSETINHERIT, - Predicate.notInRange(1, 3), - Arg.list( - Arg.create("group", true, "the group to uninherit"), - Arg.create("server", false, "the server to remove the group on"), - Arg.create("world", false, "the world to remove the group on") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - String groupName = args.get(0).toLowerCase(); - - if (ArgumentChecker.checkNode(groupName)) { - sendDetailedUsage(sender); - return CommandResult.INVALID_ARGS; - } - - try { - if (args.size() >= 2) { - final String server = args.get(1).toLowerCase(); - if (ArgumentChecker.checkServer(server)) { - Message.SERVER_INVALID_ENTRY.send(sender); - return CommandResult.INVALID_ARGS; - } - - if (args.size() == 2) { - group.unsetPermission("group." + groupName, server); - Message.GROUP_UNSETINHERIT_SERVER_SUCCESS.send(sender, group.getDisplayName(), groupName, server); - LogEntry.build().actor(sender).acted(group) - .action("unsetinherit " + groupName + " " + server) - .build().submit(plugin, sender); - } else { - final String world = args.get(2).toLowerCase(); - group.unsetPermission("group." + groupName, server, world); - Message.GROUP_UNSETINHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getDisplayName(), groupName, server, world); - LogEntry.build().actor(sender).acted(group) - .action("unsetinherit " + groupName + " " + server + " " + world) - .build().submit(plugin, sender); - } - - } else { - group.unsetPermission("group." + groupName); - Message.GROUP_UNSETINHERIT_SUCCESS.send(sender, group.getDisplayName(), groupName); - LogEntry.build().actor(sender).acted(group) - .action("unsetinherit " + groupName) - .build().submit(plugin, sender); - } - - save(group, sender, plugin); - return CommandResult.SUCCESS; - } catch (ObjectLacksException e) { - Message.GROUP_DOES_NOT_INHERIT.send(sender, group.getDisplayName(), groupName); - return CommandResult.STATE_ERROR; - } - } - - @Override - public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetTempInherit.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetTempInherit.java deleted file mode 100644 index 826c9ce7..00000000 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupUnsetTempInherit.java +++ /dev/null @@ -1,100 +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.group.subcommands; - -import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; -import me.lucko.luckperms.common.constants.Message; -import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.data.LogEntry; -import me.lucko.luckperms.common.groups.Group; -import me.lucko.luckperms.common.utils.ArgumentChecker; -import me.lucko.luckperms.exceptions.ObjectLacksException; - -import java.util.List; - -public class GroupUnsetTempInherit extends SubCommand { - public GroupUnsetTempInherit() { - super("unsettempinherit", "Removes a previously set temporary inheritance rule", - Permission.GROUP_UNSET_TEMP_INHERIT, Predicate.notInRange(1, 3), - Arg.list( - Arg.create("group", true, "the group to uninherit"), - Arg.create("server", false, "the server to remove the group on"), - Arg.create("world", false, "the world to remove the group on") - ) - ); - } - - @Override - public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group group, List args, String label) { - String groupName = args.get(0).toLowerCase(); - - if (ArgumentChecker.checkNode(groupName)) { - sendDetailedUsage(sender); - return CommandResult.INVALID_ARGS; - } - - try { - if (args.size() >= 2) { - final String server = args.get(1).toLowerCase(); - if (ArgumentChecker.checkServer(server)) { - Message.SERVER_INVALID_ENTRY.send(sender); - return CommandResult.INVALID_ARGS; - } - - if (args.size() == 2) { - group.unsetPermission("group." + groupName, server, true); - Message.GROUP_UNSET_TEMP_INHERIT_SERVER_SUCCESS.send(sender, group.getDisplayName(), groupName, server); - LogEntry.build().actor(sender).acted(group) - .action("unsettempinherit " + groupName + " " + server) - .build().submit(plugin, sender); - } else { - final String world = args.get(2).toLowerCase(); - group.unsetPermission("group." + groupName, server, world, true); - Message.GROUP_UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS.send(sender, group.getDisplayName(), groupName, server, world); - LogEntry.build().actor(sender).acted(group) - .action("unsettempinherit " + groupName + " " + server + " " + world) - .build().submit(plugin, sender); - } - - } else { - group.unsetPermission("group." + groupName, true); - Message.GROUP_UNSET_TEMP_INHERIT_SUCCESS.send(sender, group.getDisplayName(), groupName); - LogEntry.build().actor(sender).acted(group) - .action("unsettempinherit " + groupName) - .build().submit(plugin, sender); - } - - save(group, sender, plugin); - return CommandResult.SUCCESS; - } catch (ObjectLacksException e) { - Message.GROUP_DOES_NOT_TEMP_INHERIT.send(sender, group.getDisplayName(), groupName); - return CommandResult.STATE_ERROR; - } - } - - @Override - public List onTabComplete(LuckPermsPlugin plugin, Sender sender, List args) { - return getGroupTabComplete(args, plugin); - } -} diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java index 812c171d..aec19004 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/UserMainCommand.java @@ -28,7 +28,8 @@ import me.lucko.luckperms.common.commands.MainCommand; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.commands.Util; -import me.lucko.luckperms.common.commands.meta.MetaCommands; +import me.lucko.luckperms.common.commands.generic.meta.CommandMeta; +import me.lucko.luckperms.common.commands.generic.parent.CommandParent; import me.lucko.luckperms.common.commands.user.subcommands.*; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Patterns; @@ -41,25 +42,21 @@ public class UserMainCommand extends MainCommand { public UserMainCommand() { super("User", "/%s user ", 2, ImmutableList.>builder() .add(new UserInfo()) + .add(new CommandParent<>(true)) + .add(new CommandMeta<>(true)) .add(new UserGetUUID()) .add(new UserListNodes()) - .add(new UserListGroups()) .add(new UserHasPerm()) .add(new UserInheritsPerm()) .add(new UserSetPermission()) .add(new UserUnSetPermission()) - .add(new UserAddGroup()) - .add(new UserRemoveGroup()) .add(new UserSetTempPermission()) .add(new UserUnsetTempPermission()) - .add(new UserAddTempGroup()) - .add(new UserRemoveTempGroup()) .add(new UserSetPrimaryGroup()) .add(new UserShowTracks()) .add(new UserPromote()) .add(new UserDemote()) .add(new UserShowPos()) - .add(new MetaCommands<>(true)) .add(new UserBulkChange()) .add(new UserClear()) .build() diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java index 3b980dfd..a79df4d3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java @@ -100,7 +100,7 @@ public class UserDemote extends SubCommand { user.unsetPermission("group." + old); } catch (ObjectLacksException ignored) {} try { - user.addGroup(previousGroup); + user.setInheritGroup(previousGroup); } catch (ObjectAlreadyHasException ignored) {} user.setPrimaryGroup(previousGroup.getName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java index c7c916da..19f7162b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java @@ -100,7 +100,7 @@ public class UserPromote extends SubCommand { user.unsetPermission("group." + old); } catch (ObjectLacksException ignored) {} try { - user.addGroup(nextGroup); + user.setInheritGroup(nextGroup); } catch (ObjectAlreadyHasException ignored) {} user.setPrimaryGroup(nextGroup.getName()); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java index 221cd804..be3201a2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java @@ -53,10 +53,10 @@ public class UserSetPrimaryGroup extends SubCommand { return CommandResult.STATE_ERROR; } - if (!user.isInGroup(group)) { + if (!user.inheritsGroup(group)) { Message.USER_PRIMARYGROUP_ERROR_NOTMEMBER.send(sender, user.getName(), group.getName()); try { - user.addGroup(group); + user.setInheritGroup(group); } catch (ObjectAlreadyHasException ignored) {} } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java index 367bbaef..87630f49 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java @@ -34,7 +34,6 @@ import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.*; -// " ", public class BulkEditGroup extends SubCommand { public BulkEditGroup() { super("group", "Bulk edit group memberships", Permission.USER_BULKCHANGE, Predicate.not(4), diff --git a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java b/common/src/main/java/me/lucko/luckperms/common/constants/Message.java index a7c21494..8e5a8fa2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/constants/Message.java @@ -94,15 +94,10 @@ public enum Message { RENAME_SUCCESS("&b{0}&a was successfully renamed to &b{1}&a.", true), CLONE_SUCCESS("&b{0}&a was successfully cloned to &b{1}&a.", true), - USER_ALREADY_MEMBER_OF("{0} is already a member of '{1}'.", true), - USER_NOT_MEMBER_OF("{0} is not a member of '{1}'.", true), - GROUP_ALREADY_INHERITS("{0} already inherits '{1}'.", true), - GROUP_DOES_NOT_INHERIT("{0} does not inherit '{1}'.", true), - - USER_ALREADY_TEMP_MEMBER_OF("{0} is already a temporary member of '{1}'.", true), - USER_NOT_TEMP_MEMBER_OF("{0} is not a temporary member of '{1}'.", true), - GROUP_ALREADY_TEMP_INHERITS("{0} already temporarily inherits '{1}'.", true), - GROUP_DOES_NOT_TEMP_INHERIT("{0} does not temporarily inherit '{1}'.", true), + ALREADY_INHERITS("{0} already inherits '{1}'.", true), + DOES_NOT_INHERIT("{0} does not inherit '{1}'.", true), + ALREADY_TEMP_INHERITS("{0} already temporarily inherits '{1}'.", true), + DOES_NOT_TEMP_INHERIT("{0} does not temporarily inherit '{1}'.", true), TRACK_ALREADY_CONTAINS("Track {0} already contains the group '{1}'.", true), TRACK_DOES_NOT_CONTAIN("Track {0} does not contain the group '{1}'.", true), @@ -159,6 +154,7 @@ public enum Message { LISTPARENTS_TEMP("&b{0}'s Temporary Parent Groups:" + "\n" + "{1}", true), LISTGROUPS("&b{0}'s Groups:" + "\n" + "{1}", true), LISTGROUPS_TEMP("&b{0}'s Temporary Groups:" + "\n" + "{1}", true), + SETPERMISSION_SUCCESS("&aSet &b{0}&a to &b{1}&a for &b{2}&a.", true), SETPERMISSION_SERVER_SUCCESS("&aSet &b{0}&a to &b{1}&a for &b{2}&a on server &b{3}&a.", true), SETPERMISSION_SERVER_WORLD_SUCCESS("&aSet &b{0}&a to &b{1}&a for &b{2}&a on server &b{3}&a, world &b{4}&a.", true), @@ -171,6 +167,20 @@ public enum Message { UNSET_TEMP_PERMISSION_SUCCESS("&aUnset temporary permission &b{0}&a for &b{1}&a.", true), UNSET_TEMP_PERMISSION_SERVER_SUCCESS("&aUnset temporary permission &b{0}&a for &b{1}&a on server &b{2}&a.", true), UNSET_TEMP_PERMISSION_SERVER_WORLD_SUCCESS("&aUnset temporary permission &b{0}&a for &b{1}&a on server &b{2}&a, world &b{3}&a.", true), + + SET_INHERIT_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a.", true), + SET_INHERIT_SERVER_SUCCESS("&b{0}&a now inherits permissions from &b{2}&a on server &b{3}&a.", true), + SET_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), + SET_TEMP_INHERIT_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a for a duration of &b{2}&a.", true), + SET_TEMP_INHERIT_SERVER_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a for a duration of &b{3}&a.", true), + SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a, for a duration of &b{4}&a.", true), + UNSET_INHERIT_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a.", true), + UNSET_INHERIT_SERVER_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a on server &b{2}&a.", true), + UNSET_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), + UNSET_TEMP_INHERIT_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a.", true), + UNSET_TEMP_INHERIT_SERVER_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a on server &b{2}&a.", true), + UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), + CLEAR_SUCCESS("&b{0}&a's permissions were cleared. (&b{1}&a nodes were removed.)", true), CLEAR_SUCCESS_SINGULAR("&b{0}&a's permissions were cleared. (&b{1}&a node was removed.)", true), META_CLEAR_SUCCESS("&b{0}&a's meta was cleared. (&b{1}&a nodes were removed.)", true), @@ -232,18 +242,6 @@ public enum Message { false ), USER_GETUUID("&bThe UUID of &b{0}&b is &b{1}&b.", true), - USER_ADDGROUP_SUCCESS("&b{0}&a successfully added to group &b{1}&a.", true), - USER_ADDGROUP_SERVER_SUCCESS("&b{0}&a successfully added to group &b{1}&a on server &b{2}&a.", true), - USER_ADDGROUP_SERVER_WORLD_SUCCESS("&b{0}&a successfully added to group &b{1}&a on server &b{2}&a, world &b{3}&a.", true), - USER_ADDTEMPGROUP_SUCCESS("&b{0}&a successfully added to group &b{1}&a for a duration of &b{2}&a.", true), - USER_ADDTEMPGROUP_SERVER_SUCCESS("&b{0}&a successfully added to group &b{1}&a on server &b{2}&a for a duration of &b{3}&a.", true), - USER_ADDTEMPGROUP_SERVER_WORLD_SUCCESS("&b{0}&a successfully added to group &b{1}&a on server &b{2}&a, world &b{3}&a, for a duration of &b{4}&a.", true), - USER_REMOVEGROUP_SUCCESS("&b{0}&a was removed from group &b{1}&a.", true), - USER_REMOVEGROUP_SERVER_SUCCESS("&b{0}&a was removed from group &b{1}&a on server &b{2}&a.", true), - USER_REMOVEGROUP_SERVER_WORLD_SUCCESS("&b{0}&a was removed from group &b{1}&a on server &b{2}&a, world &b{3}&a.", true), - USER_REMOVETEMPGROUP_SUCCESS("&b{0}&a was removed from temproary group &b{1}&a.", true), - USER_REMOVETEMPGROUP_SERVER_SUCCESS("&b{0}&a was removed from temporary group &b{1}&a on server &b{2}&a.", true), - USER_REMOVETEMPGROUP_SERVER_WORLD_SUCCESS("&b{0}&a was removed from temporary group &b{1}&a on server &b{2}&a, world &b{3}&a.", true), USER_REMOVEGROUP_ERROR_PRIMARY("You cannot remove a user from their primary group.", true), USER_PRIMARYGROUP_SUCCESS("&b{0}&a's primary group was set to &b{1}&a.", true), USER_PRIMARYGROUP_ERROR_ALREADYHAS("The user already has this group set as their primary group.", true), @@ -276,18 +274,6 @@ public enum Message { "{PREFIX}&b-> &bUse &a/{3} group {4} listnodes &bto see all permissions.", false ), - GROUP_SETINHERIT_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a.", true), - GROUP_SETINHERIT_SERVER_SUCCESS("&b{0}&a now inherits permissions from &b{2}&a on server &b{3}&a.", true), - GROUP_SETINHERIT_SERVER_WORLD_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), - GROUP_SET_TEMP_INHERIT_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a for a duration of &b{2}&a.", true), - GROUP_SET_TEMP_INHERIT_SERVER_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a for a duration of &b{3}&a.", true), - GROUP_SET_TEMP_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a now inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a, for a duration of &b{4}&a.", true), - GROUP_UNSETINHERIT_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a.", true), - GROUP_UNSETINHERIT_SERVER_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a on server &b{2}&a.", true), - GROUP_UNSETINHERIT_SERVER_WORLD_SUCCESS("&b{0}&a no longer inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), - GROUP_UNSET_TEMP_INHERIT_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a.", true), - GROUP_UNSET_TEMP_INHERIT_SERVER_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a on server &b{2}&a.", true), - GROUP_UNSET_TEMP_INHERIT_SERVER_WORLD_SUCCESS("&b{0}&a no longer temporarily inherits permissions from &b{1}&a on server &b{2}&a, world &b{3}&a.", true), TRACK_INFO( "{PREFIX}&b-> &bTrack: &f{0}" + "\n" + diff --git a/common/src/main/java/me/lucko/luckperms/common/core/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/core/PermissionHolder.java index a36fa209..256f4ad4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/core/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/core/PermissionHolder.java @@ -32,11 +32,9 @@ import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.api.event.events.GroupRemoveEvent; -import me.lucko.luckperms.api.event.events.PermissionNodeExpireEvent; -import me.lucko.luckperms.api.event.events.PermissionNodeSetEvent; -import me.lucko.luckperms.api.event.events.PermissionNodeUnsetEvent; +import me.lucko.luckperms.api.event.events.*; import me.lucko.luckperms.common.LuckPermsPlugin; +import me.lucko.luckperms.common.api.internal.GroupLink; import me.lucko.luckperms.common.api.internal.PermissionHolderLink; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.Cache; @@ -678,6 +676,96 @@ public abstract class PermissionHolder { unsetPermission(buildNode(node).setServer(server).setWorld(world).setExpiry(temporary ? 10L : 0L).build()); } + public boolean inheritsGroup(Group group) { + return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission("group." + group.getName(), true); + } + + public boolean inheritsGroup(Group group, String server) { + return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission("group." + group.getName(), true, server); + } + + public boolean inheritsGroup(Group group, String server, String world) { + return group.getName().equalsIgnoreCase(this.getObjectName()) || hasPermission("group." + group.getName(), true, server, world); + } + + public void setInheritGroup(Group group) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, 0L)); + } + + public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true, server); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, 0L)); + } + + public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true, server, world); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, 0L)); + } + + public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true, expireAt); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, expireAt)); + } + + public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true, server, expireAt); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, expireAt)); + } + + public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException { + if (group.getName().equalsIgnoreCase(this.getObjectName())) { + throw new ObjectAlreadyHasException(); + } + + setPermission("group." + group.getName(), true, server, world, expireAt); + getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, expireAt)); + } + + public void unsetInheritGroup(Group group) throws ObjectLacksException { + unsetPermission("group." + group.getName()); + } + + public void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException { + unsetPermission("group." + group.getName(), temporary); + } + + public void unsetInheritGroup(Group group, String server) throws ObjectLacksException { + unsetPermission("group." + group.getName(), server); + } + + public void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException { + unsetPermission("group." + group.getName(), server, world); + } + + public void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException { + unsetPermission("group." + group.getName(), server, temporary); + } + + public void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException { + unsetPermission("group." + group.getName(), server, world, temporary); + } + /** * @return The temporary nodes held by the holder */ diff --git a/common/src/main/java/me/lucko/luckperms/common/groups/Group.java b/common/src/main/java/me/lucko/luckperms/common/groups/Group.java index faf2f8fa..b5bd2f39 100644 --- a/common/src/main/java/me/lucko/luckperms/common/groups/Group.java +++ b/common/src/main/java/me/lucko/luckperms/common/groups/Group.java @@ -25,14 +25,9 @@ package me.lucko.luckperms.common.groups; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; -import me.lucko.luckperms.api.event.events.GroupAddEvent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.api.internal.GroupLink; -import me.lucko.luckperms.common.api.internal.PermissionHolderLink; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.utils.Identifiable; -import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; -import me.lucko.luckperms.exceptions.ObjectLacksException; @ToString(of = {"name"}) @EqualsAndHashCode(of = {"name"}, callSuper = false) @@ -67,190 +62,4 @@ public class Group extends PermissionHolder implements Identifiable { public String getFriendlyName() { return getDisplayName(); } - - /** - * check to see if a group inherits a group - * @param group The group to check membership of - * @return true if the user is a member of the group - */ - public boolean inheritsGroup(Group group) { - return group.getName().equalsIgnoreCase(this.getName()) || hasPermission("group." + group.getName(), true); - } - - /** - * check to see if the group inherits a group on a specific server - * @param group The group to check membership of - * @param server The server to check on - * @return true if the group inherits the group - */ - public boolean inheritsGroup(Group group, String server) { - return group.getName().equalsIgnoreCase(this.getName()) || hasPermission("group." + group.getName(), true, server); - } - - /** - * check to see if the group inherits a group on a specific server - * @param group The group to check membership of - * @param server The server to check on - * @param world The world to check on - * @return true if the group inherits the group - */ - public boolean inheritsGroup(Group group, String server, String world) { - return group.getName().equalsIgnoreCase(this.getName()) || hasPermission("group." + group.getName(), true, server, world); - } - - /** - * Make this group inherit another group - * @param group the group to be inherited - * @throws ObjectAlreadyHasException if the group already inherits the group - */ - public void setInheritGroup(Group group) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, 0L)); - } - - /** - * Make this group inherit another group on a specific server - * @param group the group to be inherited - * @param server The server to add the group on - * @throws ObjectAlreadyHasException if the group already inherits the group on that server - */ - public void setInheritGroup(Group group, String server) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true, server); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, 0L)); - } - - /** - * Make this group inherit another group on a specific server - * @param group the group to be inherited - * @param server The server to add the group on - * @param world The world to add the group on - * @throws ObjectAlreadyHasException if the group already inherits the group on that server - */ - public void setInheritGroup(Group group, String server, String world) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true, server, world); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, 0L)); - } - - /** - * Make this group inherit another group on a specific server - * @param group the group to be inherited - * @param expireAt when the group should expire - * @throws ObjectAlreadyHasException if the group already inherits the group on that server - */ - public void setInheritGroup(Group group, long expireAt) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true, expireAt); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, expireAt)); - } - - /** - * Make this group inherit another group on a specific server - * @param group the group to be inherited - * @param server The server to add the group on - * @param expireAt when the group should expire - * @throws ObjectAlreadyHasException if the group already inherits the group on that server - */ - public void setInheritGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true, server, expireAt); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, expireAt)); - } - - /** - * Make this group inherit another group on a specific server - * @param group the group to be inherited - * @param server The server to add the group on - * @param world The world to add the group on - * @param expireAt when the group should expire - * @throws ObjectAlreadyHasException if the group already inherits the group on that server - */ - public void setInheritGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException { - if (group.getName().equalsIgnoreCase(this.getName())) { - throw new ObjectAlreadyHasException(); - } - - setPermission("group." + group.getName(), true, server, world, expireAt); - getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, expireAt)); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group) throws ObjectLacksException { - unsetPermission("group." + group.getName()); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @param temporary if the group being removed is temporary - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group, boolean temporary) throws ObjectLacksException { - unsetPermission("group." + group.getName(), temporary); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @param server The server to remove the group on - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group, String server) throws ObjectLacksException { - unsetPermission("group." + group.getName(), server); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @param server The server to remove the group on - * @param world The world to remove the group on - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group, String server, String world) throws ObjectLacksException { - unsetPermission("group." + group.getName(), server, world); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @param server The server to remove the group on - * @param temporary if the group being removed is temporary - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group, String server, boolean temporary) throws ObjectLacksException { - unsetPermission("group." + group.getName(), server, temporary); - } - - /** - * Remove a previously set inheritance - * @param group the group to uninherit - * @param server The server to remove the group on - * @param world The world to remove the group on - * @param temporary if the group being removed is temporary - * @throws ObjectLacksException if the group does not already inherit the group - */ - public void unsetInheritGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException { - unsetPermission("group." + group.getName(), server, world, temporary); - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/users/User.java b/common/src/main/java/me/lucko/luckperms/common/users/User.java index 219c3de3..8674bb9f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/users/User.java +++ b/common/src/main/java/me/lucko/luckperms/common/users/User.java @@ -26,18 +26,12 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import me.lucko.luckperms.api.event.events.GroupAddEvent; import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.api.internal.GroupLink; -import me.lucko.luckperms.common.api.internal.PermissionHolderLink; import me.lucko.luckperms.common.api.internal.UserLink; import me.lucko.luckperms.common.caching.UserData; import me.lucko.luckperms.common.core.PermissionHolder; -import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.Identifiable; -import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; -import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.UUID; @@ -128,168 +122,6 @@ public class User extends PermissionHolder implements Identifiable