TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_unban.java

62 lines
2.2 KiB
Java
Raw Normal View History

2018-07-25 22:06:19 +00:00
package me.totalfreedom.totalfreedommod.command;
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)
{
if (args.length > 0)
2018-07-25 22:06:19 +00:00
{
String username;
String ip;
2018-07-25 22:06:19 +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
{
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
}
FUtil.adminAction(sender.getName(), "Unbanning " + username, true);
2018-07-25 22:06:19 +00:00
plugin.bm.removeBan(plugin.bm.getByUsername(username));
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
if (args.length >= 2)
{
2020-04-23 11:18:03 +00:00
if (args[1].equalsIgnoreCase("-r"))
{
2020-04-23 11:18:03 +00:00
plugin.cpb.restore(username);
msg("Restored edits for: " + username);
}
}
2018-07-25 22:06:19 +00:00
return true;
}
return false;
}
}