TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java

58 lines
1.8 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.List;
2011-10-19 00:37:00 +00:00
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
2011-10-19 00:37:00 +00:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Quick De-Op - deop someone based on a partial name.", usage = "/<command> <partialname>")
2011-10-19 00:37:00 +00:00
public class Command_qdeop extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
2011-10-19 00:37:00 +00:00
{
return false;
}
boolean silent = false;
if (args.length == 2)
{
silent = args[1].equalsIgnoreCase("-s");
}
final String targetName = args[0].toLowerCase();
final List<String> matchedPlayerNames = new ArrayList<String>();
for (final Player player : server.getOnlinePlayers())
{
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
2011-10-19 00:37:00 +00:00
{
matchedPlayerNames.add(player.getName());
2013-08-14 14:01:42 +00:00
player.setOp(false);
player.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP);
2011-10-19 00:37:00 +00:00
}
}
if (!matchedPlayerNames.isEmpty())
{
if (!silent)
{
TFM_Util.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
}
}
else
2011-10-19 00:37:00 +00:00
{
playerMsg("No targets matched.");
2011-10-19 00:37:00 +00:00
}
return true;
}
}