mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Add some missing arg-based permission checks
This commit is contained in:
parent
e183f520d6
commit
7d7d40b087
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.group;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||
@ -70,6 +71,11 @@ public class DeleteGroup extends SingleCommand {
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), group)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.group;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
||||
@ -51,6 +52,11 @@ public class GroupRename extends ChildCommand<Group> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Group target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String newGroupName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(newGroupName)) {
|
||||
Message.GROUP_INVALID_ENTRY.send(sender, newGroupName);
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.SingleCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||
@ -64,6 +65,11 @@ public class DeleteTrack extends SingleCommand {
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), track)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||
@ -53,6 +54,11 @@ public class TrackAppend extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
||||
@ -45,6 +46,11 @@ public class TrackClear extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
target.clearGroups();
|
||||
Message.TRACK_CLEAR.send(sender, target.getName());
|
||||
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
||||
@ -49,6 +50,11 @@ public class TrackClone extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String newTrackName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(newTrackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, newTrackName);
|
||||
@ -61,6 +67,11 @@ public class TrackClone extends ChildCommand<Track> {
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), newTrack)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
newTrack.setGroups(target.getGroups());
|
||||
|
||||
Message.CLONE_SUCCESS.send(sender, Component.text(target.getName()), Component.text(newTrack.getName()));
|
||||
|
@ -27,6 +27,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
||||
@ -43,6 +44,11 @@ public class TrackInfo extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
Message.TRACK_INFO.send(sender, target.getName(), Message.formatTrackPath(target.getGroups()));
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||
@ -53,6 +54,11 @@ public class TrackInsert extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.tabcomplete.TabCompleter;
|
||||
@ -52,6 +53,11 @@ public class TrackRemove extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String groupName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.GROUP_NAME_TEST.test(groupName)) {
|
||||
sendDetailedUsage(sender, label);
|
||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.commands.track;
|
||||
import me.lucko.luckperms.common.actionlog.LoggedAction;
|
||||
import me.lucko.luckperms.common.command.CommandResult;
|
||||
import me.lucko.luckperms.common.command.abstraction.ChildCommand;
|
||||
import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.spec.CommandSpec;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
||||
@ -50,6 +51,11 @@ public class TrackRename extends ChildCommand<Track> {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Track target, ArgumentList args, String label) {
|
||||
if (ArgumentPermissions.checkModifyPerms(plugin, sender, getPermission().get(), target)) {
|
||||
Message.COMMAND_NO_PERMISSION.send(sender);
|
||||
return CommandResult.NO_PERMISSION;
|
||||
}
|
||||
|
||||
String newTrackName = args.get(0).toLowerCase();
|
||||
if (!DataConstraints.TRACK_NAME_TEST.test(newTrackName)) {
|
||||
Message.TRACK_INVALID_ENTRY.send(sender, newTrackName);
|
||||
|
Loading…
Reference in New Issue
Block a user