Paper/patches/server/0542-Add-PlayerDeepSleepEvent.patch
Owen 89d51d5f29
Allow enabling sand duping (#10191)
Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable.

It should be noted that this decision does not promise all future exploits will be configurable.
2024-03-03 17:05:34 -05:00

25 lines
1.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Wed, 21 Apr 2021 15:58:19 -0700
Subject: [PATCH] Add PlayerDeepSleepEvent
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 6fe21c29aa9d119490fbf1d69eb03c146674cde5..8ab62f37c9e1eb1582fba4adc02c3404bebc80f4 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -248,6 +248,13 @@ public abstract class Player extends LivingEntity {
if (this.isSleeping()) {
++this.sleepCounter;
+ // Paper start - Add PlayerDeepSleepEvent
+ if (this.sleepCounter == SLEEP_DURATION) {
+ if (!new io.papermc.paper.event.player.PlayerDeepSleepEvent((org.bukkit.entity.Player) getBukkitEntity()).callEvent()) {
+ this.sleepCounter = Integer.MIN_VALUE;
+ }
+ }
+ // Paper end - Add PlayerDeepSleepEvent
if (this.sleepCounter > 100) {
this.sleepCounter = 100;
}