1
0
forked from xjboss/KCauldronX

Fix inventory erase when player respawns by mods or plugins

Close #301
This commit is contained in:
Sergey Shatunov 2016-02-01 18:50:02 +07:00
parent 12b0a52ae0
commit 07698c433a
3 changed files with 8 additions and 5 deletions

View File

@ -450,10 +450,10 @@
+ // Cauldron start - refactor entire method for sanity.
+ public EntityPlayerMP respawnPlayer(EntityPlayerMP par1EntityPlayerMP, int par2, boolean par3)
+ {
+ return this.respawnPlayer(par1EntityPlayerMP, par2, par3, null);
+ return this.respawnPlayer(par1EntityPlayerMP, par2, par3, null, TeleportCause.DEATH);
+ }
+
+ public EntityPlayerMP respawnPlayer(EntityPlayerMP par1EntityPlayerMP, int targetDimension, boolean returnFromEnd, Location location)
+ public EntityPlayerMP respawnPlayer(EntityPlayerMP par1EntityPlayerMP, int targetDimension, boolean returnFromEnd, Location location, TeleportCause cause)
+ {
+ // Phase 1 - check if the player is allowed to respawn in same dimension
+ World world = mcServer.worldServerForDimension(targetDimension);
@ -506,7 +506,7 @@
+ EntityPlayerMP entityplayermp1 = new EntityPlayerMP(mcServer, mcServer.worldServerForDimension(targetDimension), par1EntityPlayerMP.getGameProfile(), new ItemInWorldManager(mcServer.worldServerForDimension(targetDimension)));
+ entityplayermp1.playerNetServerHandler = par1EntityPlayerMP.playerNetServerHandler;
+ entityplayermp1.playerNetServerHandler.playerEntity = entityplayermp1;
+ entityplayermp1.clonePlayer(par1EntityPlayerMP, returnFromEnd); // KCauldron - clone player
+ entityplayermp1.clonePlayer(par1EntityPlayerMP, cause != TeleportCause.DEATH); // KCauldron - clone player
+ entityplayermp1.setWorld(mcServer.worldServerForDimension(targetDimension));;
+ entityplayermp1.playerConqueredTheEnd = false;
+ entityplayermp1.setEntityId(par1EntityPlayerMP.getEntityId());

View File

@ -1,6 +1,6 @@
--- ../src-base/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java
+++ ../src-work/minecraft/org/bukkit/event/player/PlayerTeleportEvent.java
@@ -55,11 +55,27 @@
@@ -55,11 +55,30 @@
* portal
*/
END_PORTAL,
@ -11,6 +11,9 @@
+ */
+ MOD,
+ // Cauldron end
+ // KCauldron start
+ DEATH,
+ // KCauldron end
+ /**
* Indicates the teleportation was caused by an event not covered by
* this enum

View File

@ -503,7 +503,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
if (fromWorld == toWorld) {
entity.playerNetServerHandler.teleport(to);
} else {
server.getHandle().respawnPlayer(entity, toWorld.dimension, false, to); // Cauldron
server.getHandle().respawnPlayer(entity, toWorld.dimension, false, to, cause); // Cauldron
}
return true;
}