From 608fe60aac3b8a5da8ffb63f80f004716c3514e9 Mon Sep 17 00:00:00 2001 From: l_MrBoom_l Date: Sun, 8 Nov 2020 19:11:25 +0200 Subject: [PATCH] GH-278: Configurable movement checks --- PATCHES.md | 3 +- .../0059-Configurable-flight-checks.patch | 2 +- .../0076-Configurable-movement-checks.patch | 66 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 patches/server/0076-Configurable-movement-checks.patch diff --git a/PATCHES.md b/PATCHES.md index 75058ec3..b1016efc 100644 --- a/PATCHES.md +++ b/PATCHES.md @@ -41,7 +41,8 @@ # Patches | server | Brandings | YatopiaMC | | | server | Configurable BlockPhysicsEvent | Mykyta Komarnytskyy | | | server | Configurable criterion triggers | Mykyta Komarnytskyy | | -| server | Configurable flight checks | epserv | | +| server | Configurable flight checks | l_MrBoom_l | | +| server | Configurable movement checks | l_MrBoom_l | | | server | Configurable villager brain ticks | William Blake Galbreath | | | server | Cows eat mushrooms | William Blake Galbreath | | | server | Custom Locale Support | Bud Gidiere | | diff --git a/patches/server/0059-Configurable-flight-checks.patch b/patches/server/0059-Configurable-flight-checks.patch index f93137a8..0143be2e 100644 --- a/patches/server/0059-Configurable-flight-checks.patch +++ b/patches/server/0059-Configurable-flight-checks.patch @@ -1,5 +1,5 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: epserv +From: l_MrBoom_l Date: Wed, 30 Sep 2020 18:20:12 +0300 Subject: [PATCH] Configurable flight checks diff --git a/patches/server/0076-Configurable-movement-checks.patch b/patches/server/0076-Configurable-movement-checks.patch new file mode 100644 index 00000000..39e7ec77 --- /dev/null +++ b/patches/server/0076-Configurable-movement-checks.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: l_MrBoom_l +Date: Sun, 8 Nov 2020 19:07:14 +0200 +Subject: [PATCH] Configurable movement checks + + +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index 3a022aa9be7778ba26f005a1c9b926c5f311c525..fbeb13887fdc084fb14da3d57a28e736d5e6ba4c 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -439,7 +439,7 @@ public class PlayerConnection implements PacketListenerPlayIn { + } + // Paper end + +- if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isExemptPlayer()) { ++ if (net.yatopia.server.YatopiaConfig.checkVehicleMovedQuickly && d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isExemptPlayer()) { // Yatopia - Configurable movement checks + // CraftBukkit end + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), d6, d7, d8); + this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity)); +@@ -464,7 +464,7 @@ public class PlayerConnection implements PacketListenerPlayIn { + d10 = d6 * d6 + d7 * d7 + d8 * d8; + boolean flag1 = false; + +- if (d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot ++ if (net.yatopia.server.YatopiaConfig.checkVehicleMovedWrongly && d10 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot // Yatopia - Configurable movement checks + flag1 = true; + PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Math.sqrt(d10)); + } +@@ -1151,7 +1151,7 @@ public class PlayerConnection implements PacketListenerPlayIn { + if (!this.player.H() && (!this.player.getWorldServer().getGameRules().getBoolean(GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isGliding())) { + float f2 = this.player.isGliding() ? 300.0F : 100.0F; + +- if (d11 - d10 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isExemptPlayer()) { ++ if (net.yatopia.server.YatopiaConfig.checkMovedQuickly && d11 - d10 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isExemptPlayer()) { // Yatopia - Configurable movement checks + // CraftBukkit end + PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9); + this.a(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.yaw, this.player.pitch); +@@ -1217,7 +1217,7 @@ public class PlayerConnection implements PacketListenerPlayIn { + d11 = d7 * d7 + d8 * d8 + d9 * d9; + boolean flag1 = false; + +- if (!this.player.H() && d11 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.playerInteractManager.isCreative() && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR) { // Spigot ++ if (net.yatopia.server.YatopiaConfig.checkMovedWrongly && !this.player.H() && d11 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.playerInteractManager.isCreative() && this.player.playerInteractManager.getGameMode() != EnumGamemode.SPECTATOR) { // Spigot // Yatopia - Configurable movement checks + flag1 = true; + PlayerConnection.LOGGER.warn("{} moved wrongly!", this.player.getDisplayName().getString()); + } +diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java +index 366b1c0f7e55c954a6a2d84e4aaa857764ce1f5a..5139279822b1fdc4a60de5abc76e81c75fe2e6bb 100644 +--- a/src/main/java/net/yatopia/server/YatopiaConfig.java ++++ b/src/main/java/net/yatopia/server/YatopiaConfig.java +@@ -272,4 +272,15 @@ public class YatopiaConfig { + private static void fireBlockPhysicsEvent() { + fireBlockPhysicsEvent = getBoolean("settings.fire-block-physics-event", true); + } ++ ++ public static boolean checkMovedQuickly = true; ++ public static boolean checkMovedWrongly = true; ++ public static boolean checkVehicleMovedQuickly = true; ++ public static boolean checkVehicleMovedWrongly = true; ++ private static void movementChecks() { ++ checkMovedQuickly = getBoolean("settings.checks.moved-quickly", checkMovedQuickly); ++ checkMovedWrongly = getBoolean("settings.checks.moved-wrongly", checkMovedWrongly); ++ checkVehicleMovedQuickly = getBoolean("settings.checks.vehicle-moved-quickly", checkVehicleMovedQuickly); ++ checkVehicleMovedWrongly = getBoolean("settings.checks.vehicle-moved-wrongly", checkVehicleMovedWrongly); ++ } + }