TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/commands/Command_smite.java

67 lines
1.9 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Someone being a little bitch? Smite them down...", usage = "/<command> [playername]")
public class Command_smite extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
if (player == null)
{
playerMsg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
2013-08-14 14:01:42 +00:00
smite(player);
return true;
}
2013-08-14 14:01:42 +00:00
public static void smite(final Player player)
{
FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
//Deop
2013-08-14 14:01:42 +00:00
player.setOp(false);
//Set gamemode to survival:
2013-08-14 14:01:42 +00:00
player.setGameMode(GameMode.SURVIVAL);
//Clear inventory:
2013-08-14 14:01:42 +00:00
player.getInventory().clear();
//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();
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);
world.strikeLightning(strike_pos);
}
}
//Kill:
2013-08-14 14:01:42 +00:00
player.setHealth(0.0);
}
}