Add Player#boost(int duration) method
Is your feature request related to a problem? Please describe. Currently, to boost a player gliding with elytra, you have to manually calculate and add the velocity to the player. This can be hard to replicate the exact vanilla behavior, and it would make more sense if this was added directly to the API.
Describe the solution you'd like
Adding a boost(int duration) method to the Player class would be the best solution, where int duration is the duration of the boost between 1 and 3. This method would boost the player if they were gliding, the exact same way that the vanilla game does when you use a firework whilst gliding. The int duration parameter would replicate the flight duration aspect of a firework rocket, where the longer the flight duration, the longer the boost lasts for.
Describe alternatives you've considered An alternate solution to this is attempting to replicate the vanilla behavior by manually calculating the velocity that needs to be added to the player, but this solution is far from perfect. Another solution would be to use NMS to make the player boost, but this would break the plugin with every game update and isn't necessarily the easiest to do. A nice method in the Paper API would be a much better solution than these alternate solutions.
What about the boost of a trident with riptide? Or a bow, maybe with punch?
What would this method do when the player isn't wearing an elytra? Just do nothing?
Those things may have to be considered when implementing this, otherwise it's a bit too specific for it to be in the API. That's my opinion though, the team might have a different outlook on it
@JavierKasunic Call it #boostElytra, then. If the player is not flying, either do nothing, or throw an exception (which assumes a method such as #isFlyingWithElytra).
@Proximyst that may led to users seeing errors the players might not want. If the method is implemented as Trigary's PR does. Wouldn't it be better to have Firework#boost(Player) instead? Or even better, some kind of Booster interface that would apply for the Firework and AbstractArrow entity as well. Of course, only if that's feasible
that may led to users seeing errors the players might not want. If the method is implemented as Trigary's PR does.
What exactly do you mean?
Wouldn't it be better to have Firework#boost(Player) instead?
No. I don't like the changes we would have to make to the Firework entity.
Arrow boosting: probably way too complicated, since the arrow has to come from a specific direction, etc.
Trident boosting: this isn't exclusive to elytras, so the method names wouldn't conflict (trident boosting wouldn't be named boostElytra)
implemented in #3139