Skip to content

Commit

Permalink
Move region events into their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Jan 13, 2025
1 parent 8bc40da commit c293862
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion
import com.sk89q.worldguard.session.MoveType
import com.sk89q.worldguard.session.Session
import com.sk89q.worldguard.session.handler.Handler
import com.typewritermc.worldguard.events.RegionsEnterEvent
import com.typewritermc.worldguard.events.RegionsExitEvent
import lirand.api.extensions.server.server
import org.bukkit.entity.Player
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
import org.bukkit.event.player.PlayerEvent

class WorldGuardHandler(session: Session?) : Handler(session) {

Expand Down Expand Up @@ -42,32 +40,4 @@ class WorldGuardHandler(session: Session?) : Handler(session) {

return super.onCrossBoundary(player, from, to, toSet, entered, exited, moveType)
}
}

class RegionsEnterEvent(player: Player, val regions: Set<ProtectedRegion>) : PlayerEvent(player) {
operator fun contains(regionName: String) = regions.any { it.id == regionName }

override fun getHandlers(): HandlerList = HANDLER_LIST

companion object {
@JvmStatic
val HANDLER_LIST = HandlerList()

@JvmStatic
fun getHandlerList(): HandlerList = HANDLER_LIST
}
}

class RegionsExitEvent(player: Player, val regions: Set<ProtectedRegion>) : PlayerEvent(player) {
operator fun contains(regionName: String) = regions.any { it.id == regionName }

override fun getHandlers(): HandlerList = HANDLER_LIST

companion object {
@JvmStatic
val HANDLER_LIST = HandlerList()

@JvmStatic
fun getHandlerList(): HandlerList = HANDLER_LIST
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import com.typewritermc.engine.paper.entry.entries.AudienceEntry
import com.typewritermc.engine.paper.entry.entries.AudienceFilter
import com.typewritermc.engine.paper.entry.entries.AudienceFilterEntry
import com.typewritermc.engine.paper.entry.entries.Invertible
import com.typewritermc.worldguard.RegionsEnterEvent
import com.typewritermc.worldguard.RegionsExitEvent
import com.typewritermc.worldguard.events.RegionsEnterEvent
import com.typewritermc.worldguard.events.RegionsExitEvent
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import com.typewritermc.core.interaction.context
import com.typewritermc.engine.paper.entry.TriggerableEntry
import com.typewritermc.engine.paper.entry.entries.EventEntry
import com.typewritermc.engine.paper.entry.triggerAllFor
import com.typewritermc.worldguard.RegionsEnterEvent
import lirand.api.extensions.server.server
import com.typewritermc.worldguard.events.RegionsEnterEvent

@Entry("on_enter_region", "When a player enters a WorldGuard region", Colors.YELLOW, "fa6-solid:door-open")
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import com.typewritermc.core.interaction.context
import com.typewritermc.engine.paper.entry.TriggerableEntry
import com.typewritermc.engine.paper.entry.entries.EventEntry
import com.typewritermc.engine.paper.entry.triggerAllFor
import com.typewritermc.worldguard.RegionsExitEvent
import lirand.api.extensions.server.server
import com.typewritermc.worldguard.events.RegionsExitEvent

@Entry("on_exit_region", "When a player exits a WorldGuard region", Colors.YELLOW, "fa6-solid:door-closed")
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.typewritermc.worldguard
package com.typewritermc.worldguard.events

import com.sk89q.worldguard.protection.regions.ProtectedRegion
import org.bukkit.entity.Player
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.typewritermc.worldguard
package com.typewritermc.worldguard.events

import com.sk89q.worldguard.protection.regions.ProtectedRegion
import org.bukkit.entity.Player
Expand Down

0 comments on commit c293862

Please sign in to comment.