diff --git a/CHANGELOG.md b/CHANGELOG.md index 150b08b..4925442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve ## [0.3.4] ### Fixed -- No visible inner border visualisation when set to view mode on claims that are donut shaped. +- No visible inner border visualisation when set to view mode on claims that aren't completely filled in. - Using bell while holding an item causing the item to be used, resulting in major issues like trident duplication. +- Claim flags bypassed when an action is being done in one claim that would have an effect in another. ## [0.3.3] diff --git a/build.gradle.kts b/build.gradle.kts index 447e49e..49e0830 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "dev.mizarc" -version = "0.3.3" +version = "0.3.4" repositories { mavenCentral() diff --git a/src/main/kotlin/dev/mizarc/bellclaims/interaction/behaviours/FlagBehaviour.kt b/src/main/kotlin/dev/mizarc/bellclaims/interaction/behaviours/FlagBehaviour.kt index b763dbd..7571b22 100644 --- a/src/main/kotlin/dev/mizarc/bellclaims/interaction/behaviours/FlagBehaviour.kt +++ b/src/main/kotlin/dev/mizarc/bellclaims/interaction/behaviours/FlagBehaviour.kt @@ -14,6 +14,7 @@ import dev.mizarc.bellclaims.api.FlagService import dev.mizarc.bellclaims.api.PartitionService import dev.mizarc.bellclaims.domain.claims.Claim import dev.mizarc.bellclaims.domain.flags.Flag +import dev.mizarc.bellclaims.domain.partitions.Position2D import org.bukkit.Location import org.bukkit.block.BlockState import org.bukkit.block.data.Directional @@ -432,9 +433,10 @@ class RuleBehaviour { private fun getPistonClaims(pistonBlock: Block, blocks: List, direction: BlockFace, claimService: ClaimService, partitionService: PartitionService): List { val claimList = ArrayList() - val checks: ArrayList = ArrayList() - for (c in blocks) { - checks.add(c.getRelative(direction)) + val checks = mutableSetOf() + for (block in blocks) { + checks.add(block) + checks.add(block.getRelative(direction)) } // Check the piston head position @@ -457,8 +459,11 @@ class RuleBehaviour { private fun cancelFluidFlow(event: Event, claimService: ClaimService, partitionService: PartitionService, flagService: FlagService): Boolean { if (event !is BlockFromToEvent) return false - if (partitionService.getByLocation(event.block.location) != null) return false - if (partitionService.getByLocation(event.toBlock.location) == null) return false + val sourceClaim = partitionService.getByLocation(event.block.location)?. + let { claimService.getById(it.claimId) } + val moveClaim = partitionService.getByLocation(event.toBlock.location)?. + let { claimService.getById(it.claimId) } + if (sourceClaim == moveClaim) return false event.isCancelled = true return true } @@ -474,64 +479,62 @@ class RuleBehaviour { private fun cancelPistonRetract(event: Event, claimService: ClaimService, partitionService: PartitionService, flagService: FlagService): Boolean { if (event !is BlockPistonRetractEvent) return false - if (partitionService.getByLocation(event.block.location) != null) return false - var blockInClaim = false + val pistonClaim = partitionService.getByLocation(event.block.location)?. + let { claimService.getById(it.claimId)} + + // Perform checks to see if in claim, and if the claim has piston flag for (block in event.blocks) { - if (partitionService.getByLocation(block.location) != null) blockInClaim = true + val blockClaim = partitionService.getByLocation(block.location)?.let { claimService.getById(it.claimId)} + if (blockClaim == pistonClaim) continue + if (blockClaim != null && !flagService.doesClaimHaveFlag(blockClaim, Flag.Pistons)) { + event.isCancelled = true + return true + } } - if (!blockInClaim) return false - event.isCancelled = true - return true + return false } private fun cancelPistonExtend(event: Event, claimService: ClaimService, partitionService: PartitionService, flagService: FlagService): Boolean { if (event !is BlockPistonExtendEvent) return false - if (partitionService.getByLocation(event.block.location) != null) return false + val affectedLocations = mutableSetOf() val direction = event.direction.direction + val pistonClaim = partitionService.getByLocation(event.block.location)?. + let { claimService.getById(it.claimId)} - // Check the position of the piston head - if (partitionService.getByLocation(event.block.location.add(direction)) != null) { - event.isCancelled = true - return true - } + // Get position of the piston head + affectedLocations.add(event.block.location.add(direction)) - // Check the blocks that the piston is pushinga - var blockInClaim = false + // Get locations of all the blocks the piston will affect for (block in event.blocks) { val newBlockPosition = block.location.clone() newBlockPosition.add(direction) - if (partitionService.getByLocation(block.location) != null || - partitionService.getByLocation(newBlockPosition) != null) blockInClaim = true + affectedLocations.add(newBlockPosition) } - if (!blockInClaim) return false - event.isCancelled = true - return true + // Perform checks to see if in claim, and if the claim has piston flag + for (location in affectedLocations) { + val blockClaim = partitionService.getByLocation(location)?.let { claimService.getById(it.claimId)} + if (blockClaim == pistonClaim) continue + if (blockClaim != null && !flagService.doesClaimHaveFlag(blockClaim, Flag.Pistons)) { + event.isCancelled = true + return true + } + } + return false } private fun cancelTreeGrowth(event: Event, claimService: ClaimService, partitionService: PartitionService, flagService: FlagService): Boolean { if (event !is StructureGrowEvent) return false - if (partitionService.getByLocation(event.location) != null) { - val partition = partitionService.getByLocation(event.location) ?: return false - val claim = claimService.getById(partition.claimId) ?: return false - for (block in event.blocks) { - if (partitionService.getByLocation(block.location) != null) { - val otherPartition = partitionService.getByLocation(block.location) ?: continue - val otherClaim = claimService.getById(otherPartition.claimId) ?: continue - if (claim.id != otherClaim.id) { - partitionService.getByLocation(block.location) ?: continue - event.isCancelled = true - return true - } - } - } - return false - } + val sourceClaim = partitionService.getByLocation(event.location) ?. + let { claimService.getById(it.claimId) } for (block in event.blocks) { - if (partitionService.getByLocation(block.location) != null) { + val growthClaim = partitionService.getByLocation(block.location) ?. + let { claimService.getById(it.claimId) } + if (sourceClaim == growthClaim) continue + if (growthClaim != null && !flagService.doesClaimHaveFlag(growthClaim, Flag.Trees)) { event.isCancelled = true return true } @@ -558,11 +561,7 @@ class RuleBehaviour { val partition = partitionService.getByLocation(event.block.location) val sourcePartition = partitionService.getByLocation(event.source.location) - if (sourcePartition == partition) { - return false - } - - if (sourcePartition == null) { + if (sourcePartition != partition) { event.isCancelled = true return true } @@ -603,12 +602,13 @@ class RuleBehaviour { private fun cancelSpongeAbsorbEvent(event: Event, claimService: ClaimService, partitionService: PartitionService, flagService: FlagService): Boolean { if (event !is SpongeAbsorbEvent) return false - if (partitionService.getByLocation(event.block.location) != null) return false + val spongeClaim = partitionService.getByLocation(event.block.location)?.let { claimService.getById(it.claimId) } val cancelledBlocks: MutableList = mutableListOf() for (block in event.blocks) { val partition = partitionService.getByLocation(block.location) ?: continue val claim = claimService.getById(partition.claimId) ?: continue - if (!flagService.doesClaimHaveFlag(claim, Flag.Explosions)) { + if (spongeClaim == claim) continue + if (!flagService.doesClaimHaveFlag(claim, Flag.Sponge)) { cancelledBlocks.add(block) } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d1ab40b..f0a14be 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: BellClaims -version: 0.3.3 +version: 0.3.4 api-version: '1.21' main: dev.mizarc.bellclaims.BellClaims softdepend: [Vault] \ No newline at end of file