TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commandjump.java

45 lines
1.1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
2011-06-13 13:05:11 +00:00
import com.earth2me.essentials.Trade;
import org.bukkit.Location;
import org.bukkit.Server;
import com.earth2me.essentials.TargetBlock;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandjump extends EssentialsCommand
{
public Commandjump()
{
super("jump");
}
2011-11-18 12:06:59 +00:00
//TODO: Update to use new target methods
@Override
2011-11-18 12:06:59 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
Location loc;
2011-11-18 12:06:59 +00:00
final Location cloc = user.getLocation();
try
{
loc = new TargetBlock(user, 100, 2.65).getTargetBlock().getLocation();
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc = new TargetBlock(loc).getPreviousBlock().getLocation();
loc.setYaw(cloc.getYaw());
loc.setPitch(cloc.getPitch());
loc.setY(loc.getY() + 1);
}
catch (NullPointerException ex)
{
throw new Exception(Util.i18n("jumpError"), ex);
}
2011-11-18 12:06:59 +00:00
final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user);
user.getTeleport().teleport(loc, charge);
}
}