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

Dieser Commit ist enthalten in:
Senmori 2018-08-29 19:06:33 +10:00 committet von md_5
Ursprung 3831ae621f
Commit 1486c29516

Datei anzeigen

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