2011-10-19 00:37:00 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-03-19 22:05:20 +00:00
|
|
|
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Quick Op - op someone based on a partial name.", usage = "/<command> <partialname>")
|
2011-10-19 00:37:00 +00:00
|
|
|
public class Command_qop extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-11-03 01:03:12 +00:00
|
|
|
if (args.length < 1)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-03 01:03:12 +00:00
|
|
|
boolean silent = false;
|
|
|
|
if (args.length == 2)
|
|
|
|
{
|
|
|
|
silent = args[1].equalsIgnoreCase("-s");
|
|
|
|
}
|
|
|
|
|
2012-09-16 12:29:40 +00:00
|
|
|
boolean matched_player = false;
|
2012-09-16 17:41:41 +00:00
|
|
|
|
|
|
|
String target_name = args[0].toLowerCase();
|
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
for (Player player : server.getOnlinePlayers())
|
2012-09-16 12:29:40 +00:00
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
if (player.getName().toLowerCase().indexOf(target_name) != -1 || player.getDisplayName().toLowerCase().indexOf(target_name) != -1)
|
2012-09-16 17:41:41 +00:00
|
|
|
{
|
|
|
|
matched_player = true;
|
2012-09-14 22:49:44 +00:00
|
|
|
|
2012-11-03 01:03:12 +00:00
|
|
|
if (!silent)
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
|
2012-11-03 01:03:12 +00:00
|
|
|
}
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setOp(true);
|
|
|
|
player.sendMessage(TotalFreedomMod.YOU_ARE_OP);
|
2012-09-16 17:41:41 +00:00
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-09-16 17:41:41 +00:00
|
|
|
|
2012-09-16 12:29:40 +00:00
|
|
|
if (!matched_player)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("No targets matched.");
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|