2011-10-19 02:52:32 +00:00
|
|
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
2012-11-13 01:42:30 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
2012-03-06 19:25:22 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
2012-11-20 02:50:33 +00:00
|
|
|
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
2012-11-13 01:42:30 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2011-10-19 02:52:32 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
public class Command_saconfig extends TFM_Command
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2012-03-06 19:25:22 +00:00
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
if (args[0].equals("list"))
|
|
|
|
{
|
2012-11-13 01:42:30 +00:00
|
|
|
sender.sendMessage(ChatColor.GOLD + "Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "));
|
2012-03-06 19:25:22 +00:00
|
|
|
}
|
2012-11-20 02:50:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!senderIsConsole)
|
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the console.");
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
if (args[0].equals("clean"))
|
|
|
|
{
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Cleaning superadmin list.", true);
|
|
|
|
TFM_SuperadminList.cleanSuperadminList(true);
|
|
|
|
sender.sendMessage(ChatColor.GOLD + "Superadmins: " + StringUtils.join(TFM_SuperadminList.getSuperadminNames(), ", "));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
return true;
|
2011-10-19 02:52:32 +00:00
|
|
|
}
|
2012-11-20 02:50:33 +00:00
|
|
|
else if (args.length == 2)
|
2011-10-19 02:52:32 +00:00
|
|
|
{
|
2012-11-20 02:50:33 +00:00
|
|
|
if (!senderIsConsole)
|
2011-10-19 02:52:32 +00:00
|
|
|
{
|
2012-11-20 02:50:33 +00:00
|
|
|
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the console.");
|
2011-10-19 02:52:32 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
if (args[0].equalsIgnoreCase("add"))
|
|
|
|
{
|
|
|
|
Player p = null;
|
|
|
|
String admin_name = null;
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
p = getPlayer(args[1]);
|
|
|
|
}
|
|
|
|
catch (CantFindPlayerException ex)
|
|
|
|
{
|
|
|
|
TFM_Superadmin superadmin = TFM_SuperadminList.getAdminEntry(args[1].toLowerCase());
|
|
|
|
if (superadmin != null)
|
|
|
|
{
|
|
|
|
admin_name = superadmin.getName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sender.sendMessage(ex.getMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
if (p != null)
|
|
|
|
{
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the superadmin list.", true);
|
|
|
|
TFM_SuperadminList.addSuperadmin(p);
|
|
|
|
}
|
|
|
|
else if (admin_name != null)
|
|
|
|
{
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Adding " + admin_name + " to the superadmin list.", true);
|
|
|
|
TFM_SuperadminList.addSuperadmin(admin_name);
|
|
|
|
}
|
2011-10-31 12:00:42 +00:00
|
|
|
}
|
2012-11-20 02:50:33 +00:00
|
|
|
else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("del") || args[0].equalsIgnoreCase("remove"))
|
2011-10-31 12:00:42 +00:00
|
|
|
{
|
2012-11-20 02:50:33 +00:00
|
|
|
if (!TFM_SuperadminList.isSeniorAdmin(sender))
|
|
|
|
{
|
|
|
|
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
String target_name = args[1];
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
target_name = getPlayer(target_name).getName();
|
|
|
|
}
|
|
|
|
catch (CantFindPlayerException ex)
|
|
|
|
{
|
|
|
|
}
|
2012-11-13 01:42:30 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
if (!TFM_SuperadminList.getSuperadminNames().contains(target_name.toLowerCase()))
|
|
|
|
{
|
|
|
|
sender.sendMessage("Superadmin not found: " + target_name);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from the superadmin list.", true);
|
|
|
|
|
|
|
|
TFM_SuperadminList.removeSuperadmin(target_name);
|
|
|
|
}
|
|
|
|
else
|
2011-10-31 12:00:42 +00:00
|
|
|
{
|
2012-11-20 02:50:33 +00:00
|
|
|
return false;
|
2011-10-31 12:00:42 +00:00
|
|
|
}
|
2012-07-22 18:06:01 +00:00
|
|
|
|
2012-11-20 02:50:33 +00:00
|
|
|
return true;
|
2011-10-31 12:00:42 +00:00
|
|
|
}
|
2012-09-14 22:49:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-10-19 02:52:32 +00:00
|
|
|
}
|
|
|
|
}
|