TotalFreedomMod/src/me/totalfreedom/totalfreedommod/commands/Command_invis.java

69 lines
2.0 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
import java.util.ArrayList;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.AdminList;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
public class Command_invis extends FreedomCommand
2013-07-02 18:31:22 +00:00
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean smite = false;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("smite"))
{
FUtil.adminAction(sender.getName(), "Smiting all invisible players", true);
smite = true;
}
else
{
return false;
}
}
List<String> players = new ArrayList<String>();
int smites = 0;
2013-08-14 14:01:42 +00:00
for (Player player : server.getOnlinePlayers())
{
2013-08-14 14:01:42 +00:00
if (player.hasPotionEffect(PotionEffectType.INVISIBILITY))
2013-07-02 18:31:22 +00:00
{
2013-08-14 14:01:42 +00:00
players.add(player.getName());
if (smite && !plugin.al.isAdmin(player))
{
2014-02-16 18:02:21 +00:00
player.setHealth(0.0);
smites++;
}
}
}
2013-07-02 18:31:22 +00:00
if (players.isEmpty())
{
playerMsg("There are no invisible players");
return true;
}
if (smite)
{
playerMsg("Smitten " + smites + " players");
}
else
{
2015-05-01 01:04:50 +00:00
playerMsg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
}
return true;
}
2013-05-15 18:03:45 +00:00
}