Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/0.3' into release/0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mizarc committed Oct 5, 2024
2 parents 9e2c89f + 391fe8b commit e20ffd0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
## [0.3.1]

### Fixed
- Bell duplication when breaking a bell claim with a move item in your inventory.
- Player state unable to be retrieved if the player somehow bypassed the login player state creation.
- Other potential null-based issues based on invalid item, partition, or claim retrievals.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import dev.mizarc.bellclaims.api.ClaimService
import dev.mizarc.bellclaims.api.ClaimWorldService
import dev.mizarc.bellclaims.api.PlayerStateService
import dev.mizarc.bellclaims.domain.partitions.Position3D
import dev.mizarc.bellclaims.utils.getStringMeta
import org.bukkit.Material
import org.bukkit.NamespacedKey
import org.bukkit.block.Block
import org.bukkit.block.BlockFace
import org.bukkit.block.data.Bisected
Expand All @@ -23,6 +26,9 @@ import org.bukkit.event.block.TNTPrimeEvent
import org.bukkit.event.entity.EntityExplodeEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.world.StructureGrowEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType
import java.util.UUID

class ClaimDestructionListener(val claimService: ClaimService,
private val claimWorldService: ClaimWorldService,
Expand Down Expand Up @@ -56,6 +62,24 @@ class ClaimDestructionListener(val claimService: ClaimService,
}

claimService.destroy(claim)

for ((index, item) in event.player.inventory.withIndex()) {
println(item)
if (item == null) continue
val itemMeta = item.itemMeta ?: continue
val claimText = itemMeta.persistentDataContainer.get(
NamespacedKey("bellclaims","claim"), PersistentDataType.STRING) ?: continue
val claimId = UUID.fromString(claimText) ?: continue
if (claimId == claim.id) {
if (index == 40) {
event.player.inventory.setItemInOffHand(ItemStack(Material.AIR))
}
else {
event.player.inventory.remove(item)
}
}
}

event.player.sendActionBar(
Component.text("Claim '${claim.name}' has been destroyed")
.color(TextColor.color(85, 255, 85)))
Expand Down

0 comments on commit e20ffd0

Please # to comment.