2018-07-25 22:06:19 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2021-09-06 10:44:39 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2018-07-25 22:06:19 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2020-09-28 03:17:01 +00:00
|
|
|
@CommandPermissions(level = Rank.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;
|
2021-09-06 10:44:39 +00:00
|
|
|
String ip;
|
2018-07-25 22:06:19 +00:00
|
|
|
|
2021-09-06 10:44:39 +00:00
|
|
|
// Gets the IP using Essentials data if available
|
|
|
|
if (plugin.esb.isEnabled() && plugin.esb.getEssentialsUser(args[0]) != null)
|
2018-07-25 22:06:19 +00:00
|
|
|
{
|
2021-09-06 10:44:39 +00:00
|
|
|
User essUser = plugin.esb.getEssentialsUser(args[0]);
|
|
|
|
//
|
|
|
|
username = essUser.getName();
|
|
|
|
ip = essUser.getLastLoginAddress();
|
|
|
|
}
|
|
|
|
// Secondary method - using Essentials if available
|
|
|
|
else
|
|
|
|
{
|
|
|
|
final PlayerData entry = plugin.pl.getData(args[0]);
|
|
|
|
if (entry == null)
|
|
|
|
{
|
|
|
|
msg(PLAYER_NOT_FOUND);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
username = entry.getName();
|
|
|
|
ip = entry.getIps().get(0);
|
2018-07-25 22:06:19 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 00:28:53 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
|
2018-07-25 22:06:19 +00:00
|
|
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
2021-09-06 10:44:39 +00:00
|
|
|
plugin.bm.removeBan(plugin.bm.getByIp(ip));
|
|
|
|
msg(username + " has been unbanned along with the IP: " + ip);
|
2018-07-25 22:06:19 +00:00
|
|
|
|
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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-12-04 00:28:53 +00:00
|
|
|
}
|