Paper/Spigot-Server-Patches/0174-Add-PlayerJumpEvent.patch

59 lines
3.1 KiB
Diff
Raw Normal View History

From ca5bb26513d8ed1ccdd4b8ad854d67edd735b83b Mon Sep 17 00:00:00 2001
2017-09-28 21:38:17 +00:00
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Thu, 28 Sep 2017 17:21:44 -0400
Subject: [PATCH] Add PlayerJumpEvent
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 046ef418f8..b0651dcfbf 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2019-05-06 02:58:04 +00:00
@@ -58,6 +58,8 @@ import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.EquipmentSlot;
2017-09-28 22:54:38 +00:00
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
+import com.destroystokyo.paper.event.player.IllegalPacketEvent; // Paper
2017-09-28 22:54:38 +00:00
+import com.destroystokyo.paper.event.player.PlayerJumpEvent; // Paper
import co.aikar.timings.MinecraftTimings; // Paper
// CraftBukkit end
2019-12-11 23:43:22 +00:00
@@ -925,7 +927,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
}
if (this.player.onGround && !packetplayinflying.b() && d8 > 0.0D) {
- this.player.jump();
2017-09-28 21:38:17 +00:00
+ // Paper start - Add player jump event
+ Player player = this.getPlayer();
+ Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location.
+
+ // If the packet contains movement information then we update the To location with the correct XYZ.
+ if (packetplayinflying.hasPos) {
+ to.setX(packetplayinflying.x);
+ to.setY(packetplayinflying.y);
+ to.setZ(packetplayinflying.z);
+ }
+
+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch.
+ if (packetplayinflying.hasLook) {
+ to.setYaw(packetplayinflying.yaw);
+ to.setPitch(packetplayinflying.pitch);
+ }
+
+ PlayerJumpEvent event = new PlayerJumpEvent(player, from, to);
+
+ if (event.callEvent()) {
+ this.player.jump();
2017-09-28 21:38:17 +00:00
+ } else {
+ from = event.getFrom();
+ this.internalTeleport(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.emptySet());
+ return;
+ }
+ // Paper end
}
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
2017-09-28 21:38:17 +00:00
--
2.26.2
2017-09-28 21:38:17 +00:00