2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.OfflinePlayer;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
@CommandPermissions(level = PlayerRank.OP, source = SourceType.BOTH)
|
|
|
|
@CommandParameters(description = "Manager operators", usage = "/<command> <count | purge>")
|
|
|
|
public class Command_ops extends FreedomCommand
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2015-10-19 17:43:46 +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)
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equals("count"))
|
|
|
|
{
|
|
|
|
int totalOps = server.getOperators().size();
|
|
|
|
int onlineOps = 0;
|
|
|
|
|
|
|
|
for (Player player : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (player.isOp())
|
|
|
|
{
|
|
|
|
onlineOps++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Online OPs: " + onlineOps);
|
|
|
|
msg("Offline OPs: " + (totalOps - onlineOps));
|
|
|
|
msg("Total OPs: " + totalOps);
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equals("purge"))
|
|
|
|
{
|
|
|
|
if (!plugin.al.isAdmin(sender))
|
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
noPerms();
|
2015-10-19 17:43:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUtil.adminAction(sender.getName(), "Purging all operators", true);
|
|
|
|
|
|
|
|
for (OfflinePlayer player : server.getOperators())
|
|
|
|
{
|
|
|
|
player.setOp(false);
|
|
|
|
if (player.isOnline())
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg(player.getPlayer(), FreedomCommand.YOU_ARE_NOT_OP);
|
2015-10-19 17:43:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|