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;
|
2016-05-12 19:40:39 +00:00
|
|
|
import org.apache.commons.lang3.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)
|
2016-05-12 19:40:39 +00:00
|
|
|
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> <player> [reason]")
|
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
|
|
|
}
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
String reason = null;
|
|
|
|
if (args.length > 1)
|
|
|
|
{
|
|
|
|
reason = StringUtils.join(args, " ", 1, args.length);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2017-12-23 04:07:36 +00:00
|
|
|
smite(sender, player, reason);
|
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
|
|
|
{
|
2017-12-23 04:07:36 +00:00
|
|
|
smite(sender, player, null);
|
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)
|
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);
|
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
|
|
|
}
|
2019-01-12 03:05:12 +00:00
|
|
|
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);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2012-09-16 17:46:53 +00:00
|
|
|
}
|
|
|
|
}
|