Source Code
Here is the source code, if you read the liscence , you can't copy it, but it can inspire you to do something else!
public class ExplodePlayer { //State variables public static ExplodePlayer plugin; public final Logger logger = Logger.getLogger("Minecraft"); //Handle onDisable() and onEnable() public void onDisable() { this.logger.info("ExplodePlayer disabled"); } public void onEnable() { this.logger.info("ExplodePlayer enabled"); } //Handle command /troll public boolean onCommand(CommandSender sender , Command cmd , String commandLabel , String[] args) { //Cast player to sender Player player = (Player) sender; //state variable World world = player.getWorld(); //ignore case of the command if (commandLabel.equalsIgnoreCase("troll")) { //no arguments if (args.length == 0) { //getting target block location Block targetblock = player.getTargetBlock(null, 50); Location location = targetblock.getLocation(); //do some funny shit world.strikeLightning(location); world.createExplosion(location, 2); //confirm with the player player.sendMessage(ChatColor.BLUE + "smiting & blowing up the location you are looking at, BOOM!"); } else if (args.length > 0) { //if there are too many arguments: player.sendMessage(ChatColor.RED + "Error: Too many arguments"); } } //return statement return false; } //TODO: Fix the PlayerTargetting command }
Comments