Add PlayerBedFailEnterEvent (#4935)
This commit is contained in:
56
Spigot-Server-Patches/Added-PlayerBedFailEnterEvent.patch
Normal file
56
Spigot-Server-Patches/Added-PlayerBedFailEnterEvent.patch
Normal file
@@ -0,0 +1,56 @@
|
||||
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] Added PlayerBedFailEnterEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
this.g = ichatbasecomponent;
|
||||
}
|
||||
|
||||
+ public @Nullable IChatBaseComponent getChatComponent() { return this.a(); }; // Paper - OBFHELPER
|
||||
@Nullable
|
||||
public IChatBaseComponent a() {
|
||||
return this.g;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BlockBed.java b/src/main/java/net/minecraft/world/level/block/BlockBed.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BlockBed.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BlockBed.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
|
||||
import net.minecraft.world.phys.shapes.VoxelShapes;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
+import io.papermc.paper.event.player.PlayerBedFailEnterEvent; // Paper
|
||||
+import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
|
||||
public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
|
||||
|
||||
@@ -0,0 +0,0 @@ public class BlockBed extends BlockFacingHorizontal implements ITileEntity {
|
||||
BlockPosition finalblockposition = blockposition;
|
||||
// CraftBukkit end
|
||||
entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> {
|
||||
+ // Paper start - PlayerBedFailEnterEvent
|
||||
+ if (entityhuman_enumbedresult != null) {
|
||||
+ PlayerBedFailEnterEvent event = new PlayerBedFailEnterEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), PlayerBedFailEnterEvent.FailReason.VALUES[entityhuman_enumbedresult.ordinal()], org.bukkit.craftbukkit.block.CraftBlock.at(world, finalblockposition), entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE, PaperAdventure.asAdventure(entityhuman_enumbedresult.getChatComponent()));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start - handling bed explosion from below here
|
||||
- if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) {
|
||||
+ if (event.getWillExplode()) { // Paper
|
||||
this.explodeBed(finaliblockdata, world, finalblockposition);
|
||||
} else
|
||||
// CraftBukkit end
|
||||
if (entityhuman_enumbedresult != null) {
|
||||
- entityhuman.a(entityhuman_enumbedresult.a(), true);
|
||||
+ entityhuman.a(PaperAdventure.asVanilla(event.getMessage()), true); // Paper
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
});
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
Reference in New Issue
Block a user