TPPOS command with yaw and pitch

Discussion in 'Spigot Plugin Development' started by OverscorePlayZ, Jul 19, 2019.

  1. This is my code:
    if (cmd.getName().equals("tppos")) {
    if (!isPlayer) {
    console.sendMessage(TCHub.noConsole);
    return true;
    }
    if (!p.isOp()) {
    p.sendMessage(TCHub.noAccess);
    return true;
    }
    if (args.length == 0) {
    p.sendMessage(TCHub.TCCUsage + "§7/tppos (X) (Y) (Z) (float) (float)");
    return true;
    }
    if (args.length > 3) {
    p.sendMessage(TCHub.Admin + "§cPlease enter valid coordinates.");
    return true;
    }
    if (args.length < 3) {
    p.sendMessage(TCHub.Admin + "§cPlease enter valid coordinates.");
    return true;
    }
    if (args.length == 3) {
    //Location targetPos = new Location(p.getWorld(), Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
    Location targetPos1 = new Location(p.getWorld(), Float.parseFloat(args[0]), Float.parseFloat(args[1]), Float.parseFloat(args[2]));
    p.teleport(targetPos1);
    p.sendMessage("§9§lTPPOS §8» §7You teleported to the cords: §b" + args[0] + " " + args[1] + " " + args[2]);
    return true;
    }
    } // end tppos command

    I'm trying to get Yaw and Pitch, please help. Thank you :)
     
  2. How do implement SetYaw and SetPitch into //Location targetPos = new Location(p.getWorld(), Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));?
     
  3. World world = p.getWorld();
    double x = p.getLocation().getX();
    double y = p.getLocation().getY();
    double z = p.getLocation().getZ();
    double yaw = p.getLocation().getYaw();
    double pitch = p.getLocation().getPitch();
    Location targetPos1 = new Location(world, x, y, z, yaw, pitch);
    p.teleport(targetPos1);
    Is that correct?
     
  4. It should work but it just teleports the player to his current location. How does this make sense?
     
  5. Would you mind giving me a code example to get me on the road please?
     
  6. I don't know what you want to do.
     
  7. I want to use TPPOS command and teleport to X, Y, Z and yaw and pitch
     
  8. But there is already a teleport command in Minecraft?
     
  9. Like for teleporting via cords?
     
  10. Yes, there is one.
     
  11. And there are code tags use the + button, click code and choose the language that suits your code. Or you can type them down manually [ code=Java ] code here... [ /code ] (without the spaces) :D
     
  12. You're on the right track, only take the x, y, z, yaw and pitch from the command arguments.

    Skickat från min ONEPLUS A6003 via Tapatalk