From 6a2b66811c111f5993260705bb2f54bc1a5239b2 Mon Sep 17 00:00:00 2001 From: James Mortemore Date: Sun, 6 Mar 2022 09:54:29 +0000 Subject: [PATCH] feat: added bm.command.unmuteip.own & bm.command.unbanip.own permissions Part of #965 --- .../banmanager/common/commands/UnbanIpCommand.java | 6 ++++++ .../banmanager/common/commands/UnmuteIpCommand.java | 8 ++++++-- common/src/main/resources/messages.yml | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/me/confuser/banmanager/common/commands/UnbanIpCommand.java b/common/src/main/java/me/confuser/banmanager/common/commands/UnbanIpCommand.java index 3e45e236..1018071f 100644 --- a/common/src/main/java/me/confuser/banmanager/common/commands/UnbanIpCommand.java +++ b/common/src/main/java/me/confuser/banmanager/common/commands/UnbanIpCommand.java @@ -78,6 +78,12 @@ public boolean onCommand(final CommonSender sender, CommandParser originalParser IpBanData ban = getPlugin().getIpBanStorage().getBan(ip); PlayerData actor = sender.getData(); + if (!actor.getUUID().equals(ban.getActor().getUUID()) && !sender.hasPermission("bm.exempt.override.banip") + && sender.hasPermission("bm.command.unbanip.own")) { + Message.get("unbanip.error.notOwn").set("ip", ipStr).sendTo(sender); + return; + } + boolean unbanned; try { diff --git a/common/src/main/java/me/confuser/banmanager/common/commands/UnmuteIpCommand.java b/common/src/main/java/me/confuser/banmanager/common/commands/UnmuteIpCommand.java index 6aa255e5..5bb9aa59 100644 --- a/common/src/main/java/me/confuser/banmanager/common/commands/UnmuteIpCommand.java +++ b/common/src/main/java/me/confuser/banmanager/common/commands/UnmuteIpCommand.java @@ -63,10 +63,14 @@ public boolean onCommand(final CommonSender sender, CommandParser parser) { } IpMuteData mute = getPlugin().getIpMuteStorage().getMute(ip); - final PlayerData actor = sender.getData(); - if (actor == null) return; + if (!actor.getUUID().equals(mute.getActor().getUUID()) && !sender.hasPermission("bm.exempt.override.muteip") + && sender.hasPermission("bm.command.unmuteip.own")) { + Message.get("unmuteip.error.notOwn").set("ip", ipStr).sendTo(sender); + return; + } + boolean unmuted; diff --git a/common/src/main/resources/messages.yml b/common/src/main/resources/messages.yml index 011775a1..5e2ce1af 100644 --- a/common/src/main/resources/messages.yml +++ b/common/src/main/resources/messages.yml @@ -277,6 +277,7 @@ messages: notify: '&6[ip] has been unbanned by [actor]' error: noExists: '&c[ip] is not banned' + notOwn: '&c[ip] was not banned by you, unable to unban' unbanipall: notify: '&6[ip] will be unbanned by [actor]'