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