Adjust /rtp <player> permission checks

This commit is contained in:
William committed 2022-08-26 13:42:16 +01:00
1 parent d985fb9742
commit 36703c55f5
2 files changed
+5 -5

No files matched your search

@@ -24,16 +24,16 @@ public class RtpCommand extends CommandBase implements ConsoleExecutable {
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
OnlineUser target = onlineUser;
if (args.length == 1) {
if (!onlineUser.hasPermission(Permission.COMMAND_RTP_OTHER.node)) {
plugin.getLocales().getLocale("error_no_permission").ifPresent(onlineUser::sendMessage);
return;
}
Optional<OnlineUser> foundUser = plugin.findPlayer(args[0]);
if (foundUser.isEmpty()) {
plugin.getLocales().getLocale("error_player_not_found", args[0])
.ifPresent(onlineUser::sendMessage);
return;
}
if (!onlineUser.hasPermission(Permission.COMMAND_RTP_OTHER.node)) {
plugin.getLocales().getLocale("error_no_permission").ifPresent(onlineUser::sendMessage);
return;
}
target = foundUser.get();
} else if (args.length > 1) {
plugin.getLocales().getLocale("error_invalid_syntax", "/rtp [player]")
@@ -132,7 +132,7 @@ public enum Permission {
* Lets the user randomly teleport in the world they are in ({@code /rtp})
*/
COMMAND_RTP("huskhomes.command.rtp", DefaultAccess.EVERYONE),
COMMAND_RTP_OTHER("huskhomes.command.rtp.other", DefaultAccess.EVERYONE),
COMMAND_RTP_OTHER("huskhomes.command.rtp.other", DefaultAccess.OPERATORS),
/**
* Lets the user teleport to the defined spawn position ({@code /spawn})
*/