Commits

Parker Hawke authored and md_5 committed f1120ee22db
#983: Expose riptide velocity to PlayerRiptideEvent
No tags

src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java

Modified
1 1 package org.bukkit.event.player;
2 2
3 3 import org.bukkit.entity.Player;
4 4 import org.bukkit.event.HandlerList;
5 5 import org.bukkit.inventory.ItemStack;
6 +import org.bukkit.util.Vector;
6 7 import org.jetbrains.annotations.NotNull;
7 8
8 9 /**
9 10 * This event is fired when the player activates the riptide enchantment, using
10 11 * their trident to propel them through the air.
11 12 * <br>
12 13 * N.B. the riptide action is currently performed client side, so manipulating
13 14 * the player in this event may have undesired effects.
14 15 */
15 16 public class PlayerRiptideEvent extends PlayerEvent {
16 17
17 18 private static final HandlerList handlers = new HandlerList();
18 19 private final ItemStack item;
20 + private final Vector velocity;
19 21
20 - public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item) {
22 + public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item, @NotNull Vector velocity) {
21 23 super(who);
22 24 this.item = item;
25 + this.velocity = velocity;
26 + }
27 +
28 + @Deprecated
29 + public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item) {
30 + this(who, item, new Vector());
23 31 }
24 32
25 33 /**
26 34 * Gets the item containing the used enchantment.
27 35 *
28 36 * @return held enchanted item
29 37 */
30 38 @NotNull
31 39 public ItemStack getItem() {
32 40 return item;
33 41 }
34 42
43 + /**
44 + * Get the velocity applied to the player as a result of this riptide.
45 + *
46 + * @return the riptide velocity
47 + */
48 + @NotNull
49 + public Vector getVelocity() {
50 + return velocity.clone();
51 + }
52 +
35 53 @NotNull
36 54 @Override
37 55 public HandlerList getHandlers() {
38 56 return handlers;
39 57 }
40 58
41 59 @NotNull
42 60 public static HandlerList getHandlerList() {
43 61 return handlers;
44 62 }
45 63 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut