PaperMC/patches/server/0533-Add-PlayerBedFailEnterEvent.patch

37 lines
2.6 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 24 Dec 2020 12:27:41 -0800
Subject: [PATCH] Add PlayerBedFailEnterEvent
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java
2024-04-24 15:46:45 +02:00
index 68326d7c3bd14e5a66971f34e6ec8ec8e93b728a..03035ed3df2f32e14a8eb9bc3d536ef64b5d87ba 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java
2024-04-24 15:46:45 +02:00
@@ -118,14 +118,23 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock
2021-06-11 14:02:28 +02:00
BlockPos finalblockposition = pos;
// CraftBukkit end
player.startSleepInBed(pos).ifLeft((entityhuman_enumbedresult) -> {
+ // Paper start - PlayerBedFailEnterEvent
+ if (entityhuman_enumbedresult != null) {
2024-02-01 10:15:57 +01:00
+ io.papermc.paper.event.player.PlayerBedFailEnterEvent event = new io.papermc.paper.event.player.PlayerBedFailEnterEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.event.player.PlayerBedFailEnterEvent.FailReason.values()[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), !world.dimensionType().bedWorks(), io.papermc.paper.adventure.PaperAdventure.asAdventure(entityhuman_enumbedresult.getMessage()));
2021-06-11 14:02:28 +02:00
+ if (!event.callEvent()) {
+ return;
+ }
+ // Paper end - PlayerBedFailEnterEvent
2021-06-11 14:02:28 +02:00
// CraftBukkit start - handling bed explosion from below here
- if (!world.dimensionType().bedWorks()) {
+ if (event.getWillExplode()) { // Paper - PlayerBedFailEnterEvent
2021-06-11 14:02:28 +02:00
this.explodeBed(finaliblockdata, world, finalblockposition);
} else
// CraftBukkit end
2022-06-08 10:00:56 +02:00
if (entityhuman_enumbedresult.getMessage() != null) {
2021-06-11 14:02:28 +02:00
- player.displayClientMessage(entityhuman_enumbedresult.getMessage(), true);
+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent
+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent
2021-06-11 14:02:28 +02:00
}
+ } // Paper - PlayerBedFailEnterEvent
2021-06-11 14:02:28 +02:00
});
return InteractionResult.SUCCESS;