SPIGOT-7487: entity.remove() on a leash drops a lead item

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2023-12-01 08:01:44 +11:00
parent dd57b4aec5
commit 0f6da6b1c8
3 changed files with 57 additions and 42 deletions

View File

@@ -94,6 +94,15 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -456,7 +514,7 @@
}
nbttagcompound.put("HandDropChances", nbttaglist3);
- if (this.leashHolder != null) {
+ if (this.leashHolder != null && !this.leashHolder.pluginRemoved) { // CraftBukkit - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin
nbttagcompound2 = new NBTTagCompound();
if (this.leashHolder instanceof EntityLiving) {
UUID uuid = this.leashHolder.getUUID();
@@ -487,16 +545,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@@ -256,14 +265,16 @@
if (this.isPassenger()) {
Entity entity = this.getVehicle();
@@ -1333,6 +1445,7 @@
@@ -1333,7 +1445,8 @@
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
- this.dropLeash(true, true);
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
this.dropLeash(true, true);
+ this.dropLeash(true, !this.leashHolder.pluginRemoved);// CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
}
}
@@ -1344,7 +1457,9 @@
this.leashHolder = null;
this.leashInfoTag = null;