2012-09-14 22:49:44 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2014-04-09 20:33:03 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_AdminList;
|
2014-12-21 09:23:50 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_DepreciationAggregator;
|
2012-09-14 22:49:44 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.OfflinePlayer;
|
|
|
|
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.OP, source = SourceType.BOTH)
|
2013-04-10 02:05:24 +00:00
|
|
|
@CommandParameters(description = "Makes a player operator", usage = "/<command> <playername>")
|
2012-09-14 22:49:44 +00:00
|
|
|
public class Command_op extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("everyone"))
|
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("Correct usage: /opall");
|
2012-09-14 22:49:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
OfflinePlayer player = null;
|
2012-09-14 22:49:44 +00:00
|
|
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
|
|
|
|
{
|
2013-08-14 14:01:42 +00:00
|
|
|
player = onlinePlayer;
|
2012-09-14 22:49:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the player is not online
|
2013-08-14 14:01:42 +00:00
|
|
|
if (player == null)
|
2012-09-14 22:49:44 +00:00
|
|
|
{
|
2014-04-09 20:33:03 +00:00
|
|
|
if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole)
|
2012-09-14 22:49:44 +00:00
|
|
|
{
|
2014-12-21 09:23:50 +00:00
|
|
|
player = TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]);
|
2012-09-14 22:49:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-07 14:56:53 +00:00
|
|
|
playerMsg("That player is not online.");
|
|
|
|
playerMsg("You don't have permissions to OP offline players.", ChatColor.YELLOW);
|
2012-09-14 22:49:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-14 14:01:42 +00:00
|
|
|
TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false);
|
|
|
|
player.setOp(true);
|
2012-09-14 22:49:44 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|