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

53 lines
1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
public class Commandafk extends EssentialsCommand
{
public Commandafk()
{
super("afk");
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
{
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
if (afkUser != null)
{
toggleAfk(afkUser);
}
}
else
{
toggleAfk(user);
}
}
2011-11-18 18:07:28 +00:00
private void toggleAfk(User user)
{
if (!user.toggleAfk())
{
2011-08-27 20:29:57 +00:00
//user.sendMessage(Util.i18n("markedAsNotAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
}
user.updateActivity(false);
}
else
{
2011-08-27 20:29:57 +00:00
//user.sendMessage(Util.i18n("markedAsAway"));
if (!user.isHidden())
{
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
}
}
}
}