SPIGOT-6316: PlayerBedLeaveEvent implements Cancellable
By: md_5 <git@md-5.net>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/EntityHuman.java
|
||||
+++ b/net/minecraft/server/EntityHuman.java
|
||||
@@ -16,10 +16,24 @@
|
||||
@@ -16,10 +16,22 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
+import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
+import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
+import org.bukkit.util.Vector;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityHuman extends EntityLiving {
|
||||
@@ -26,7 +24,7 @@
|
||||
private static final DataWatcherObject<Float> c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
|
||||
private static final DataWatcherObject<Integer> d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
|
||||
protected static final DataWatcherObject<Byte> bi = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
|
||||
@@ -28,10 +42,10 @@
|
||||
@@ -28,10 +40,10 @@
|
||||
protected static final DataWatcherObject<NBTTagCompound> bl = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
|
||||
private long e;
|
||||
public final PlayerInventory inventory = new PlayerInventory(this);
|
||||
@@ -39,7 +37,7 @@
|
||||
protected int br;
|
||||
public float bs;
|
||||
public float bt;
|
||||
@@ -57,6 +71,16 @@
|
||||
@@ -57,6 +69,16 @@
|
||||
@Nullable
|
||||
public EntityFishingHook hookedFish;
|
||||
|
||||
@@ -56,7 +54,7 @@
|
||||
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
|
||||
super(EntityTypes.PLAYER, world);
|
||||
this.bL = ItemStack.b;
|
||||
@@ -194,7 +218,7 @@
|
||||
@@ -194,7 +216,7 @@
|
||||
ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
||||
|
||||
if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a((Tag) TagsFluid.WATER)) {
|
||||
@@ -65,7 +63,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,7 +383,8 @@
|
||||
@@ -359,7 +381,8 @@
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) {
|
||||
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
|
||||
@@ -75,7 +73,7 @@
|
||||
}
|
||||
|
||||
if (this.foodData.c() && this.ticksLived % 10 == 0) {
|
||||
@@ -544,6 +569,30 @@
|
||||
@@ -544,6 +567,30 @@
|
||||
entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
|
||||
}
|
||||
|
||||
@@ -106,7 +104,7 @@
|
||||
return entityitem;
|
||||
}
|
||||
}
|
||||
@@ -670,16 +719,17 @@
|
||||
@@ -670,16 +717,17 @@
|
||||
if (this.isInvulnerable(damagesource)) {
|
||||
return false;
|
||||
} else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
|
||||
@@ -126,7 +124,7 @@
|
||||
}
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
|
||||
@@ -691,7 +741,13 @@
|
||||
@@ -691,7 +739,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +139,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -706,10 +762,29 @@
|
||||
@@ -706,10 +760,29 @@
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
@@ -174,7 +172,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -746,8 +821,13 @@
|
||||
@@ -746,8 +819,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +187,7 @@
|
||||
if (!this.isInvulnerable(damagesource)) {
|
||||
f = this.applyArmorModifier(damagesource, f);
|
||||
f = this.applyMagicModifier(damagesource, f);
|
||||
@@ -773,6 +853,7 @@
|
||||
@@ -773,6 +851,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
@@ -197,7 +195,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -932,7 +1013,7 @@
|
||||
@@ -932,7 +1011,7 @@
|
||||
|
||||
f *= 0.2F + f2 * f2 * 0.8F;
|
||||
f1 *= f2;
|
||||
@@ -206,7 +204,7 @@
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = f2 > 0.9F;
|
||||
boolean flag1 = false;
|
||||
@@ -971,8 +1052,15 @@
|
||||
@@ -971,8 +1050,15 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
f3 = ((EntityLiving) entity).getHealth();
|
||||
if (j > 0 && !entity.isBurning()) {
|
||||
@@ -224,7 +222,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,8 +1088,11 @@
|
||||
@@ -1000,8 +1086,11 @@
|
||||
EntityLiving entityliving = (EntityLiving) iterator.next();
|
||||
|
||||
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) {
|
||||
@@ -237,7 +235,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,9 +1101,26 @@
|
||||
@@ -1010,9 +1099,26 @@
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && entity.velocityChanged) {
|
||||
@@ -264,7 +262,7 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -1057,7 +1165,14 @@
|
||||
@@ -1057,7 +1163,14 @@
|
||||
|
||||
this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
|
||||
if (j > 0) {
|
||||
@@ -280,7 +278,7 @@
|
||||
}
|
||||
|
||||
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
||||
@@ -1073,6 +1188,11 @@
|
||||
@@ -1073,6 +1186,11 @@
|
||||
if (flag4) {
|
||||
entity.extinguish();
|
||||
}
|
||||
@@ -292,7 +290,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1133,17 +1253,40 @@
|
||||
@@ -1133,6 +1251,12 @@
|
||||
}
|
||||
|
||||
public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
|
||||
@@ -305,35 +303,7 @@
|
||||
this.entitySleep(blockposition);
|
||||
this.sleepTicks = 0;
|
||||
return Either.right(Unit.INSTANCE);
|
||||
}
|
||||
|
||||
public void wakeup(boolean flag, boolean flag1) {
|
||||
+ BlockPosition bedPosition = this.getBedPosition().orElse(null); // CraftBukkit
|
||||
super.entityWakeup();
|
||||
if (this.world instanceof WorldServer && flag1) {
|
||||
((WorldServer) this.world).everyoneSleeping();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - fire PlayerBedLeaveEvent
|
||||
+ if (this.getBukkitEntity() instanceof Player) {
|
||||
+ Player player = (Player) this.getBukkitEntity();
|
||||
+
|
||||
+ org.bukkit.block.Block bed;
|
||||
+ if (bedPosition != null) {
|
||||
+ bed = this.world.getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ());
|
||||
+ } else {
|
||||
+ bed = this.world.getWorld().getBlockAt(player.getLocation());
|
||||
+ }
|
||||
+
|
||||
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.sleepTicks = flag ? 0 : 100;
|
||||
}
|
||||
|
||||
@@ -1253,7 +1396,11 @@
|
||||
@@ -1253,7 +1377,11 @@
|
||||
this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z);
|
||||
this.aE = f;
|
||||
this.fallDistance = 0.0F;
|
||||
@@ -346,7 +316,7 @@
|
||||
} else {
|
||||
super.g(vec3d);
|
||||
}
|
||||
@@ -1383,12 +1530,24 @@
|
||||
@@ -1383,12 +1511,24 @@
|
||||
}
|
||||
|
||||
public void startGliding() {
|
||||
@@ -372,7 +342,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1555,14 +1714,21 @@
|
||||
@@ -1555,14 +1695,21 @@
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
@@ -397,7 +367,7 @@
|
||||
this.inventory.armor.set(enumitemslot.b(), itemstack);
|
||||
}
|
||||
|
||||
@@ -1603,26 +1769,31 @@
|
||||
@@ -1603,26 +1750,31 @@
|
||||
|
||||
protected void releaseShoulderEntities() {
|
||||
if (this.e + 20L < this.world.getTime()) {
|
||||
|
||||
Reference in New Issue
Block a user