2016-05-12 19:40:39 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
2018-03-03 04:29:08 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|
|
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2020-08-01 04:10:44 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
2016-05-12 19:40:39 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2020-08-01 04:10:44 +00:00
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
2019-07-28 06:04:16 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2016-05-12 19:40:39 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2020-08-15 22:42:46 +00:00
|
|
|
@CommandPermissions(level = Rank.TRIAL_MOD, source = SourceType.BOTH)
|
2020-08-01 04:10:44 +00:00
|
|
|
@CommandParameters(description = "Kick the specified player.", usage = "/<command> <player> [reason] [-q]")
|
2016-05-12 19:40:39 +00:00
|
|
|
public class Command_kick extends FreedomCommand
|
|
|
|
{
|
|
|
|
@Override
|
2020-07-01 01:51:06 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Player player = getPlayer(args[0]);
|
2018-07-30 07:23:01 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
if (player == null)
|
|
|
|
{
|
|
|
|
msg(PLAYER_NOT_FOUND);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-08-01 04:10:44 +00:00
|
|
|
boolean silent = false;
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
String reason = null;
|
2020-08-01 04:10:44 +00:00
|
|
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
2020-08-01 04:10:44 +00:00
|
|
|
silent = true;
|
|
|
|
FLog.debug("silent");
|
|
|
|
|
|
|
|
if (args.length >= 2)
|
|
|
|
{
|
|
|
|
FLog.debug("set reason (silent)");
|
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (args.length > 1)
|
|
|
|
{
|
|
|
|
FLog.debug("set reason");
|
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder builder = new StringBuilder()
|
|
|
|
.append(ChatColor.RED).append("You have been kicked from the server.")
|
|
|
|
.append("\n").append(ChatColor.RED).append("Kicked by: ").append(ChatColor.GOLD).append(sender.getName());
|
|
|
|
|
|
|
|
if (reason != null)
|
|
|
|
{
|
|
|
|
builder.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD).append(reason);
|
|
|
|
}
|
2020-08-01 04:10:44 +00:00
|
|
|
|
|
|
|
if (!silent)
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
2020-08-01 04:10:44 +00:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2020-08-15 22:42:46 +00:00
|
|
|
FUtil.staffAction(sender.getName(), "Kicking " + player.getName() + " - Reason: " + reason, true);
|
2020-08-01 04:10:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-15 22:42:46 +00:00
|
|
|
FUtil.staffAction(sender.getName(), "Kicking " + player.getName(), true);
|
2020-08-01 04:10:44 +00:00
|
|
|
}
|
2020-08-18 08:23:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-18 15:22:43 +00:00
|
|
|
msg("Kicked " + player.getName() + " quietly.");
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
player.kickPlayer(builder.toString());
|
2018-03-03 04:29:08 +00:00
|
|
|
|
2020-07-01 01:51:06 +00:00
|
|
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.KICK, reason));
|
2018-03-03 04:29:08 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|