You can no longer ban or mute a player who is already banned or muted.

This commit is contained in:
Brianna 2019-06-02 18:48:51 -04:00
parent 50ddb12419
commit 19ab706cc4
4 changed files with 24 additions and 0 deletions

View File

@ -50,6 +50,12 @@ public class CommandBan extends AbstractCommand {
return ReturnType.FAILURE;
}
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
sender.sendMessage(instance.getReferences().getPrefix() + "That player is already banned.");
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
.execute(sender, player);

View File

@ -50,6 +50,12 @@ public class CommandMute extends AbstractCommand {
return ReturnType.FAILURE;
}
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
sender.sendMessage(instance.getReferences().getPrefix() + "That player is already muted.");
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.MUTE, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
.execute(sender, player);

View File

@ -33,6 +33,12 @@ public class CommandUnBan extends AbstractCommand {
return ReturnType.FAILURE;
}
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
sender.sendMessage(instance.getReferences().getPrefix() + "That player isn't banned.");
return ReturnType.FAILURE;
}
PlayerPunishData playerPunishData = instance.getPunishmentManager().getPlayer(player);
playerPunishData.expirePunishments(PunishmentType.BAN);

View File

@ -32,6 +32,12 @@ public class CommandUnMute extends AbstractCommand {
return ReturnType.FAILURE;
}
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
sender.sendMessage(instance.getReferences().getPrefix() + "That player isn't muted.");
return ReturnType.FAILURE;
}
PlayerPunishData playerPunishData = instance.getPunishmentManager().getPlayer(player);
playerPunishData.expirePunishments(PunishmentType.MUTE);