2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2012-09-16 17:46:53 +00:00
|
|
|
|
2018-08-17 00:20:50 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|
|
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2018-08-17 00:20:50 +00:00
|
|
|
import net.pravian.aero.util.Ips;
|
2020-04-23 11:18:03 +00:00
|
|
|
import org.apache.commons.lang.ArrayUtils;
|
2019-07-28 06:04:16 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2012-09-16 17:46:53 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2012-09-16 18:20:51 +00:00
|
|
|
import org.bukkit.GameMode;
|
2012-09-16 17:46:53 +00:00
|
|
|
import org.bukkit.Location;
|
2012-09-16 18:20:51 +00:00
|
|
|
import org.bukkit.World;
|
2012-09-16 17:46:53 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2020-04-23 11:18:03 +00:00
|
|
|
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason] [-q]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_smite extends FreedomCommand
|
2012-09-16 17:46:53 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2012-09-16 18:20:51 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2012-09-16 17:46:53 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
if (args.length < 1)
|
2012-09-16 18:20:51 +00:00
|
|
|
{
|
2012-09-16 21:33:26 +00:00
|
|
|
return false;
|
2012-09-16 18:20:51 +00:00
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
String reason = null;
|
2020-04-23 11:18:03 +00:00
|
|
|
Boolean silent = false;
|
|
|
|
if (args.length >= 2)
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
2020-04-23 11:18:03 +00:00
|
|
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
|
|
|
{
|
|
|
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
|
|
|
{
|
|
|
|
silent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.length >= 3)
|
|
|
|
{
|
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-23 11:18:03 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2012-09-16 17:46:53 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
2012-09-16 17:46:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-09-16 18:20:51 +00:00
|
|
|
|
2020-04-23 11:18:03 +00:00
|
|
|
smite(sender, player, reason, silent);
|
2018-08-17 00:20:50 +00:00
|
|
|
|
|
|
|
plugin.pul.logPunishment(new Punishment(player.getName(), Ips.getIp(player), sender.getName(), PunishmentType.SMITE, reason));
|
|
|
|
|
2013-07-03 20:11:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
public static void smite(CommandSender sender, Player player)
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
2020-04-23 11:18:03 +00:00
|
|
|
smite(sender, player, null, false);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
public static void smite(CommandSender sender, Player player, String reason)
|
2020-04-23 11:18:03 +00:00
|
|
|
{
|
|
|
|
smite(sender, player, reason, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void smite(CommandSender sender, Player player, String reason, Boolean silent)
|
2013-07-03 20:11:57 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
2019-11-30 17:43:16 +00:00
|
|
|
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Be sure to follow the rules!", 20, 100, 60);
|
2012-09-16 18:20:51 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2017-12-23 04:07:36 +00:00
|
|
|
FUtil.bcastMsg(" Reason: " + ChatColor.YELLOW + reason, ChatColor.RED);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2020-04-23 11:18:03 +00:00
|
|
|
|
|
|
|
if (!silent)
|
|
|
|
{
|
|
|
|
FUtil.bcastMsg(" Smitten by: " + ChatColor.YELLOW + sender.getName(), ChatColor.RED);
|
|
|
|
}
|
2016-05-12 19:40:39 +00:00
|
|
|
|
|
|
|
// Deop
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setOp(false);
|
2012-09-16 18:20:51 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
// Set gamemode to survival
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
2012-09-16 18:20:51 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
// Clear inventory
|
2013-08-14 14:01:42 +00:00
|
|
|
player.getInventory().clear();
|
2012-09-16 18:20:51 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
// Strike with lightning effect
|
2013-08-14 14:55:37 +00:00
|
|
|
final Location targetPos = player.getLocation();
|
2013-08-14 14:01:42 +00:00
|
|
|
final World world = player.getWorld();
|
2012-09-16 18:20:51 +00:00
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
{
|
|
|
|
for (int z = -1; z <= 1; z++)
|
|
|
|
{
|
2013-08-14 14:55:37 +00:00
|
|
|
final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
2012-09-16 18:20:51 +00:00
|
|
|
world.strikeLightning(strike_pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
// Kill
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setHealth(0.0);
|
2016-05-12 19:40:39 +00:00
|
|
|
|
|
|
|
if (reason != null)
|
|
|
|
{
|
2017-06-30 07:42:49 +00:00
|
|
|
player.sendMessage(ChatColor.RED + "You've been smitten. Reason: " + ChatColor.YELLOW + reason);
|
2019-11-30 17:43:16 +00:00
|
|
|
player.sendTitle(ChatColor.RED + "You've been smitten.", ChatColor.YELLOW + "Reason: " + reason, 20, 100, 60);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2012-09-16 17:46:53 +00:00
|
|
|
}
|
|
|
|
}
|