mirror of https://github.com/PaperMC/Paper.git
Merge 8b713e1650
into 8f7ac62905
This commit is contained in:
commit
353eca2d9f
|
@ -0,0 +1,77 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Mon, 1 May 2023 15:23:34 -0500
|
||||
Subject: [PATCH] Add PlayerPreRespawnLocationEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bae7b9d61a061f9a4cc812c1b9107b2695dd5374
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerPreRespawnLocationEvent.java
|
||||
@@ -0,0 +1,65 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a respawn event tries to determine the location of a respawn. This is called before {@link PlayerRespawnEvent}
|
||||
+ */
|
||||
+public class PlayerPreRespawnLocationEvent extends PlayerEvent {
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+ private final PlayerRespawnEvent.RespawnReason respawnReason;
|
||||
+ private Location respawnLocation;
|
||||
+
|
||||
+ public PlayerPreRespawnLocationEvent(@NotNull final Player respawnPlayer, PlayerRespawnEvent.RespawnReason respawnReason) {
|
||||
+ super(respawnPlayer);
|
||||
+ this.respawnReason = respawnReason;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current respawn location
|
||||
+ *
|
||||
+ * @return Location current respawn location
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Location getRespawnLocation() {
|
||||
+ return this.respawnLocation != null ? this.respawnLocation.clone() : null;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the new respawn location.
|
||||
+ *
|
||||
+ * @param respawnLocation The exact location for the respawn. Can be set to null to invalidate any previously called/modified events<br/>
|
||||
+ * <b>Note:</b> If this is provided, <b>no vanilla logic that calculates "safe" respawn locations will be done.</b> It is up to you to ensure you are
|
||||
+ * providing a good respawn location for a Player.
|
||||
+ */
|
||||
+ public void setRespawnLocation(@Nullable Location respawnLocation) {
|
||||
+ this.respawnLocation = respawnLocation;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the reason this respawn event was called.
|
||||
+ *
|
||||
+ * @return the reason the event was called.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public PlayerRespawnEvent.RespawnReason getRespawnReason() {
|
||||
+ return respawnReason;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Cryptite <cryptite@gmail.com>
|
||||
Date: Mon, 1 May 2023 15:23:34 -0500
|
||||
Subject: [PATCH] Add PlayerPreRespawnLocationEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 4d837c1530a3031a4c2a5a39d87bd013d60e14a6..203d43c0902132bed1e396bc956d2313447d3534 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -835,6 +835,14 @@ public abstract class PlayerList {
|
||||
|
||||
// CraftBukkit start - fire PlayerRespawnEvent
|
||||
if (location == null) {
|
||||
+ // Paper start
|
||||
+ Player respawnPlayer = entityplayer1.getBukkitEntity();
|
||||
+ io.papermc.paper.event.player.PlayerPreRespawnLocationEvent preRespawnEvent = new io.papermc.paper.event.player.PlayerPreRespawnLocationEvent(respawnPlayer, reason);
|
||||
+ preRespawnEvent.callEvent();
|
||||
+ location = preRespawnEvent.getRespawnLocation();
|
||||
+
|
||||
+ if (location == null) {
|
||||
+ // Paper end
|
||||
// boolean isBedSpawn = false; // Paper - moved up
|
||||
ServerLevel worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension());
|
||||
if (worldserver1 != null) {
|
||||
@@ -876,8 +884,8 @@ public abstract class PlayerList {
|
||||
blockposition = entityplayer1.getSpawnPoint(worldserver1);
|
||||
location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F), worldserver1.levelData.getSpawnAngle(), 0.0F); // Paper - use world spawn angle
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
- Player respawnPlayer = entityplayer1.getBukkitEntity();
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !isAnchorSpawn, isAnchorSpawn, reason, com.google.common.collect.ImmutableSet.<org.bukkit.event.player.PlayerRespawnEvent.RespawnFlag>builder().add(respawnFlags)); // Paper - Fix anchor respawn acting as a bed respawn from the end portal
|
||||
this.cserver.getPluginManager().callEvent(respawnEvent);
|
||||
// Spigot Start
|
Loading…
Reference in New Issue