2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2012-09-16 17:46:53 +00:00
|
|
|
|
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;
|
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
|
|
|
|
2017-11-16 22:32:09 +00:00
|
|
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final 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
|
|
|
}
|
2017-11-16 22:32:09 +00:00
|
|
|
final Player player = this.getPlayer(args[0]);
|
2016-05-12 19:40:39 +00:00
|
|
|
String reason = null;
|
|
|
|
if (args.length > 1)
|
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
reason = StringUtils.join((Object[]) args, " ", 1, args.length);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2012-09-16 17:46:53 +00:00
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
this.msg(FreedomCommand.PLAYER_NOT_FOUND);
|
2012-09-16 17:46:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-11-16 22:32:09 +00:00
|
|
|
smite(player, sender, reason);
|
2013-07-03 20:11:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-16 22:32:09 +00:00
|
|
|
public static void smite(final Player player, final CommandSender sender)
|
2016-05-12 19:40:39 +00:00
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
smite(player, sender, null);
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 22:32:09 +00:00
|
|
|
public static void smite(final Player player, final CommandSender sender, final 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);
|
2016-05-12 19:40:39 +00:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
FUtil.bcastMsg(ChatColor.RED + " Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason));
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2017-11-16 22:32:09 +00:00
|
|
|
FUtil.bcastMsg(ChatColor.RED + " Smitten by: " + ChatColor.YELLOW + sender.getName());
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setOp(false);
|
|
|
|
player.setGameMode(GameMode.SURVIVAL);
|
|
|
|
player.getInventory().clear();
|
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();
|
2017-11-16 22:32:09 +00:00
|
|
|
for (int x = -1; x <= 1; ++x)
|
2012-09-16 18:20:51 +00:00
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
for (int z = -1; z <= 1; ++z)
|
2012-09-16 18:20:51 +00:00
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
final Location strike_pos = new Location(world, (double) (targetPos.getBlockX() + x), (double) targetPos.getBlockY(), (double) (targetPos.getBlockZ() + z));
|
|
|
|
world.strikeLightningEffect(strike_pos);
|
2012-09-16 18:20:51 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-14 14:01:42 +00:00
|
|
|
player.setHealth(0.0);
|
2017-11-16 22:32:09 +00:00
|
|
|
player.sendMessage(ChatColor.RED + "You've been smitten by: " + ChatColor.YELLOW + sender.getName());
|
2016-05-12 19:40:39 +00:00
|
|
|
if (reason != null)
|
|
|
|
{
|
2017-11-16 22:32:09 +00:00
|
|
|
player.sendMessage(ChatColor.RED + "Reason: " + ChatColor.YELLOW + FUtil.StrictColorize(reason));
|
2016-05-12 19:40:39 +00:00
|
|
|
}
|
2012-09-16 17:46:53 +00:00
|
|
|
}
|
|
|
|
}
|