Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adminprivate events #97

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ makeevrserg.java.ktarget=21
# Project
makeevrserg.project.name=AspeKt
makeevrserg.project.group=ru.astrainteractive.aspekt
makeevrserg.project.version.string=2.29.3
makeevrserg.project.version.string=2.29.4
makeevrserg.project.description=Essentials plugin for EmpireProjekt
makeevrserg.project.developers=makeevrserg|Makeev Roman|[email protected]
makeevrserg.project.url=https://empireprojekt.ru
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ import org.bukkit.entity.Monster
import org.bukkit.entity.Player
import org.bukkit.event.Cancellable
import org.bukkit.event.Event
import org.bukkit.event.EventHandler
import org.bukkit.event.block.Action
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.block.BlockBurnEvent
import org.bukkit.event.block.BlockExplodeEvent
import org.bukkit.event.block.BlockFromToEvent
import org.bukkit.event.block.BlockIgniteEvent
import org.bukkit.event.block.BlockPistonEvent
import org.bukkit.event.block.BlockPistonExtendEvent
import org.bukkit.event.block.BlockPistonRetractEvent
import org.bukkit.event.block.BlockPlaceEvent
import org.bukkit.event.block.BlockSpreadEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.entity.EntityExplodeEvent
import org.bukkit.event.entity.EntitySpawnEvent
import org.bukkit.event.entity.ExplosionPrimeEvent
import org.bukkit.event.hanging.HangingBreakByEntityEvent
Expand Down Expand Up @@ -66,6 +70,7 @@ internal class AdminPrivateEvent(
}
}

@EventHandler
fun blockBreakEvent(e: BlockBreakEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.block.chunk, e.player, "blockBreakEvent"),
Expand All @@ -76,6 +81,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun blockPlaceEvent(e: BlockPlaceEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.block.chunk, e.player, "blockPlaceEvent"),
Expand All @@ -86,6 +92,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun interactEvent(e: PlayerInteractEvent) {
val location = e.interactionPoint ?: e.player.location
if (e.action == Action.LEFT_CLICK_AIR) return
Expand All @@ -99,6 +106,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun itemFrameEvent(e: PlayerItemFrameChangeEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.player.location, e.player, "itemFrameEvent"),
Expand All @@ -109,6 +117,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun breakItemFrameEvent(e: HangingBreakByEntityEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.entity.location, e.entity, "breakItemFrameEvent"),
Expand All @@ -119,6 +128,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun armorStandEvent(e: PlayerArmorStandManipulateEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.player.location, e.player, "armorStandEvent"),
Expand All @@ -129,6 +139,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun armorStandBreakEvent(e: EntityDamageByEntityEvent) {
val armorStand = e.entity as? ArmorStand ?: return
handleDefault(
Expand All @@ -141,6 +152,7 @@ internal class AdminPrivateEvent(
}

// Explosions
@EventHandler
fun onBlockExplode(e: BlockExplodeEvent) {
e.blockList().forEach { block ->
handleDefault(
Expand All @@ -153,7 +165,8 @@ internal class AdminPrivateEvent(
}
}

fun onEntityExplode(e: BlockExplodeEvent) {
@EventHandler
fun onEntityExplode(e: EntityExplodeEvent) {
e.blockList().forEach { block ->
handleDefault(
retractKey = RetractKey.Vararg(block.chunk, "onEntityExplode"),
Expand All @@ -165,6 +178,7 @@ internal class AdminPrivateEvent(
}
}

@EventHandler
fun onPrimeExplosion(e: ExplosionPrimeEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.entity.location.chunk, "onPrimeExplosion"),
Expand All @@ -176,6 +190,7 @@ internal class AdminPrivateEvent(
}

// Placing
@EventHandler
fun onBucketEmptyEvent(e: PlayerBucketEmptyEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.blockClicked.location.chunk, "onBucketEmptyEvent"),
Expand All @@ -186,6 +201,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun onTntLavaPlace(e: BlockPlaceEvent) {
if (!listOf(Material.TNT, Material.LAVA, Material.LAVA_BUCKET).contains(e.blockPlaced.type)) return
handleDefault(
Expand All @@ -197,6 +213,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun onBlockFromTo(e: BlockFromToEvent) {
if (!listOf(Material.LAVA, Material.LAVA_BUCKET).contains(e.block.type)) return
handleDefault(
Expand All @@ -208,6 +225,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun onBlockIgniteEvent(e: BlockIgniteEvent) {
val location = (e.ignitingBlock ?: e.block).location
handleDefault(
Expand All @@ -219,6 +237,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun onBlockBurnEvent(e: BlockBurnEvent) {
val location = (e.ignitingBlock ?: e.block).location
handleDefault(
Expand All @@ -230,6 +249,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun onBlockSpread(e: BlockSpreadEvent) {
if (!listOf(Material.LAVA, Material.FIRE).contains(e.block.type)) return
handleDefault(
Expand All @@ -241,6 +261,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun playerDamageEvent(e: EntityDamageEvent) {
val player = e.entity as? Player ?: return
handleDefault(
Expand All @@ -252,6 +273,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun entitySpawnEvent(e: EntitySpawnEvent) {
if (e.entity !is Monster || e.entity !is Enemy) return
handleDefault(
Expand All @@ -263,6 +285,7 @@ internal class AdminPrivateEvent(
)
}

@EventHandler
fun portalCreateEvent(e: PortalCreateEvent) {
val chunks = e.blocks
.map(BlockState::getLocation)
Expand All @@ -282,7 +305,7 @@ internal class AdminPrivateEvent(
}
}

fun pistonEvent(e: BlockPistonEvent) {
private fun pistonEvent(e: BlockPistonEvent) {
handleDefault(
retractKey = RetractKey.Vararg(e.block.location.chunk, "BlockPistonEvent"),
e = e,
Expand All @@ -291,4 +314,14 @@ internal class AdminPrivateEvent(
flag = ChunkFlag.PLACE
)
}

@EventHandler
fun onBlockPistonExtendEvent(e: BlockPistonExtendEvent) {
pistonEvent(e)
}

@EventHandler
fun onBlockPistonRetractEvent(e: BlockPistonRetractEvent) {
pistonEvent(e)
}
}
Loading