Allow tppos to be used in console.

This commit is contained in:
KHobbits 2012-04-02 02:47:10 +01:00
parent 767703bfc9
commit bf1e073ef4
1 changed files with 27 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@ -41,4 +42,30 @@ public class Commandtppos extends EssentialsCommand
user.getTeleport().teleport(location, charge, TeleportCause.COMMAND);
throw new NoChargeException();
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 4)
{
throw new NotEnoughArgumentsException();
}
User user = ess.getUser(server.getPlayer(args[0]));
final int x = Integer.parseInt(args[1]);
final int y = Integer.parseInt(args[2]);
final int z = Integer.parseInt(args[3]);
final Location location = new Location(user.getWorld(), x, y, z);
if (args.length > 4)
{
location.setYaw((Float.parseFloat(args[4]) + 180 + 360) % 360);
}
if (args.length > 5)
{
location.setPitch(Float.parseFloat(args[5]));
}
sender.sendMessage(_("teleporting"));
user.sendMessage(_("teleporting"));
user.getTeleport().teleport(location, null, TeleportCause.COMMAND);
}
}