blob: 5cbba493b7461f944db9d5d0d53bcb7b08522000 (
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
53
|
package net.ess3.commands;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
import net.ess3.user.UserData.TimestampType;
import net.ess3.utils.DateUtil;
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();
}
final IUser player = ess.getUserMap().matchUser(args[0], false, true);
if (!player.getData().isMuted() && Permissions.MUTE_EXEMPT.isAuthorized(player))
{
throw new Exception(_("muteExempt"));
}
long muteTimestamp = 0;
if (args.length > 1)
{
final String time = getFinalArg(args, 1);
muteTimestamp = DateUtil.parseDateDiff(time, true);
player.setMuted(true);
}
else
{
player.setMuted(!player.getData().isMuted());
}
player.setTimestamp(TimestampType.MUTE, muteTimestamp);
final boolean muted = player.getData().isMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? _("mutedPlayerFor", player.getPlayer().getDisplayName(), DateUtil.formatDateDiff(muteTimestamp))
: _("mutedPlayer", player.getPlayer().getDisplayName()))
: _("unmutedPlayer", player.getPlayer().getDisplayName()));
player.sendMessage(
muted
? (muteTimestamp > 0
? _("playerMutedFor", DateUtil.formatDateDiff(muteTimestamp))
: _("playerMuted"))
: _("playerUnmuted"));
}
}
|