Skip to content

Use Location for integration canLeash checks and enforce claim checks for fence leashing#12

Open
SrBedrock wants to merge 5 commits intoNaspoDev:mainfrom
ArmaRealms:main
Open

Use Location for integration canLeash checks and enforce claim checks for fence leashing#12
SrBedrock wants to merge 5 commits intoNaspoDev:mainfrom
ArmaRealms:main

Conversation

@SrBedrock
Copy link
Copy Markdown

@SrBedrock SrBedrock commented Apr 3, 2026

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.

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.
@SrBedrock
Copy link
Copy Markdown
Author

@NaspoDev there is a critical bug where players can steal mobs trapped in fences inside protected areas.

@NaspoDev
Copy link
Copy Markdown
Owner

NaspoDev commented Apr 6, 2026

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.

  1. Your comment changes to Integration.canLeash() denote that this can only be used for mobs, when it is in fact also used for players, hence the use of LivingEntity before. Please change the wording to "target" instead of "mob".
  2. The IntegrationManager.canLeash() check for fence leashing should happen in LeashMobService.handleFenceLeashing(), like all the other related checks. Not in PlayerInteractListener.
  3. Undo your changes of using explicit imports instead of broad imports. Everywhere that broad imports are used is for a good reason. For example, IntegrationManager will always need all integrations.
  4. Your excessive use of final makes things harder to read and is just not really necessary. It especially makes it harder to review this PR, so please undo all excessive uses of the final keyword.

@NaspoDev
Copy link
Copy Markdown
Owner

NaspoDev commented Apr 6, 2026

@NaspoDev there is a critical bug where players can steal mobs trapped in fences inside protected areas.

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).

@SrBedrock
Copy link
Copy Markdown
Author

@NaspoDev there is a critical bug where players can steal mobs trapped in fences inside protected areas.

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.

@NaspoDev
Copy link
Copy Markdown
Owner

NaspoDev commented Apr 7, 2026

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!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants