Skip to content

Commit

Permalink
fix: arrows stuck in custom block
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Feb 22, 2024
1 parent 6a0b4cf commit 8c17411
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "net.azisaba"
version = "6.9.7"
version = "6.9.8"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.bukkit.World
import org.bukkit.block.data.Directional
import org.bukkit.block.data.type.Leaves
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Entity
import org.bukkit.event.HandlerList
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.ShapedRecipe
Expand Down Expand Up @@ -181,4 +182,7 @@ class CustomBlockManager(val plugin: LifeCore) {
}
}
}

fun isCustomBlockEntity(e: Entity?) =
e is ArmorStand && e.customName == "custom_block" && !e.isVisible && e.isInvulnerable && e.isSmall
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.Sound
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack
import org.bukkit.entity.Arrow
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.Action
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.block.BlockPlaceEvent
import org.bukkit.event.entity.ProjectileHitEvent
import org.bukkit.event.player.PlayerInteractAtEntityEvent
import org.bukkit.event.player.PlayerInteractEntityEvent
import org.bukkit.event.player.PlayerInteractEvent
Expand Down Expand Up @@ -103,6 +105,13 @@ class CustomBlockListener(val plugin: LifeCore) : Listener {
}
}

@EventHandler
fun onProjectileHit(e: ProjectileHitEvent) {
if (e.entity is Arrow && plugin.customBlockManager.isCustomBlockEntity(e.hitEntity)) {
e.entity.remove()
}
}

private fun destroyAt(player: Player, location: Location, callEvent: Boolean = true) {
val state = plugin.customBlockManager.getState(location) ?: return
if (callEvent) {
Expand Down

0 comments on commit 8c17411

Please sign in to comment.