diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmute.java index b5c7302b5a7..b028742bf5d 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmute.java @@ -21,6 +21,7 @@ public Commandmute() { @Override public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception { + final boolean isUnmute = commandLabel.toLowerCase(java.util.Locale.ENGLISH).contains("unmute"); boolean nomatch = false; if (args.length < 1) { throw new NotEnoughArgumentsException(); @@ -32,11 +33,17 @@ public void run(final Server server, final CommandSource sender, final String co nomatch = true; user = ess.getUser(new OfflinePlayerStub(args[0], ess.getServer())); } + + if (isUnmute && !user.getMuted()) { + sender.sendTl("playerNotMuted", user.getDisplayName()); + return; + } + if (!user.getBase().isOnline() && sender.isPlayer()) { if (!sender.isAuthorized("essentials.mute.offline")) { throw new TranslatableException("muteExemptOffline"); } - } else if (user.isAuthorized("essentials.mute.exempt")) { + } else if (!isUnmute && user.isAuthorized("essentials.mute.exempt")) { throw new TranslatableException("muteExempt"); } @@ -44,7 +51,7 @@ public void run(final Server server, final CommandSource sender, final String co final String time; String muteReason = null; - if (args.length > 1) { + if (!isUnmute && args.length > 1) { time = args[1]; try { muteTimestamp = DateUtil.parseDateDiff(time, true); @@ -59,7 +66,7 @@ public void run(final Server server, final CommandSource sender, final String co } } - final boolean willMute = (args.length > 1) || !user.getMuted(); + final boolean willMute = !isUnmute && ((args.length > 1) || !user.getMuted()); final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null; final MuteStatusChangeEvent event = new MuteStatusChangeEvent(user, controller, willMute, muteTimestamp, muteReason); ess.getServer().getPluginManager().callEvent(event); @@ -121,6 +128,8 @@ public void run(final Server server, final CommandSource sender, final String co } else { sender.sendTl("unmutedPlayer", user.getDisplayName()); user.sendTl("playerUnmuted"); + ess.getLogger().log(Level.INFO, ess.getAdventureFacet().miniToLegacy(tlLiteral("unmuteNotify", sender.getSender().getName(), user.getName()))); + ess.broadcastTl(null, "essentials.mute.notify", "unmuteNotify", new Object[]{sender.getSender().getName(), user.getName()}); } } } diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 50e945d886f..fe2fd99baee 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -1480,7 +1480,9 @@ unlinkCommandDescription=Unlinks your Minecraft account from the currently linke unlinkCommandUsage=/ unlinkCommandUsage1=/ unlinkCommandUsage1Description=Unlinks your Minecraft account from the currently linked Discord account. +unmuteNotify={0} unmuted {1}. unmutedPlayer=Player {0} unmuted. +playerNotMuted={0} is not muted. unsafeTeleportDestination=The teleport destination is unsafe and teleport-safety is disabled. unsupportedBrand=The server platform you are currently running does not provide the capabilities for this feature. unsupportedFeature=This feature is not supported on the current server version. diff --git a/Essentials/src/main/resources/messages_en.properties b/Essentials/src/main/resources/messages_en.properties index 0689d5b2948..67fe0229f8e 100644 --- a/Essentials/src/main/resources/messages_en.properties +++ b/Essentials/src/main/resources/messages_en.properties @@ -1463,7 +1463,9 @@ unlinkCommandDescription=Unlinks your Minecraft account from the currently linke unlinkCommandUsage=/ unlinkCommandUsage1=/ unlinkCommandUsage1Description=Unlinks your Minecraft account from the currently linked Discord account. +unmuteNotify={0} unmuted {1}. unmutedPlayer=Player {0} unmuted. +playerNotMuted={0} is not muted. unsafeTeleportDestination=The teleport destination is unsafe and teleport-safety is disabled. unsupportedBrand=The server platform you are currently running does not provide the capabilities for this feature. unsupportedFeature=This feature is not supported on the current server version. diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 844f9231926..4c578304f3e 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -314,7 +314,7 @@ commands: mute: description: Mutes or unmutes a player. usage: / [datediff] [reason] - aliases: [emute,silence,esilence] + aliases: [emute,silence,esilence,unmute,eunmute] near: description: Lists the players near by or around a player. usage: / [playername] [radius]