Got a bug in the code with the jump?

sn
7

I had a question so i programmed a navigator (for minecraft) and i have a problem it works fine only when i do teleport i have a bug.

Here is a section where the teleport takes place:

if (name.equalsIgnoreCase ("§6Spawn")) {
p.setVelocity (p.getVelocity (). SetY (1.0D));
p.closeInventory ();
try {

Thread.sleep (1000);
} catch (InterruptedException e1) {
e1.printStackTrace ();
}

p.sendMessage ("§cTeleportation successfully carried out, you are now at" + name);
p.teleport (LocationManager.getLocation ("spawn"));
p.playSound (p.getLocation (), Sound.ENDERMAN_TELEPORT, 3, 2);
p.addPotionEffect (new PotionEffect (PotionEffectType.BLINDNESS, 30, 2));
p.sendTitle ("§cTeleportation", "§c§l§nSpawn");

So you can see in the code "p.setVelocity (p.getVelocity (). SetY (1.0D));" the teleport upwards but here is the mistake the inventory is closed first then we wait a second and then the jump is carried out but the jump should close before the inventory and before the teleportation.

My guess is that I did something wrong with the sleeper and I just don't find mistakes.

Pr

Is there an error message?

sn

No there's no error message

Pr

And what exactly is the error now?

sn

So the player should first close the inventory then the player should jump and then wait a second and then the sound should be played then the effect then the teleport then the text and then the title.

But first we close the inventory and then wait a second and then the jump and then the rest.

Bi

Under no circumstances may you use Thread.Sleep there. If you want to wait a second you should use a scheduler

Pr

Write that
p.setVelocity (p.getVelocity (). SetY (1.0D));
in the line before the p.teleport ();

sn

Sorry that I did not get in touch but it still does not work. You should be shot first and then tpt if you were shot