Package com.sijobe.spc.command

Source Code of com.sijobe.spc.command.Jump

package com.sijobe.spc.command;

import com.sijobe.spc.wrapper.CommandException;
import com.sijobe.spc.wrapper.CommandSender;
import com.sijobe.spc.wrapper.Coordinate;
import com.sijobe.spc.wrapper.Player;

import java.util.List;

/**
* Sets the players spawn based on the player position or the arguments
* provided
*
* @author simo_415
* @version 1.0
*/
@Command (
   name = "jump",
   description = "Moves the player to where the player is pointing",
   videoURL = "http://www.youtube.com/watch?v=Kc6lm3XxSUA",
   version = "1.0"
)
public class Jump extends StandardCommand {

   /**
    * @see com.sijobe.spc.wrapper.CommandBase#execute(com.sijobe.spc.wrapper.CommandSender, java.util.List)
    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = getSenderAsPlayer(sender);
      Coordinate hit = player.trace(128);
      if (hit == null) {
         throw new CommandException("No block in sight.");
      }
      int y = hit.getBlockY() + 1;
      while (y < 260) {
         if (player.isClear(new Coordinate(hit.getBlockX(), y++, hit.getBlockZ()))) {
            player.setPosition(new Coordinate(hit.getBlockX() + 0.5F, --y, hit.getBlockZ() + 0.5F));
            break;
         }
      }
   }
}
TOP

Related Classes of com.sijobe.spc.command.Jump

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.