2018-03-01 05:23:37 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.Access;
|
|
|
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
public class CmdUnban extends FCommand {
|
|
|
|
|
2019-12-02 19:55:38 +01:00
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdUnban() {
|
|
|
|
super();
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.unban);
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requiredArgs.add("target");
|
|
|
|
|
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.BAN)
|
|
|
|
.playerOnly()
|
|
|
|
.memberOnly()
|
|
|
|
.withAction(PermissableAction.BAN)
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
// Good on permission checks. Now lets just ban the player.
|
|
|
|
FPlayer target = context.argAsFPlayer(0);
|
|
|
|
if (target == null) {
|
|
|
|
return; // the above method sends a message if fails to find someone.
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target.getFaction() != context.fPlayer.getFaction()) {
|
|
|
|
if (target.getFaction().getAccess(context.fPlayer, PermissableAction.BAN) != Access.ALLOW) {
|
|
|
|
if (!context.fPlayer.isAdminBypassing()) {
|
2019-09-16 00:48:47 +02:00
|
|
|
context.fPlayer.msg(TL.COMMAND_UNBAN_TARGET_IN_OTHER_FACTION, target.getName());
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!context.faction.isBanned(target)) {
|
|
|
|
context.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.faction.unban(target);
|
|
|
|
|
|
|
|
context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
|
2020-01-03 11:04:12 +01:00
|
|
|
target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target));
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_UNBAN_DESCRIPTION;
|
|
|
|
}
|
2018-03-01 05:23:37 +01:00
|
|
|
}
|