Use Location for integration canLeash checks and enforce claim checks for fence leashing#12
Use Location for integration canLeash checks and enforce claim checks for fence leashing#12SrBedrock wants to merge 5 commits intoNaspoDev:mainfrom
Conversation
Refactor integration permission checks to use Location instead of LivingEntity. Changed Integration.canLeash(Location, Player) and updated IntegrationManager, all integration implementations (WorldGuard, GriefDefender, GriefPrevention, Lands, Residence, Towny) and callers to pass a Location (e.g. entity.getLocation() or target.getLocation()). Also updated Tether event registration to supply integrationManager to PlayerInteractListener and made various cosmetic adjustments (added final modifiers and small local refactors). No functional behavior changes intended—this decouples integrations from entity objects and centralizes location-based permission checks.
Inject IntegrationManager and perform a canLeash(location, player) check before calling handleFenceLeashing so mobs can't be leashed in protected/claimed areas. Also add a null check for clickedBlock, import Location/Player types, and update the constructor and method params to accept/use the IntegrationManager and final modifiers. Added imports for leash-related exceptions (prepared for future error handling).
Simplify PlayerLeashEntityListener by removing its LeashMobService field and constructor, and register it without arguments in Tether. Mark the PlayerLeashEntityEvent parameter final and keep the event cancellation for LivingEntity. Also remove the unused Tether plugin field from IntegrationManager. These changes reduce coupling and remove unused state without changing runtime behavior.
Replace wildcard listener import with explicit listener class imports for clarity and to avoid broad imports. Move integrationManager.enableIntegrations() from onLoad() into onEnable() so integrations are initialized during plugin enable (after classes are instantiated and config saved).
Move integrationManager.enableIntegrations() from onEnable() to onLoad() so integrations are initialized earlier during plugin load. Update GriefPreventionIntegration to lazy-initialize its DataStore via a new getDataStore() method and replace direct dataStore accesses to avoid null issues. Clean up IntegrationManager imports to explicitly reference toggleable integration classes and remove unused imports.
|
@NaspoDev there is a critical bug where players can steal mobs trapped in fences inside protected areas. |
|
Hi @SrBedrock, thanks for the PR. The core of your changes are good, but I'd like to request some changes to your PR before I test and potentially merge it.
|
When you say "trapped in fences" do you mean the fence leashing feature? If so, I'm assuming it's this PR that also addresses that with the claim checks? If it's something else, please open a separate issue for it (or make another PR if you like). |
Yes, this PR adress the issue. |
|
Okay, well let me know if you're planning on making those changes I requested. Otherwise I'll just go ahead and fix it myself. Thanks! |
Refactor integration permission checks to use Location instead of LivingEntity. Changed Integration.canLeash(Location, Player) and updated IntegrationManager, all integration implementations (WorldGuard, GriefDefender, GriefPrevention, Lands, Residence, Towny) and callers to pass a Location (e.g. entity.getLocation() or target.getLocation()). Also updated Tether event registration to supply integrationManager to PlayerInteractListener and made various cosmetic adjustments (added final modifiers and small local refactors). No functional behavior changes intended—this decouples integrations from entity objects and centralizes location-based permission checks.
Inject IntegrationManager and perform a canLeash(location, player) check before calling handleFenceLeashing so mobs can't be leashed in protected/claimed areas. Also add a null check for clickedBlock, import Location/Player types, and update the constructor and method params to accept/use the IntegrationManager and final modifiers. Added imports for leash-related exceptions (prepared for future error handling).
Update GriefPreventionIntegration to lazy-initialize its DataStore via a new getDataStore() method and replace direct dataStore accesses to avoid null issues. Clean up IntegrationManager imports to explicitly reference toggleable integration classes and remove unused imports.