2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2013-05-15 13:23:18 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2013-05-15 13:23:18 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2014-11-29 19:16:00 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2013-05-15 13:23:18 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
2013-05-15 13:23:18 +00:00
|
|
|
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_invis extends FreedomCommand
|
2013-07-02 18:31:22 +00:00
|
|
|
{
|
2013-05-15 13:23:18 +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"))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Smiting all invisible players", true);
|
2013-05-15 13:23:18 +00:00
|
|
|
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-05-15 13:23:18 +00:00
|
|
|
{
|
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());
|
2015-10-19 17:43:46 +00:00
|
|
|
if (smite && !plugin.al.isAdmin(player))
|
2013-05-15 13:23:18 +00:00
|
|
|
{
|
2014-02-16 18:02:21 +00:00
|
|
|
player.setHealth(0.0);
|
2013-05-15 13:23:18 +00:00
|
|
|
smites++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-02 18:31:22 +00:00
|
|
|
if (players.isEmpty())
|
|
|
|
{
|
2014-08-14 19:49:48 +00:00
|
|
|
playerMsg("There are no invisible players");
|
2013-05-15 13:23:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (smite)
|
|
|
|
{
|
2014-08-14 19:49:48 +00:00
|
|
|
playerMsg("Smitten " + smites + " players");
|
2013-05-15 13:23:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-01 01:04:50 +00:00
|
|
|
playerMsg("Invisible players (" + players.size() + "): " + StringUtils.join(players, ", "));
|
2013-05-15 13:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-15 18:03:45 +00:00
|
|
|
}
|