Support MyPet 4 entity lookup while retaining MyPet 3 compatibility - #1990
Support MyPet 4 entity lookup while retaining MyPet 3 compatibility#1990mercurialmusic wants to merge 2 commits into
Conversation
|
Can I perhaps suggest doing this in the reverse way - use reflection for MyPet 3 (the legacy version) and direct import MyPet 4? Looks good otherwise, I also made my own fork but forgot to PR it :P |
Thanks for the review and direction! I’ve updated the implementation so that MyPet 4 is now the primary compile-time API, with MyPet 3 compatibility handled through reflection instead. The revised changes now:
I also rechecked the implementation against the current MyPet 4 source and the MyPet 3 source. The expected methods and package names match both versions, and isolated runtime checks confirmed that:
The updated Jobs build completed successfully, and the plugin has been tested on Paper 26.2 with Java 25. It loads without errors, the previous @UserDerezzed would still appreciate your review again as well! |
|
Looks good to me :) just needs Jobs authors’ approvals |
Description
This updates the Jobs MyPet hook to support the rewritten MyPet 4 API while retaining compatibility with the MyPet 3 API currently used to compile Jobs.
MyPet 4 removed
MyPetBukkitEntity. As a result, the existinginstanceof MyPetBukkitEntitycheck throws aNoClassDefFoundErrorwhenever Jobs handles an applicableEntityDeathEventon a server running MyPet 4.MyPet 4 pets are now regular Bukkit entities registered with MyPet's
PetManager. The updated hook detects the available MyPet API and uses the appropriate lookup path:MyPetBukkitEntityimplementation.MyPetApi#getPetManager()andPetManager#getPetFromEntity(Entity).Reflection is used for the MyPet 4 path so Jobs can continue compiling against its existing MyPet 3 dependency without requiring a broader dependency or build-system change. This was done largely because MyPet 4 has gone open-source premium, it's only just released, and I expect many users will remain on MyPet 3 for a while.
Testing
Tested with:
The plugin compiled successfully and loaded without errors. The previous
NoClassDefFoundErrorconsole spam is no longer present, and the MyPet integration appears to function correctly during initial testing.Scope
This change is limited to
MyPetManagerand does not modify Jobs' bundled MyPet dependency, general payment handling, or other plugin hooks.Closes #1989