Update Leash Syntax To Entity by tibisabau · Pull Request #8413 · SkriptLang/Skript
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 fromSimplePropertyExpression<LivingEntity, Entity>toSimplePropertyExpression<Entity, Entity>EffLeash.java- Updated to acceptExpression<Entity>instead ofExpression<LivingEntity>for both leash and unleash operationsCondLeashed.java- Changed fromPropertyCondition<LivingEntity>toPropertyCondition<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 entitiesCondLeashed.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.