diff --git a/src/main/java/de/shiewk/smoderation/inventory/SModMenu.java b/src/main/java/de/shiewk/smoderation/inventory/SModMenu.java index 794533c..fea86e8 100644 --- a/src/main/java/de/shiewk/smoderation/inventory/SModMenu.java +++ b/src/main/java/de/shiewk/smoderation/inventory/SModMenu.java @@ -237,8 +237,6 @@ public class SModMenu extends PageableCustomInventory { if (punishment.isActive()){ if ((punishment.type == PunishmentType.BAN && player.hasPermission("smod.cancelBan")) || (punishment.type == PunishmentType.MUTE && player.hasPermission("smod.cancelMute"))) { item.editMeta(meta -> meta.getPersistentDataContainer().set(PUNISHMENT_STORE_KEY, PersistentDataType.LONG, punishment.time)); - } else { - System.out.println("asd"); } } inventory.setItem(i, item); @@ -266,14 +264,11 @@ public class SModMenu extends PageableCustomInventory { if (punishment != null) { new ConfirmationInventory(player, "Do you want to cancel this punishment?", () -> { punishment.cancel(player.getUniqueId()); + punishment.broadcastCancellation(container); player.playSound(player, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f); this.open(); }, this::open, false).open(); - } else { - System.out.println("kalsjkdaklsjd"); } - } else { - System.out.println("asasdasd"); } } } diff --git a/src/main/java/de/shiewk/smoderation/punishments/Punishment.java b/src/main/java/de/shiewk/smoderation/punishments/Punishment.java index bf71dca..e71fdca 100644 --- a/src/main/java/de/shiewk/smoderation/punishments/Punishment.java +++ b/src/main/java/de/shiewk/smoderation/punishments/Punishment.java @@ -86,6 +86,27 @@ public class Punishment { return buffer.array(); } + private Component cancellationMessage(){ + String msg = ""; + switch (type){ + case MUTE -> msg = "unmuted"; + case KICK -> msg = "unkicked??"; + case BAN -> msg = "unbanned"; + } + return Component.text(PlayerUtil.offlinePlayerName(to)).color(SECONDARY_COLOR) + .append(Component.text(" was ").color(PRIMARY_COLOR)) + .append(Component.text(msg)) + .append(Component.text(" by ").color(PRIMARY_COLOR)) + .append(Component.text(PlayerUtil.offlinePlayerName(cancelledBy))) + .append(Component.text(".").color(PRIMARY_COLOR)); + } + + public void broadcastCancellation(PunishmentContainer container){ + for (CommandSender sender : container.collectBroadcastTargets()) { + sender.sendMessage(cancellationMessage()); + } + } + /** * @deprecated behaves weirdly, does not support punishment reasons */