Skip to content

Update Leash Syntax To Entity#8413

Open
tibisabau wants to merge 6 commits intoSkriptLang:dev/featurefrom
tibisabau:feature/update-leash-syntax-entities
Open

Update Leash Syntax To Entity#8413
tibisabau wants to merge 6 commits intoSkriptLang:dev/featurefrom
tibisabau:feature/update-leash-syntax-entities

Conversation

@tibisabau
Copy link

Problem

Leash-related syntax (leash holder expression, leash/unleash effects, and is leashed condition) only accepted LivingEntity types, preventing users from leashing boats and other non-living leashable entities. Users had to resort to reflection workarounds to leash boats.

Solution

Updated all three leash-related syntax files to accept any Entity type and utilize Paper's Leashable interface (available in Paper 1.21+) with runtime version checking via Skript.classExists(). The implementation falls back to the legacy LivingEntity.getLeashHolder() approach for older server versions, maintaining full backward compatibility.

Modified Files:

  • ExprLeashHolder.java - Changed from SimplePropertyExpression<LivingEntity, Entity> to SimplePropertyExpression<Entity, Entity>
  • EffLeash.java - Updated to accept Expression<Entity> instead of Expression<LivingEntity> for both leash and unleash operations
  • CondLeashed.java - Changed from PropertyCondition<LivingEntity> to PropertyCondition<Entity>

Testing Completed

  • Created comprehensive test files:
    • ExprLeashHolder.sk - Tests leash holder expression with wolves and non-leashable entities (snowballs)
    • EffLeash.sk - Tests leash/unleash effects with living entities, non-living entities, and multiple entities
    • CondLeashed.sk - Tests is leashed condition with various entity types
  • ./gradlew clean build - SUCCESS (0 errors)
  • ./gradlew clean quickTest - SUCCESS (all tests passed including "leash effect", "leash holder expression", and "is leashed condition")

Supporting Information

The implementation uses Paper's io.papermc.paper.entity.Leashable interface which provides consistent leashing behavior across all entity types. Non-leashable entities return null/false without throwing exceptions, ensuring graceful handling of edge cases.


Completes: #8239
Related: none
AI assistance: GitHub Copilot with Claude Sonnet 4.5 model

The code in this pull request was generated by GitHub Copilot with the Claude Sonnet 4.5 model.

@tibisabau tibisabau requested a review from a team as a code owner January 28, 2026 22:38
@tibisabau tibisabau requested review from APickledWalrus and TheMug06 and removed request for a team January 28, 2026 22:38
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Jan 28, 2026
@TheMug06
Copy link
Contributor

Duplicate of #8241

@TheMug06 TheMug06 marked this as a duplicate of #8241 Jan 28, 2026
Copy link
Contributor

@TheMug06 TheMug06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests contain lines attempting to leash entities to blocks, while the syntax does not offer support for this. Also never checks whether syntax even succeeded See sovde's comments

Instanceof checks do not need to have the entire path of the class, can just check for Leashable instead of io.papermc.paper.entity.Leashable.

Perhaps add a new version to @Since to indicate changes to what entities can be leashed.

The rest looks good to me!

@skriptlang-automation skriptlang-automation bot removed the needs reviews A PR that needs additional reviews label Jan 28, 2026
Copy link
Contributor

@Absolutionism Absolutionism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a feature PR, it will be added in Skript 2.15, which the minimum MC version will be 1.21.1 (only a singular bump in the minor version). 1.21.1 contains Leashable, so there is no need for the SUPPORTS_LEASHABLE

Copy link
Contributor

@TheMug06 TheMug06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description of EffLeash is not accurate, as Ender Dragon, Wither, and Bat are all subinterfaces of Leashable, thus should be leashable (?)

New version in @Since should be INSERT VERSION, not 2.10, which has been out for a long time. (AI does not know this.) Its description (currently entities) could also be slightly more descriptive, as it doesn't really say anything about what changed after the new version.

@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Jan 29, 2026
@TheMug06
Copy link
Contributor

I still don't really love the since, the differences between LivingEntity and Leashable are not just non-living entities.

@tibisabau tibisabau requested a review from sovdeeth January 30, 2026 08:34
Copy link
Contributor

@TheMug06 TheMug06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Since, any entity type is not accurate either, as not every entity type is Leashable (Think Player, Armor Stand).

Additionally, asserting whether a zombie is not leashed with "... non-leashable entity ..." makes no sense, as zombies are leashable.

@sovdeeth
Copy link
Member

@tibisabau have you played Minecraft before? It seems like a lot of these changes are just blind guesses in the dark. I suggest you reference Paper's javadocs for Leashable or at least the minecraft wiki.

Tests failing due to leashing entity to self working in 1.21.3/1.21.1.

@TheMug06
Copy link
Contributor

Skript users probably will not know what entities implementing Leashable means... Perhaps think of something that,

  1. Makes sense in the context of the change
  2. Will make sense to Skript users

Comment on lines +33 to +35
# Check if self-leashing is supported by the Leashable API
if {_self} is leashed:
assert leash holder of {_self} is {_self} with "if self-leashing works, holder should be itself"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit iffy, we should really be checking exact versions it should work on.
But whatever, it's probably ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants