2011-05-04 10:39:56 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
2011-11-21 01:55:26 +00:00
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2014-03-20 15:54:07 +00:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
2011-05-04 10:39:56 +00:00
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import org.bukkit.Server;
|
2011-05-04 14:23:22 +00:00
|
|
|
|
2011-05-04 10:39:56 +00:00
|
|
|
|
2013-06-08 11:53:23 +00:00
|
|
|
public class Commandsocialspy extends EssentialsToggleCommand
|
2011-05-04 10:39:56 +00:00
|
|
|
{
|
|
|
|
public Commandsocialspy()
|
|
|
|
{
|
2013-06-08 11:53:23 +00:00
|
|
|
super("socialspy", "essentials.socialspy.others");
|
2011-05-04 10:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-16 19:59:39 +00:00
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception
|
2011-05-04 10:39:56 +00:00
|
|
|
{
|
2013-06-08 11:53:23 +00:00
|
|
|
toggleOtherPlayers(server, sender, args);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
|
|
|
{
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
Boolean toggle = matchToggleArgument(args[0]);
|
|
|
|
if (toggle == null && user.isAuthorized(othersPermission))
|
|
|
|
{
|
2013-10-16 19:59:39 +00:00
|
|
|
toggleOtherPlayers(server, user.getSource(), args);
|
2013-06-08 11:53:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-16 19:59:39 +00:00
|
|
|
togglePlayer(user.getSource(), user, toggle);
|
2013-06-08 11:53:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (args.length == 2 && user.isAuthorized(othersPermission))
|
2013-03-25 14:18:09 +00:00
|
|
|
{
|
2013-10-16 19:59:39 +00:00
|
|
|
toggleOtherPlayers(server, user.getSource(), args);
|
2013-03-25 14:18:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-16 19:59:39 +00:00
|
|
|
togglePlayer(user.getSource(), user, null);
|
2013-03-25 14:18:09 +00:00
|
|
|
}
|
|
|
|
}
|
2013-03-25 14:05:35 +00:00
|
|
|
|
2013-03-25 14:18:09 +00:00
|
|
|
@Override
|
2013-10-16 19:59:39 +00:00
|
|
|
void togglePlayer(CommandSource sender, User user, Boolean enabled) throws NotEnoughArgumentsException
|
2013-03-25 14:18:09 +00:00
|
|
|
{
|
2013-06-08 11:53:23 +00:00
|
|
|
if (enabled == null)
|
2013-03-25 14:18:09 +00:00
|
|
|
{
|
2013-06-26 06:56:56 +00:00
|
|
|
enabled = !user.isSocialSpyEnabled();
|
2013-03-25 14:18:09 +00:00
|
|
|
}
|
2013-06-08 11:53:23 +00:00
|
|
|
|
|
|
|
user.setSocialSpyEnabled(enabled);
|
|
|
|
|
|
|
|
|
2014-03-20 15:54:07 +00:00
|
|
|
user.sendMessage(tl("socialSpy", user.getDisplayName(), enabled ? tl("enabled") : tl("disabled")));
|
2013-10-18 06:43:37 +00:00
|
|
|
if (!sender.isPlayer() || !sender.getPlayer().equals(user.getBase()))
|
2013-03-25 14:18:09 +00:00
|
|
|
{
|
2014-03-20 15:54:07 +00:00
|
|
|
sender.sendMessage(tl("socialSpy", user.getDisplayName(), enabled ? tl("enabled") : tl("disabled")));
|
2013-03-25 14:18:09 +00:00
|
|
|
}
|
2011-05-04 10:39:56 +00:00
|
|
|
}
|
|
|
|
}
|