Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Add PlayerMicroMoveEvent
Dieser Commit ist enthalten in:
Ursprung
e139db70f1
Commit
23f4ae7bbd
47
Spigot-API-Patches/0012-Add-PlayerMicroMoveEvent.patch
Normale Datei
47
Spigot-API-Patches/0012-Add-PlayerMicroMoveEvent.patch
Normale Datei
@ -0,0 +1,47 @@
|
||||
From 459f653fc31bb56279122a2cee50f0e46e9bf37f Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Thu, 23 Jul 2015 03:19:57 -0700
|
||||
Subject: [PATCH] Add PlayerMicroMoveEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/github/paperspigot/event/PlayerMicroMoveEvent.java b/src/main/java/org/github/paperspigot/event/PlayerMicroMoveEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..e57a377
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/github/paperspigot/event/PlayerMicroMoveEvent.java
|
||||
@@ -0,0 +1,32 @@
|
||||
+package org.github.paperspigot.event;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerMoveEvent;
|
||||
+
|
||||
+/**
|
||||
+ * This event is fired for player movements that are too small to track with PlayerMoveEvent.
|
||||
+ *
|
||||
+ * When used in combination with PlayerMoveEvent, it is possible to keep track of all
|
||||
+ * PacketPlayInFlying movements. This can be particularly useful for anti-cheat plugins.
|
||||
+ *
|
||||
+ * Please note this event is not intended for casual use. Plugins that casually use this event
|
||||
+ * may cause significant overhead depending on handler logic.
|
||||
+ */
|
||||
+public class PlayerMicroMoveEvent extends PlayerMoveEvent {
|
||||
+ private static final HandlerList handlerList = new HandlerList();
|
||||
+
|
||||
+ public PlayerMicroMoveEvent(Player player, Location from, Location to) {
|
||||
+ super(player, from, to);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return getHandlerList();
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlerList;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
39
Spigot-Server-Patches/0068-Add-PlayerMicroMoveEvent.patch
Normale Datei
39
Spigot-Server-Patches/0068-Add-PlayerMicroMoveEvent.patch
Normale Datei
@ -0,0 +1,39 @@
|
||||
From 510ff3ce75e0325b382a61cc39685df8482cdf24 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Thu, 23 Jul 2015 04:29:22 -0700
|
||||
Subject: [PATCH] Add PlayerMicroMoveEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 2c373cd..3fd3f4f 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -62,6 +62,7 @@ import org.bukkit.util.NumberConversions;
|
||||
// CraftBukkit end
|
||||
|
||||
import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
|
||||
+import org.github.paperspigot.event.PlayerMicroMoveEvent; // PaperSpigot
|
||||
|
||||
public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerListBox {
|
||||
|
||||
@@ -257,7 +258,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
||||
double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2);
|
||||
float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch());
|
||||
|
||||
- if ((delta > 1f / 256 || deltaAngle > 10f) && (this.checkMovement && !this.player.dead)) {
|
||||
+ if ((delta > 0 || deltaAngle > 0) && (this.checkMovement && !this.player.dead)) { // PaperSpigot
|
||||
this.lastPosX = to.getX();
|
||||
this.lastPosY = to.getY();
|
||||
this.lastPosZ = to.getZ();
|
||||
@@ -267,7 +268,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
||||
// Skip the first time we do this
|
||||
if (true) { // Spigot - don't skip any move events
|
||||
Location oldTo = to.clone();
|
||||
- PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
+ PlayerMoveEvent event = (delta > 1f / 256 || deltaAngle > 10f) ? new PlayerMoveEvent(player, from, to) : new PlayerMicroMoveEvent(player, from, to); // PaperSpigot - PlayerMicroMoveEvent
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
||||
// If the event is cancelled we move the player back to their old location.
|
||||
--
|
||||
1.9.5.msysgit.1
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren