TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandmute.java

54 lines
1.3 KiB
Java

package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandmute extends EssentialsCommand
{
public Commandmute()
{
super("mute");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0, true);
if (p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(commandLabel);
return;
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
}
p.setMuteTimeout(muteTimestamp);
charge(sender);
boolean muted = p.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}