diff --git a/README.md b/README.md
index e8a7c94..8dbd417 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ Maven
gg.flyte
twilight
- 1.0.27
+ 1.0.28
```
@@ -29,14 +29,14 @@ maven {
url "https://repo.flyte.gg/releases"
}
-implementation "gg.flyte:twilight:1.0.27"
+implementation "gg.flyte:twilight:1.0.28"
```
Gradle (Kotlin DSL)
```kotlin
maven("https://repo.flyte.gg/releases")
-implementation("gg.flyte:twilight:1.0.27")
+implementation("gg.flyte:twilight:1.0.28")
```
Certain features of Twilight require configuration, which can be done via the Twilight class. To setup a Twilight class instance, you can use the `twilight` method as shown below:
diff --git a/build.gradle.kts b/build.gradle.kts
index 0885bef..1ec1c5a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -5,7 +5,7 @@ plugins {
}
group = "gg.flyte"
-version = "1.0.27"
+version = "1.0.28"
repositories {
mavenCentral()
diff --git a/src/main/kotlin/gg/flyte/twilight/event/Event.kt b/src/main/kotlin/gg/flyte/twilight/event/Event.kt
index 051fa46..d7a1fa3 100644
--- a/src/main/kotlin/gg/flyte/twilight/event/Event.kt
+++ b/src/main/kotlin/gg/flyte/twilight/event/Event.kt
@@ -51,6 +51,10 @@ open class CustomTwilightListener {
val events = mutableListOf()
val runnables = mutableListOf()
+ /**
+ * Unregisters this custom Twilight listener, removing all registered events and associated runnables.
+ * Any event handlers and scheduled tasks associated with this listener are deactivated.
+ */
fun unregister() {
events.applyForEach { unregister() }
runnables.applyForEach { cancel() }
@@ -117,9 +121,17 @@ open class TwilightEvent(async: Boolean = false) : Event(async), Cancellable {
/**
* List of custom Twilight Event Listeners
*/
-val customEvents = listOf(
+val customEventListeners = mutableSetOf(
GUIListener,
InteractEventListener,
OpEventListener
)
+/**
+ * Disables custom event listeners by unregistering them from the associated events.
+ *
+ * @param events The custom event listeners to disable.
+ */
+fun disableCustomEventListeners(vararg events: CustomTwilightListener) {
+ customEventListeners -= events.toSet().also { it.applyForEach { unregister() } }
+}
diff --git a/src/test/kotlin/gg/flyte/twilight/EventTest.kt b/src/test/kotlin/gg/flyte/twilight/EventTest.kt
index 3e92699..24c5a9c 100644
--- a/src/test/kotlin/gg/flyte/twilight/EventTest.kt
+++ b/src/test/kotlin/gg/flyte/twilight/EventTest.kt
@@ -1,5 +1,7 @@
package gg.flyte.twilight
+import gg.flyte.twilight.event.custom.admin.listener.OpEventListener
+import gg.flyte.twilight.event.disableCustomEventListeners
import gg.flyte.twilight.event.event
import org.bukkit.event.player.PlayerJoinEvent
@@ -10,4 +12,6 @@ fun eventTest() {
}
listener.unregister()
+
+ disableCustomEventListeners(OpEventListener)
}
\ No newline at end of file