aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0543-Add-PlayerDeepSleepEvent.patch
blob: 7dfa56bff7316ece4ea26901bbc6f26430aa25dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 203f36776f41c46172b77a195d3702dd6af7409e..e765b6f1163edb363ddebe0c83ca733a061ff103 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -247,6 +247,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;
             }