2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2014-08-14 00:11:12 +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;
|
2011-10-19 00:37:00 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Quick De-Op - deop someone based on a partial name.", usage = "/<command> <partialname>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_qdeop extends FreedomCommand
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2011-10-19 00:37:00 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-03 01:03:12 +00:00
|
|
|
if (args.length < 1)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-01 19:43:03 +00:00
|
|
|
|
2012-11-03 01:03:12 +00:00
|
|
|
boolean silent = false;
|
|
|
|
if (args.length == 2)
|
|
|
|
{
|
|
|
|
silent = args[1].equalsIgnoreCase("-s");
|
|
|
|
}
|
|
|
|
|
2014-08-14 00:11:12 +00:00
|
|
|
final String targetName = args[0].toLowerCase();
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
final List<String> matchedPlayerNames = new ArrayList<>();
|
2014-08-14 00:11:12 +00:00
|
|
|
for (final Player player : server.getOnlinePlayers())
|
2012-09-16 17:41:41 +00:00
|
|
|
{
|
2014-08-14 00:11:12 +00:00
|
|
|
if (player.getName().toLowerCase().contains(targetName) || player.getDisplayName().toLowerCase().contains(targetName))
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2014-08-14 21:37:20 +00:00
|
|
|
if (player.isOp())
|
|
|
|
{
|
|
|
|
matchedPlayerNames.add(player.getName());
|
|
|
|
player.setOp(false);
|
2015-10-19 17:43:46 +00:00
|
|
|
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
|
2014-08-14 21:37:20 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2014-08-14 00:11:12 +00:00
|
|
|
if (!matchedPlayerNames.isEmpty())
|
|
|
|
{
|
|
|
|
if (!silent)
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "De-opping " + StringUtils.join(matchedPlayerNames, ", "), false);
|
2014-08-14 00:11:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("No targets matched.");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|