2018-07-25 22:06:19 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2018-07-31 07:01:29 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2018-07-25 22:06:19 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
|
|
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2019-07-28 06:04:16 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2018-07-25 22:06:19 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2020-04-23 11:18:03 +00:00
|
|
|
@CommandParameters(description = "Unbans the specified player.", usage = "/<command> <username> [-r]")
|
2018-07-25 22:06:19 +00:00
|
|
|
public class Command_unban extends FreedomCommand
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
2018-07-26 22:55:55 +00:00
|
|
|
if (args.length > 0)
|
2018-07-25 22:06:19 +00:00
|
|
|
{
|
|
|
|
String username;
|
|
|
|
final List<String> ips = new ArrayList<>();
|
|
|
|
final PlayerData entry = plugin.pl.getData(args[0]);
|
|
|
|
|
|
|
|
if (entry == null)
|
|
|
|
{
|
2018-07-26 01:34:40 +00:00
|
|
|
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
2018-07-25 22:06:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-30 07:25:38 +00:00
|
|
|
username = entry.getName();
|
2018-07-25 22:06:19 +00:00
|
|
|
ips.addAll(entry.getIps());
|
|
|
|
|
2019-08-19 01:06:47 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
2020-04-23 11:18:03 +00:00
|
|
|
msg(username + " has been unbanned along with the following IPs: " + StringUtils.join(ips, ", "));
|
2018-07-25 22:06:19 +00:00
|
|
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
|
|
|
|
2018-07-26 22:55:55 +00:00
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
2020-04-23 11:18:03 +00:00
|
|
|
if (args[1].equalsIgnoreCase("-r"))
|
2018-07-26 22:55:55 +00:00
|
|
|
{
|
2020-04-23 11:18:03 +00:00
|
|
|
plugin.cpb.restore(username);
|
2018-07-26 22:55:55 +00:00
|
|
|
msg("Restored edits for: " + username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-25 22:06:19 +00:00
|
|
|
for (String ip : ips)
|
|
|
|
{
|
|
|
|
Ban ban = plugin.bm.getByIp(ip);
|
|
|
|
if (ban != null)
|
|
|
|
{
|
|
|
|
plugin.bm.removeBan(ban);
|
|
|
|
}
|
|
|
|
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
|
|
|
if (ban != null)
|
|
|
|
{
|
|
|
|
plugin.bm.removeBan(ban);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|