Improve PunishmentCommand Permissions

This commit is contained in:
2025-10-28 17:07:50 +01:00
parent 2410ea3979
commit 4c730bcc48
2 changed files with 15 additions and 14 deletions
@@ -181,7 +181,7 @@ public class PunishmentCommand {
private final Punishment.PunishmentType punishmentType;
private PunishCommand(String command, Punishment.PunishmentType punishmentType) {
super(command, UserPerm.TEAM);
super(command, punishmentType.getUserPerm());
this.command = command;
this.punishmentType = punishmentType;
}
@@ -196,7 +196,7 @@ public class PunishmentCommand {
@Register
public void genericCommand(Chatter sender, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
SteamwarUser punisher = sender.user();
if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION))
if (!punisher.hasPerm(punishmentType.getUserPerm()))
return;
SteamwarUser target = unsafeUser(sender, toPunish);
@@ -246,14 +246,15 @@ public class PunishmentCommand {
private final Punishment.PunishmentType punishmentType;
private UnpunishCommand(String command, Punishment.PunishmentType punishmentType) {
super(command, UserPerm.TEAM);
super(command, punishmentType.getUserPerm());
this.command = command;
this.punishmentType = punishmentType;
}
@Register
public void genericCommand(Chatter sender, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
if (punishmentType.isNeedsAdmin() && !sender.user().hasPerm(UserPerm.MODERATION))
SteamwarUser punisher = sender.user();
if (!punisher.hasPerm(punishmentType.getUserPerm()))
return;
if (!target.isPunished(punishmentType)) {