From 2bf22f46c48e4161163d2788980d767d2b4d247d Mon Sep 17 00:00:00 2001 From: tobias Date: Thu, 5 Dec 2024 21:12:41 +0100 Subject: [PATCH] Added projectile protection --- .../listeners/claim/ClaimProjectileListener.kt | 15 +++++++++++++++ .../listeners/claim/ClaimProtectionListener.kt | 1 + improved-factions/src/main/resources/config.yml | 6 ++++++ improved-factions/version.properties | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProjectileListener.kt diff --git a/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProjectileListener.kt b/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProjectileListener.kt new file mode 100644 index 00000000..97f078f4 --- /dev/null +++ b/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProjectileListener.kt @@ -0,0 +1,15 @@ +package io.github.toberocat.improvedfactions.listeners.claim + +import org.bukkit.entity.Player +import org.bukkit.event.EventHandler +import org.bukkit.event.entity.ProjectileHitEvent + +class ClaimProjectileListener(zoneType: String) : ProtectionListener(zoneType) { + override fun namespace() = "projectiles" + + @EventHandler + fun onProjectileHit(event: ProjectileHitEvent) { + val player = event.entity.shooter as? Player ?: return + protectChunk(event, event.entity, player) + } +} \ No newline at end of file diff --git a/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProtectionListener.kt b/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProtectionListener.kt index d616a401..21ec74a7 100644 --- a/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProtectionListener.kt +++ b/improved-factions/src/main/kotlin/io/github/toberocat/improvedfactions/listeners/claim/ClaimProtectionListener.kt @@ -26,6 +26,7 @@ class ClaimProtectionListener( register(ClaimEntityBreakHangingListener(zoneType)) register(ClaimEntitySpawnedByEggListener(zoneType)) register(ClaimArmorStandManipulateListener(zoneType)) + register(ClaimProjectileListener(zoneType)) register(ClaimVehicleBreakListener(zoneType)) register(ClaimTntListener(zoneType)) diff --git a/improved-factions/src/main/resources/config.yml b/improved-factions/src/main/resources/config.yml index 9f4c2a39..1bcf2485 100644 --- a/improved-factions/src/main/resources/config.yml +++ b/improved-factions/src/main/resources/config.yml @@ -301,6 +301,7 @@ zones: # Other protections minecart-damage: true # Prevent minecarts being destroyed in a claim + projectiles: true # Prevent projectiles from damaging entities in a claim safezone: announce-title: true # True will allow this zone to send titles to the player - Faction claims and no faction claims allow-claiming: false # Set to true will allow factions to claim their chunks in these regions @@ -341,6 +342,8 @@ zones: entity-interaction: true # Prevent interacting with entities in a claim entity-break-hanging: true # Prevent breaking hanging entities (like paintings or itemframes) in a claim entity-place: true # Prevent placing entities in a claim + projectiles: true # Prevent projectiles from damaging entities in a claim + warzone: announce-title: true # True will allow this zone to send titles to the player - Faction claims and no faction claims allow-claiming: false # Set to true will allow factions to claim their chunks in these regions @@ -383,6 +386,8 @@ zones: entity-interaction: true # Prevent interacting with entities in a claim entity-break-hanging: true # Prevent breaking hanging entities (like paintings or itemframes) in a claim entity-place: false # Prevent placing entities in a claim + projectiles: true # Prevent projectiles from damaging entities in a claim + unmanaged: announce-title: false # True will allow this zone to send titles to the player - Faction claims and no faction claims allow-claiming: false # Set to true will allow factions to claim their chunks in these regions @@ -424,6 +429,7 @@ zones: entity-interaction: false # Prevent interacting with entities in a claim entity-break-hanging: false # Prevent breaking hanging entities (like paintings or itemframes) in a claim entity-place: false # Prevent placing entities in a claim + projectiles: false # Prevent projectiles from damaging entities in a claim performance: thread-pool-size: 5 # Amount of thread that should be pooled waiting for operations diff --git a/improved-factions/version.properties b/improved-factions/version.properties index ca627e2e..81f3e4c0 100644 --- a/improved-factions/version.properties +++ b/improved-factions/version.properties @@ -1,3 +1,3 @@ -#Thu Dec 05 21:04:31 CET 2024 -buildIncrement=29 +#Thu Dec 05 21:10:14 CET 2024 +buildIncrement=30 versionName=2.3.0