Do not remove leash knot if leasing to an existing leash knot gets cancelled

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2024-04-28 07:27:18 +10:00
parent 6041b5c6b5
commit 44c4305918

View File

@ -14,20 +14,21 @@
public class EntityLeash extends EntityHanging {
public static final double OFFSET_Y = 0.375D;
@@ -89,6 +96,12 @@
@@ -89,6 +96,13 @@
EntityInsentient entityinsentient = (EntityInsentient) iterator.next();
if (entityinsentient.getLeashHolder() == entityhuman) {
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman, enumhand).isCancelled()) {
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
+ flag = true; // Also set true when the event is cancelled otherwise it tries to unleash the entities
+ continue;
+ }
+ // CraftBukkit end
entityinsentient.setLeashedTo(this, true);
flag = true;
}
@@ -97,18 +110,32 @@
@@ -97,18 +111,32 @@
boolean flag1 = false;
if (!flag) {