Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -32,19 +33,25 @@ 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");
}

long muteTimestamp = 0;
final String time;
String muteReason = null;

if (args.length > 1) {
if (!isUnmute && args.length > 1) {
time = args[1];
try {
muteTimestamp = DateUtil.parseDateDiff(time, true);
Expand All @@ -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);
Expand Down Expand Up @@ -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()});
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,9 @@ unlinkCommandDescription=Unlinks your Minecraft account from the currently linke
unlinkCommandUsage=/<command>
unlinkCommandUsage1=/<command>
unlinkCommandUsage1Description=Unlinks your Minecraft account from the currently linked Discord account.
unmuteNotify=<secondary>{0} <primary>unmuted<secondary> {1}<primary>.
unmutedPlayer=<primary>Player<secondary> {0} <primary>unmuted.
playerNotMuted=<secondary>{0} <primary>is not muted.
unsafeTeleportDestination=<dark_red>The teleport destination is unsafe and teleport-safety is disabled.
unsupportedBrand=<dark_red>The server platform you are currently running does not provide the capabilities for this feature.
unsupportedFeature=<dark_red>This feature is not supported on the current server version.
Expand Down
2 changes: 2 additions & 0 deletions Essentials/src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,9 @@ unlinkCommandDescription=Unlinks your Minecraft account from the currently linke
unlinkCommandUsage=/<command>
unlinkCommandUsage1=/<command>
unlinkCommandUsage1Description=Unlinks your Minecraft account from the currently linked Discord account.
unmuteNotify=<secondary>{0} <primary>unmuted<secondary> {1}<primary>.
unmutedPlayer=<primary>Player<secondary> {0} <primary>unmuted.
playerNotMuted=<secondary>{0} <primary>is not muted.
unsafeTeleportDestination=<dark_red>The teleport destination is unsafe and teleport-safety is disabled.
unsupportedBrand=<dark_red>The server platform you are currently running does not provide the capabilities for this feature.
unsupportedFeature=<dark_red>This feature is not supported on the current server version.
Expand Down
2 changes: 1 addition & 1 deletion Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ commands:
mute:
description: Mutes or unmutes a player.
usage: /<command> <player> [datediff] [reason]
aliases: [emute,silence,esilence]
aliases: [emute,silence,esilence,unmute,eunmute]
near:
description: Lists the players near by or around a player.
usage: /<command> [playername] [radius]
Expand Down
Loading