mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
refactor inheritance commands
This commit is contained in:
parent
782c09b686
commit
045539c752
@ -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);
|
||||
|
@ -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
|
||||
|
@ -133,15 +133,15 @@ public abstract class SubCommand<T> {
|
||||
* ----------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected static List<String> getGroupTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
public static List<String> getGroupTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getGroupManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
protected static List<String> getTrackTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
public static List<String> getTrackTabComplete(List<String> args, LuckPermsPlugin plugin) {
|
||||
return getTabComplete(new ArrayList<>(plugin.getTrackManager().getAll().keySet()), args);
|
||||
}
|
||||
|
||||
protected static List<String> getBoolTabComplete(List<String> args) {
|
||||
public static List<String> getBoolTabComplete(List<String> args) {
|
||||
if (args.size() == 2) {
|
||||
return Arrays.asList("true", "false");
|
||||
} else {
|
||||
@ -161,7 +161,7 @@ public abstract class SubCommand<T> {
|
||||
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<T> {
|
||||
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<T> {
|
||||
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 {
|
||||
|
@ -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<T extends PermissionHolder> extends SubCommand<T> {
|
||||
public class SecondaryMainCommand<T extends PermissionHolder> extends SubCommand<T> {
|
||||
private boolean user;
|
||||
private final List<SecondarySubCommand> secondaryCommands;
|
||||
|
||||
private final List<MetaSubCommand> subCommands = ImmutableList.<MetaSubCommand>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<SecondarySubCommand> 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<String> args, String label) {
|
||||
if (args.size() == 0) {
|
||||
sendUsageMeta(sender, user, label);
|
||||
sendUsageDetailed(sender, user, label);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Optional<MetaSubCommand> o = subCommands.stream()
|
||||
Optional<SecondarySubCommand> o = secondaryCommands.stream()
|
||||
.filter(s -> s.getName().equalsIgnoreCase(args.get(0)))
|
||||
.limit(1)
|
||||
.findAny();
|
||||
@ -72,7 +60,7 @@ public class MetaCommands<T extends PermissionHolder> extends SubCommand<T> {
|
||||
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<T extends PermissionHolder> extends SubCommand<T> {
|
||||
return sub.execute(plugin, sender, t, strippedArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
final List<SecondarySubCommand> 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<SecondarySubCommand> 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<T extends PermissionHolder> extends SubCommand<T> {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendUsageMeta(Sender sender, boolean user, String label) {
|
||||
List<MetaSubCommand> subs = subCommands.stream()
|
||||
private void sendUsageDetailed(Sender sender, boolean user, String label) {
|
||||
List<SecondarySubCommand> 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 <user> meta ...)", label));
|
||||
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s user <user> " + getName().toLowerCase() + " ...)", label));
|
||||
} else {
|
||||
Util.sendPluginMessage(sender, "&bMeta Sub Commands: &7(" + String.format("/%s group <group> meta ...)", label));
|
||||
Util.sendPluginMessage(sender, "&b" + getName() + " Sub Commands: &7(" + String.format("/%s group <group> " + getName().toLowerCase() + " ...)", label));
|
||||
}
|
||||
|
||||
for (MetaSubCommand s : subs) {
|
||||
for (SecondarySubCommand s : subs) {
|
||||
s.sendUsage(sender);
|
||||
}
|
||||
|
@ -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<String> args);
|
||||
|
||||
public List<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> 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();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* 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<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public CommandMeta(boolean user) {
|
||||
super("Meta", "Edit metadata values", user, ImmutableList.<SecondarySubCommand>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());
|
||||
}
|
||||
}
|
@ -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(
|
@ -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(
|
@ -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(
|
@ -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(
|
@ -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(
|
@ -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);
|
||||
}
|
@ -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(
|
@ -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(
|
@ -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(
|
@ -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(
|
@ -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<User> {
|
||||
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<String> 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<T extends PermissionHolder> extends SecondaryMainCommand<T> {
|
||||
public CommandParent(boolean user) {
|
||||
super("Parent", "Edit inheritances", user, ImmutableList.<SecondarySubCommand>builder()
|
||||
.add(new ParentInfo())
|
||||
.add(new ParentAdd())
|
||||
.add(new ParentRemove())
|
||||
.add(new ParentAddTemp())
|
||||
.add(new ParentRemoveTemp())
|
||||
.build());
|
||||
}
|
||||
}
|
@ -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<User> {
|
||||
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<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
@ -74,32 +81,32 @@ public class UserAddGroup extends SubCommand<User> {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
@ -81,7 +88,7 @@ public class UserAddTempGroup extends SubCommand<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<Group> {
|
||||
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<String> 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<String> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
@ -53,6 +61,15 @@ public class UserRemoveTempGroup extends SubCommand<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, User user, List<String> args, String label) {
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, List<String> args) {
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
|
||||
if (ArgumentChecker.checkNode(groupName)) {
|
||||
@ -53,12 +60,6 @@ public class UserRemoveGroup extends SubCommand<User> {
|
||||
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<User> {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<Group> {
|
||||
public GroupMainCommand() {
|
||||
super("Group", "/%s group <group>", 2, ImmutableList.<SubCommand<Group>>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())
|
||||
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* 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<Group> {
|
||||
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<String> 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<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* 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<Group> {
|
||||
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<String> 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<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* 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<Group> {
|
||||
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<String> 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<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Lucko (Luck) <luck@lucko.me>
|
||||
*
|
||||
* 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<Group> {
|
||||
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<String> 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<String> onTabComplete(LuckPermsPlugin plugin, Sender sender, List<String> args) {
|
||||
return getGroupTabComplete(args, plugin);
|
||||
}
|
||||
}
|
@ -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<User> {
|
||||
public UserMainCommand() {
|
||||
super("User", "/%s user <user>", 2, ImmutableList.<SubCommand<User>>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()
|
||||
|
@ -100,7 +100,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
user.unsetPermission("group." + old);
|
||||
} catch (ObjectLacksException ignored) {}
|
||||
try {
|
||||
user.addGroup(previousGroup);
|
||||
user.setInheritGroup(previousGroup);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
user.setPrimaryGroup(previousGroup.getName());
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
user.unsetPermission("group." + old);
|
||||
} catch (ObjectLacksException ignored) {}
|
||||
try {
|
||||
user.addGroup(nextGroup);
|
||||
user.setInheritGroup(nextGroup);
|
||||
} catch (ObjectAlreadyHasException ignored) {}
|
||||
user.setPrimaryGroup(nextGroup.getName());
|
||||
|
||||
|
@ -53,10 +53,10 @@ public class UserSetPrimaryGroup extends SubCommand<User> {
|
||||
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) {}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@ import me.lucko.luckperms.exceptions.ObjectLacksException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
// "<group|null> <server|world> <from> <to>",
|
||||
public class BulkEditGroup extends SubCommand<Datastore> {
|
||||
public BulkEditGroup() {
|
||||
super("group", "Bulk edit group memberships", Permission.USER_BULKCHANGE, Predicate.not(4),
|
||||
|
@ -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" +
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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<String> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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<UserIdentifie
|
||||
getPlugin().getApiProvider().fireEventAsync(new UserPermissionRefreshEvent(new UserLink(this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the user is a member of a group
|
||||
* @param group The group to check membership of
|
||||
* @return true if the user is a member of the group
|
||||
*/
|
||||
public boolean isInGroup(Group group) {
|
||||
return hasPermission("group." + group.getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a user is a member of 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 user is a member of the group
|
||||
*/
|
||||
public boolean isInGroup(Group group, String server) {
|
||||
return hasPermission("group." + group.getName(), true, server);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a user is a member of 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 user is a member of the group
|
||||
*/
|
||||
public boolean isInGroup(Group group, String server, String world) {
|
||||
return hasPermission("group." + group.getName(), true, server, world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group
|
||||
* @param group The group to add the user to
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group
|
||||
*/
|
||||
public void addGroup(Group group) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, 0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
*/
|
||||
public void addGroup(Group group, String server) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true, server);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, 0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @param world The world to add the group on
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
*/
|
||||
public void addGroup(Group group, String server, String world) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true, server, world);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, 0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
*/
|
||||
public void addGroup(Group group, long expireAt) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true, expireAt);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), null, null, expireAt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @param server The server to add the group on
|
||||
* @param expireAt when the group should expire
|
||||
* @throws ObjectAlreadyHasException if the user is already a member of the group on that server
|
||||
*/
|
||||
public void addGroup(Group group, String server, long expireAt) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true, server, expireAt);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, null, expireAt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to a group on a specific server
|
||||
* @param group The group to add the user to
|
||||
* @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 user is already a member of the group on that server
|
||||
*/
|
||||
public void addGroup(Group group, String server, String world, long expireAt) throws ObjectAlreadyHasException {
|
||||
setPermission("group." + group.getName(), true, server, world, expireAt);
|
||||
getPlugin().getApiProvider().fireEventAsync(new GroupAddEvent(new PermissionHolderLink(this), new GroupLink(group), server, world, expireAt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group the group to remove the user from
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group the group to remove the user from
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group, boolean temporary) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName(), temporary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group, String server) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName(), server);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @param world The world to remove the group on
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group, String server, String world) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName(), server, world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group The group to remove the user from
|
||||
* @param server The server to remove the group on
|
||||
* @param temporary if the group being removed is temporary
|
||||
* @throws ObjectLacksException if the user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group, String server, boolean temporary) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName(), server, temporary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user from a group
|
||||
* @param group The group to remove the user from
|
||||
* @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 user isn't a member of the group
|
||||
*/
|
||||
public void removeGroup(Group group, String server, String world, boolean temporary) throws ObjectLacksException {
|
||||
unsetPermission("group." + group.getName(), server, world, temporary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all of the users permission nodes
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user