mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2025-09-18 21:54:50 +00:00
SPIGOT-7643: Fix inverted leash event cancelled usage and remove leash knot if no entity gets leashed
This commit is contained in:
parent
7ddb482941
commit
f70367d429
1 changed files with 13 additions and 3 deletions
|
@ -30,7 +30,7 @@
|
|||
EntityLeash entityleash = null;
|
||||
double d0 = 7.0D;
|
||||
int i = blockposition.getX();
|
||||
@@ -54,12 +59,29 @@
|
||||
@@ -54,19 +59,50 @@
|
||||
|
||||
EntityInsentient entityinsentient;
|
||||
|
||||
|
@ -55,13 +55,23 @@
|
|||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||
+ entityinsentient.setLeashedTo(entityleash, true);
|
||||
+ iterator.remove();
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ entityinsentient.setLeashedTo(entityleash, true);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
@@ -69,4 +91,10 @@
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman));
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else {
|
||||
+ // CraftBukkit start- remove leash if we do not leash any entity because of the cancelled event
|
||||
+ if (entityleash != null) {
|
||||
+ entityleash.discard(null);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue