Add command to unban player from report system
This commit is contained in:
parent
f805ceccdc
commit
fb369d3df9
@ -11,6 +11,7 @@ import mineplex.core.report.command.ReportCloseCommand;
|
||||
import mineplex.core.report.command.ReportCommand;
|
||||
import mineplex.core.report.command.ReportHandleCommand;
|
||||
import mineplex.core.report.command.ReportStatsCommand;
|
||||
import mineplex.core.report.command.ReportUnbanCommand;
|
||||
|
||||
/**
|
||||
* Main class for this module, handles initialization and disabling of the module.
|
||||
@ -38,6 +39,7 @@ public class ReportPlugin extends MiniPlugin
|
||||
addCommand(new ReportCloseCommand(this));
|
||||
addCommand(new ReportStatsCommand(this));
|
||||
addCommand(new ReportAbortCommand(this));
|
||||
addCommand(new ReportUnbanCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,60 @@
|
||||
package mineplex.core.report.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.report.data.ReportRepository;
|
||||
|
||||
/**
|
||||
* A temporary command to allow unbanning of users who have abused the report system.
|
||||
*/
|
||||
public class ReportUnbanCommand extends CommandBase<ReportPlugin>
|
||||
{
|
||||
public ReportUnbanCommand(ReportPlugin plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "reportunban", "runban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args != null && args.length == 1)
|
||||
{
|
||||
String targetName = args[0];
|
||||
Player target = Bukkit.getPlayerExact(targetName);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
ReportRepository repository = Plugin.getReportManager().getReportRepository();
|
||||
int targetId = _commandCenter.GetClientManager().getAccountId(target);
|
||||
|
||||
repository.hasBan(targetId).thenAccept(hasBan ->
|
||||
{
|
||||
if (hasBan)
|
||||
{
|
||||
repository.removeBan(targetId).thenAccept(aVoid ->
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Unbanned player from the report system.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "That player is not banned from using the report system."));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "Couldn't find player named: " + F.elem(targetName)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), C.cRed + "Invalid Usage: " + F.elem("/reportunban <player>")));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user