blob: 2426df15102cc69a0ba6ed2183874cd6e1952158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.api.server.CommandSender;
import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.user.UserData.TimestampType;
import com.earth2me.essentials.utils.DateUtil;
import lombok.Cleanup;
import org.bukkit.command.CommandSender;
public class Commandmute extends EssentialsCommand
{
@Override
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
@Cleanup
final IUser player = getPlayer(args, 0, true);
player.acquireReadLock();
if (!player.getData().isMuted() && Permissions.MUTE_EXEMPT.isAuthorized(player))
{
throw new Exception(_("muteExempt"));
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = DateUtil.parseDateDiff(time, true);
}
player.setTimestamp(TimestampType.MUTE, muteTimestamp);
final boolean muted = player.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? _("mutedPlayerFor", player.getDisplayName(), DateUtil.formatDateDiff(muteTimestamp))
: _("mutedPlayer", player.getDisplayName()))
: _("unmutedPlayer", player.getDisplayName()));
player.sendMessage(
muted
? (muteTimestamp > 0
? _("playerMutedFor", DateUtil.formatDateDiff(muteTimestamp))
: _("playerMuted"))
: _("playerUnmuted"));
}
}
|