mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-28 05:54:16 +02:00
Broadcast cancellation
This commit is contained in:
@@ -237,8 +237,6 @@ public class SModMenu extends PageableCustomInventory {
|
|||||||
if (punishment.isActive()){
|
if (punishment.isActive()){
|
||||||
if ((punishment.type == PunishmentType.BAN && player.hasPermission("smod.cancelBan")) || (punishment.type == PunishmentType.MUTE && player.hasPermission("smod.cancelMute"))) {
|
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));
|
item.editMeta(meta -> meta.getPersistentDataContainer().set(PUNISHMENT_STORE_KEY, PersistentDataType.LONG, punishment.time));
|
||||||
} else {
|
|
||||||
System.out.println("asd");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory.setItem(i, item);
|
inventory.setItem(i, item);
|
||||||
@@ -266,14 +264,11 @@ public class SModMenu extends PageableCustomInventory {
|
|||||||
if (punishment != null) {
|
if (punishment != null) {
|
||||||
new ConfirmationInventory(player, "Do you want to cancel this punishment?", () -> {
|
new ConfirmationInventory(player, "Do you want to cancel this punishment?", () -> {
|
||||||
punishment.cancel(player.getUniqueId());
|
punishment.cancel(player.getUniqueId());
|
||||||
|
punishment.broadcastCancellation(container);
|
||||||
player.playSound(player, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
player.playSound(player, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
||||||
this.open();
|
this.open();
|
||||||
}, this::open, false).open();
|
}, this::open, false).open();
|
||||||
} else {
|
|
||||||
System.out.println("kalsjkdaklsjd");
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
System.out.println("asasdasd");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,27 @@ public class Punishment {
|
|||||||
return buffer.array();
|
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
|
* @deprecated behaves weirdly, does not support punishment reasons
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user