mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 11:24:11 +01:00
SPIGOT-6316: PlayerBedLeaveEvent implements Cancellable
By: md_5 <git@md-5.net>
This commit is contained in:
parent
7405148b11
commit
022d868fa2
2 changed files with 92 additions and 105 deletions
|
@ -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()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/net/minecraft/server/EntityPlayer.java
|
||||
@@ -15,6 +15,27 @@
|
||||
@@ -15,6 +15,28 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
|||
+import org.bukkit.craftbukkit.event.CraftPortalEvent;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
|
||||
+import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
+import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
|
@ -28,7 +29,7 @@
|
|||
public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -60,6 +81,20 @@
|
||||
@@ -60,6 +82,20 @@
|
||||
public int ping;
|
||||
public boolean viewingCredits;
|
||||
|
||||
|
@ -49,7 +50,7 @@
|
|||
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
|
||||
super(worldserver, worldserver.getSpawn(), worldserver.v(), gameprofile);
|
||||
this.spawnDimension = World.OVERWORLD;
|
||||
@@ -71,12 +106,56 @@
|
||||
@@ -71,12 +107,56 @@
|
||||
this.G = 1.0F;
|
||||
this.c(worldserver);
|
||||
this.co = minecraftserver.a(this);
|
||||
|
@ -58,8 +59,8 @@
|
|||
+ this.displayName = this.getName();
|
||||
+ this.canPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
|
||||
+ // If this is an issue, PRs are welcome
|
||||
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
|
||||
|
@ -96,9 +97,9 @@
|
|||
+ }
|
||||
+
|
||||
+ return blockposition;
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+
|
||||
private void c(WorldServer worldserver) {
|
||||
BlockPosition blockposition = worldserver.getSpawn();
|
||||
|
||||
|
@ -107,7 +108,7 @@
|
|||
int i = Math.max(0, this.server.a(worldserver));
|
||||
int j = MathHelper.floor(worldserver.getWorldBorder().b((double) blockposition.getX(), (double) blockposition.getZ()));
|
||||
|
||||
@@ -142,11 +221,20 @@
|
||||
@@ -142,11 +222,20 @@
|
||||
if (nbttagcompound.hasKeyOfType("recipeBook", 10)) {
|
||||
this.recipeBook.a(nbttagcompound.getCompound("recipeBook"), this.server.getCraftingManager());
|
||||
}
|
||||
|
@ -128,7 +129,7 @@
|
|||
if (nbttagcompound.hasKeyOfType("SpawnX", 99) && nbttagcompound.hasKeyOfType("SpawnY", 99) && nbttagcompound.hasKeyOfType("SpawnZ", 99)) {
|
||||
this.spawn = new BlockPosition(nbttagcompound.getInt("SpawnX"), nbttagcompound.getInt("SpawnY"), nbttagcompound.getInt("SpawnZ"));
|
||||
this.spawnForced = nbttagcompound.getBoolean("SpawnForced");
|
||||
@@ -180,7 +268,20 @@
|
||||
@@ -180,7 +269,20 @@
|
||||
Entity entity = this.getRootVehicle();
|
||||
Entity entity1 = this.getVehicle();
|
||||
|
||||
|
@ -150,7 +151,7 @@
|
|||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
|
||||
|
||||
@@ -198,7 +299,7 @@
|
||||
@@ -198,7 +300,7 @@
|
||||
nbttagcompound.setInt("SpawnZ", this.spawn.getZ());
|
||||
nbttagcompound.setBoolean("SpawnForced", this.spawnForced);
|
||||
nbttagcompound.setFloat("SpawnAngle", this.spawnAngle);
|
||||
|
@ -159,7 +160,7 @@
|
|||
Logger logger = EntityPlayer.LOGGER;
|
||||
|
||||
logger.getClass();
|
||||
@@ -206,9 +307,33 @@
|
||||
@@ -206,9 +308,33 @@
|
||||
nbttagcompound.set("SpawnDimension", nbtbase);
|
||||
});
|
||||
}
|
||||
|
@ -193,7 +194,7 @@
|
|||
public void a(int i) {
|
||||
float f = (float) this.getExpToLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -262,6 +387,11 @@
|
||||
@@ -262,6 +388,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
@ -205,7 +206,7 @@
|
|||
this.playerInteractManager.a();
|
||||
--this.invulnerableTicks;
|
||||
if (this.noDamageTicks > 0) {
|
||||
@@ -329,7 +459,7 @@
|
||||
@@ -329,7 +460,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() != this.lastHealthSent || this.lastFoodSent != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastSentSaturationZero) {
|
||||
|
@ -214,7 +215,7 @@
|
|||
this.lastHealthSent = this.getHealth();
|
||||
this.lastFoodSent = this.foodData.getFoodLevel();
|
||||
this.lastSentSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -360,6 +490,12 @@
|
||||
@@ -360,6 +491,12 @@
|
||||
this.a(IScoreboardCriteria.XP, MathHelper.f((float) this.lastExpTotalScored));
|
||||
}
|
||||
|
||||
|
@ -227,7 +228,7 @@
|
|||
if (this.expLevel != this.lastExpLevelScored) {
|
||||
this.lastExpLevelScored = this.expLevel;
|
||||
this.a(IScoreboardCriteria.LEVEL, MathHelper.f((float) this.lastExpLevelScored));
|
||||
@@ -374,6 +510,16 @@
|
||||
@@ -374,6 +511,16 @@
|
||||
CriterionTriggers.p.a(this);
|
||||
}
|
||||
|
||||
|
@ -244,7 +245,7 @@
|
|||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
|
||||
@@ -384,7 +530,8 @@
|
||||
@@ -384,7 +531,8 @@
|
||||
}
|
||||
|
||||
private void a(IScoreboardCriteria iscoreboardcriteria, int i) {
|
||||
|
@ -254,7 +255,7 @@
|
|||
scoreboardscore.setScore(i);
|
||||
});
|
||||
}
|
||||
@@ -392,9 +539,46 @@
|
||||
@@ -392,9 +540,46 @@
|
||||
@Override
|
||||
public void die(DamageSource damagesource) {
|
||||
boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES);
|
||||
|
@ -303,7 +304,7 @@
|
|||
|
||||
this.playerConnection.a((Packet) (new PacketPlayOutCombatEvent(this.getCombatTracker(), PacketPlayOutCombatEvent.EnumCombatEventType.ENTITY_DIED, ichatbasecomponent)), (future) -> {
|
||||
if (!future.isSuccess()) {
|
||||
@@ -428,12 +612,18 @@
|
||||
@@ -428,12 +613,18 @@
|
||||
if (this.world.getGameRules().getBoolean(GameRules.FORGIVE_DEAD_PLAYERS)) {
|
||||
this.eW();
|
||||
}
|
||||
|
@ -326,7 +327,7 @@
|
|||
EntityLiving entityliving = this.getKillingEntity();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -469,10 +659,12 @@
|
||||
@@ -469,10 +660,12 @@
|
||||
String s = this.getName();
|
||||
String s1 = entity.getName();
|
||||
|
||||
|
@ -341,7 +342,7 @@
|
|||
} else {
|
||||
this.a(StatisticList.MOB_KILLS);
|
||||
}
|
||||
@@ -490,7 +682,8 @@
|
||||
@@ -490,7 +683,8 @@
|
||||
int i = scoreboardteam.getColor().b();
|
||||
|
||||
if (i >= 0 && i < aiscoreboardcriteria.length) {
|
||||
|
@ -351,7 +352,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -534,18 +727,20 @@
|
||||
@@ -534,18 +728,20 @@
|
||||
}
|
||||
|
||||
private boolean canPvP() {
|
||||
|
@ -375,7 +376,7 @@
|
|||
} else {
|
||||
return shapedetectorshape;
|
||||
}
|
||||
@@ -554,11 +749,20 @@
|
||||
@@ -554,11 +750,20 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity b(WorldServer worldserver) {
|
||||
|
@ -399,7 +400,7 @@
|
|||
this.decouple();
|
||||
this.getWorldServer().removePlayer(this);
|
||||
if (!this.viewingCredits) {
|
||||
@@ -569,6 +773,8 @@
|
||||
@@ -569,6 +774,8 @@
|
||||
|
||||
return this;
|
||||
} else {
|
||||
|
@ -408,7 +409,7 @@
|
|||
WorldData worlddata = worldserver.getWorldData();
|
||||
|
||||
this.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.getDimensionManager(), worldserver.getDimensionKey(), BiomeManager.a(worldserver.getSeed()), this.playerInteractManager.getGameMode(), this.playerInteractManager.c(), worldserver.isDebugWorld(), worldserver.isFlatWorld(), true));
|
||||
@@ -578,22 +784,52 @@
|
||||
@@ -578,22 +785,52 @@
|
||||
playerlist.d(this);
|
||||
worldserver1.removePlayer(this);
|
||||
this.dead = false;
|
||||
|
@ -467,7 +468,7 @@
|
|||
worldserver1.getMethodProfiler().exit();
|
||||
this.triggerDimensionAdvancements(worldserver1);
|
||||
this.playerInteractManager.a(worldserver);
|
||||
@@ -612,12 +848,31 @@
|
||||
@@ -612,12 +849,31 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastHealthSent = -1.0F;
|
||||
this.lastFoodSent = -1;
|
||||
|
@ -499,7 +500,7 @@
|
|||
private void a(WorldServer worldserver, BlockPosition blockposition) {
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.i();
|
||||
|
||||
@@ -634,17 +889,17 @@
|
||||
@@ -634,17 +890,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -522,7 +523,7 @@
|
|||
}
|
||||
|
||||
return optional1;
|
||||
@@ -688,10 +943,8 @@
|
||||
@@ -688,10 +944,8 @@
|
||||
this.activeContainer.c();
|
||||
}
|
||||
|
||||
|
@ -535,7 +536,7 @@
|
|||
if (!this.isSleeping() && this.isAlive()) {
|
||||
if (!this.world.getDimensionManager().isNatural()) {
|
||||
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
|
||||
@@ -717,7 +970,36 @@
|
||||
@@ -717,7 +971,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -573,7 +574,7 @@
|
|||
this.a(StatisticList.SLEEP_IN_BED);
|
||||
CriterionTriggers.q.a(this);
|
||||
});
|
||||
@@ -726,9 +1008,8 @@
|
||||
@@ -726,9 +1009,8 @@
|
||||
return either;
|
||||
}
|
||||
}
|
||||
|
@ -584,15 +585,32 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -755,6 +1036,7 @@
|
||||
@@ -755,6 +1037,24 @@
|
||||
|
||||
@Override
|
||||
public void wakeup(boolean flag, boolean flag1) {
|
||||
+ if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one!
|
||||
+ // CraftBukkit start - fire PlayerBedLeaveEvent
|
||||
+ CraftPlayer player = this.getBukkitEntity();
|
||||
+ BlockPosition bedPosition = this.getBedPosition().orElse(null);
|
||||
+
|
||||
+ 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);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.isSleeping()) {
|
||||
this.getWorldServer().getChunkProvider().broadcastIncludingSelf(this, new PacketPlayOutAnimation(this, 2));
|
||||
}
|
||||
@@ -826,8 +1108,9 @@
|
||||
@@ -826,8 +1126,9 @@
|
||||
this.playerConnection.sendPacket(new PacketPlayOutOpenSignEditor(tileentitysign.getPosition()));
|
||||
}
|
||||
|
||||
|
@ -603,7 +621,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -842,6 +1125,24 @@
|
||||
@@ -842,6 +1143,24 @@
|
||||
this.nextContainerCounter();
|
||||
Container container = itileinventory.createMenu(this.containerCounter, this.inventory, this);
|
||||
|
||||
|
@ -628,7 +646,7 @@
|
|||
if (container == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true);
|
||||
@@ -849,9 +1150,11 @@
|
||||
@@ -849,9 +1168,11 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
|
@ -642,7 +660,7 @@
|
|||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -864,13 +1167,24 @@
|
||||
@@ -864,13 +1185,24 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
|
||||
|
@ -669,7 +687,7 @@
|
|||
this.activeContainer.addSlotListener(this);
|
||||
}
|
||||
|
||||
@@ -915,6 +1229,11 @@
|
||||
@@ -915,6 +1247,11 @@
|
||||
public void a(Container container, NonNullList<ItemStack> nonnulllist) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutWindowItems(container.windowId, nonnulllist));
|
||||
this.playerConnection.sendPacket(new PacketPlayOutSetSlot(-1, -1, this.inventory.getCarried()));
|
||||
|
@ -681,7 +699,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -924,6 +1243,7 @@
|
||||
@@ -924,6 +1261,7 @@
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
@ -689,7 +707,7 @@
|
|||
this.playerConnection.sendPacket(new PacketPlayOutCloseWindow(this.activeContainer.windowId));
|
||||
this.o();
|
||||
}
|
||||
@@ -958,7 +1278,7 @@
|
||||
@@ -958,7 +1296,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic, int i) {
|
||||
this.serverStatisticManager.b(this, statistic, i);
|
||||
|
@ -698,7 +716,7 @@
|
|||
scoreboardscore.addScore(i);
|
||||
});
|
||||
}
|
||||
@@ -966,7 +1286,7 @@
|
||||
@@ -966,7 +1304,7 @@
|
||||
@Override
|
||||
public void a(Statistic<?> statistic) {
|
||||
this.serverStatisticManager.setStatistic(this, statistic, 0);
|
||||
|
@ -707,25 +725,24 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1015,8 +1335,17 @@
|
||||
@@ -1015,7 +1353,16 @@
|
||||
|
||||
public void triggerHealthUpdate() {
|
||||
this.lastHealthSent = -1.0E8F;
|
||||
+ this.lastSentExp = -1; // CraftBukkit - Added to reset
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - Support multi-line messages
|
||||
+ public void sendMessage(UUID uuid, IChatBaseComponent[] ichatbasecomponent) {
|
||||
+ for (IChatBaseComponent component : ichatbasecomponent) {
|
||||
+ this.sendMessage(component, (uuid == null) ? SystemUtils.b : uuid);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent, flag ? ChatMessageType.GAME_INFO : ChatMessageType.CHAT, SystemUtils.b));
|
||||
@@ -1068,12 +1397,13 @@
|
||||
@@ -1068,12 +1415,13 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastHealthSent = -1.0F;
|
||||
this.lastFoodSent = -1;
|
||||
|
@ -740,7 +757,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1141,6 +1471,18 @@
|
||||
@@ -1141,6 +1489,18 @@
|
||||
|
||||
@Override
|
||||
public void a(EnumGamemode enumgamemode) {
|
||||
|
@ -759,7 +776,7 @@
|
|||
this.playerInteractManager.setGameMode(enumgamemode);
|
||||
this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.d, (float) enumgamemode.getId()));
|
||||
if (enumgamemode == EnumGamemode.SPECTATOR) {
|
||||
@@ -1190,7 +1532,20 @@
|
||||
@@ -1190,7 +1550,20 @@
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -780,7 +797,7 @@
|
|||
this.bY = packetplayinsettings.d();
|
||||
this.bZ = packetplayinsettings.e();
|
||||
this.getDataWatcher().set(EntityPlayer.bi, (byte) packetplayinsettings.f());
|
||||
@@ -1226,13 +1581,13 @@
|
||||
@@ -1226,13 +1599,13 @@
|
||||
if (entity instanceof EntityHuman) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[]{entity.getId()}));
|
||||
} else {
|
||||
|
@ -796,7 +813,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1256,7 +1611,7 @@
|
||||
@@ -1256,7 +1629,7 @@
|
||||
this.spectatedEntity = (Entity) (entity == null ? this : entity);
|
||||
if (entity1 != this.spectatedEntity) {
|
||||
this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
|
||||
|
@ -805,7 +822,7 @@
|
|||
}
|
||||
|
||||
}
|
||||
@@ -1285,7 +1640,7 @@
|
||||
@@ -1285,7 +1658,7 @@
|
||||
|
||||
@Nullable
|
||||
public IChatBaseComponent getPlayerListName() {
|
||||
|
@ -814,7 +831,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1306,9 +1661,16 @@
|
||||
@@ -1306,9 +1679,16 @@
|
||||
return this.advancementDataPlayer;
|
||||
}
|
||||
|
||||
|
@ -831,7 +848,7 @@
|
|||
if (worldserver == this.world) {
|
||||
this.playerConnection.a(d0, d1, d2, f, f1);
|
||||
} else {
|
||||
@@ -1329,6 +1691,9 @@
|
||||
@@ -1329,6 +1709,9 @@
|
||||
this.server.getPlayerList().a(this, worldserver);
|
||||
this.server.getPlayerList().updateClient(this);
|
||||
}
|
||||
|
@ -841,7 +858,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1426,4 +1791,144 @@
|
||||
@@ -1426,4 +1809,144 @@
|
||||
public ITextFilter Q() {
|
||||
return this.co;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue