I'm currently working on a community plugin.
I just want to let the creator and the creators get on stage and the other players should be kicked off while trying, but unfortunately I do not know how exactly to set the velocity.
I've stored two corner points of the input in the config and with the "Cuboid class" I ask if the player is there. :
Location ytArea1 = configManager.getLocation ("ytAreaP1_1");
Location ytArea11 = configManager.getLocation ("ytAreaP2_1");
if (ytArea1! = null && ytArea11! = null) {
Cuboid cuboid = new Cuboid (ytArea1, ytArea11);
if (cuboid.containsLocation (player.getLocation ({
}
}
Have the solution:
double x1 = event.getFrom (). GetX ();
double z1 = event.getFrom (). GetZ ();
double x2 = event.getTo (). GetX ();
double z2 = event.getTo (). GetZ ();
Vector newVector = new Vector (x2-x1, 0, z2-z1) .normalize (). Multiply (-1) .setY (0.5);
player.setVelocity (newVector);
// Grab the player's vector
Vector v = p.getVelocity ();
// Apply force in a northern direction, which is negative on the Z-axis in Minecraft
v.setZ (-20);
// If the player is on solid ground, friction wants to dampen the force significantly.
// To counter this, push the player slightly upwards in the air
v.setY (5);
// Apply our modified vector to the player
p.setVelocity (v);
Source: https://bukkit.org/threads/set-a-players-velocity.145866/
Thanks, got the solution through a friend
double x1 = event.getFrom (). GetX ();
double z1 = event.getFrom (). GetZ ();
double x2 = event.getTo (). GetX ();
double z2 = event.getTo (). GetZ ();
Vector newVector = new Vector (x2-x1, 0, z2-z1) .normalize (). Multiply (-1) .setY (0.5);
player.setVelocity (newVector);