API to prevent PlayerBedLeaveEvent from changing a player's spawn location

This commit is contained in:
Senmori 2018-08-29 19:06:33 +10:00 committed by md_5
parent 3831ae621f
commit 1486c29516

View File

@ -332,7 +332,7 @@
this.releaseShoulderEntities();
this.a(StatisticList.CUSTOM.b(StatisticList.TIME_SINCE_REST));
this.setSize(0.2F, 0.2F);
@@ -1212,6 +1354,23 @@
@@ -1212,6 +1354,24 @@
this.world.everyoneSleeping();
}
@ -348,15 +348,16 @@
+ bed = this.world.getWorld().getBlockAt(player.getLocation());
+ }
+
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, flag2);
+ this.world.getServer().getPluginManager().callEvent(event);
+ flag2 = event.shouldSetSpawnLocation();
+ }
+ // CraftBukkit end
+
this.sleepTicks = flag ? 0 : 100;
if (flag2) {
this.setRespawnPosition(this.bedPosition, false);
@@ -1263,9 +1422,11 @@
@@ -1263,9 +1423,11 @@
if (blockposition != null) {
this.e = blockposition;
this.f = flag;
@ -368,7 +369,7 @@
}
}
@@ -1331,7 +1492,11 @@
@@ -1331,7 +1493,11 @@
this.motY = d3 * 0.6D;
this.aU = f3;
this.fallDistance = 0.0F;
@ -381,7 +382,7 @@
} else {
super.a(f, f1, f2);
}
@@ -1631,13 +1796,17 @@
@@ -1631,13 +1797,17 @@
}
protected void releaseShoulderEntities() {
@ -404,7 +405,7 @@
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
Entity entity = EntityTypes.a(nbttagcompound, this.world);
@@ -1646,9 +1815,10 @@
@@ -1646,9 +1816,10 @@
}
entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
@ -416,7 +417,7 @@
}
public abstract boolean isSpectator();
@@ -1859,7 +2029,7 @@
@@ -1859,7 +2030,7 @@
return entitymonster.c(this.a);
}