aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt6
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt12
2 files changed, 8 insertions, 10 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt
index 09027ed..c7c8ea6 100644
--- a/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt
+++ b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt
@@ -4,8 +4,7 @@ import com.dulkirfabric.DulkirModFabric
import meteordevelopment.orbit.ICancellable
abstract class CancellableEvent: ICancellable {
- @JvmField
- var cancelled: Boolean = false
+ private var cancelled = false
override fun isCancelled(): Boolean {
return cancelled
@@ -19,7 +18,6 @@ abstract class CancellableEvent: ICancellable {
* Posts a given event to the bus and returns whether the user wishes to cancel it
*/
fun post(): Boolean {
- DulkirModFabric.EVENT_BUS.post(this)
- return cancelled
+ return DulkirModFabric.EVENT_BUS.post(this).isCancelled
}
} \ No newline at end of file
diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt
index 2172c4b..52224ff 100644
--- a/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/chat/AbiPhoneDND.kt
@@ -18,7 +18,7 @@ object AbiPhoneDND {
if (!DulkirConfig.configOptions.abiPhoneDND) return
if (System.currentTimeMillis() - lastRing < 5000) {
if (event.sound.id.path == "block.note_block.pling" && event.sound.volume == 0.69f && event.sound.pitch == 1.6666666f) {
- event.isCancelled = true
+ event.cancel()
}
}
}
@@ -26,11 +26,10 @@ object AbiPhoneDND {
@EventHandler
fun handle(event: ChatReceivedEvent) {
if (!DulkirConfig.configOptions.abiPhoneDND) return
- val unformatted: String = event.message.unformattedString
- println(unformatted)
+ val unformatted = event.message.unformattedString
if (unformatted matches abiPhoneFormat && !unformatted.contains("Elle") && !unformatted.contains("Dean")) {
val matchResult = abiPhoneFormat.find(unformatted)
- event.isCancelled = true
+ event.cancel()
lastRing = System.currentTimeMillis()
if (DulkirConfig.configOptions.abiPhoneCallerID) {
val blocked = if (Math.random() < .001) "Breefing"
@@ -39,8 +38,9 @@ object AbiPhoneDND {
}
}
if (unformatted.startsWith("✆ Ring...") && unformatted.endsWith("[PICK UP]")
- && System.currentTimeMillis() - lastRing < 5000) {
- event.isCancelled = true
+ && System.currentTimeMillis() - lastRing < 5000
+ ) {
+ event.cancel()
}
}
} \ No newline at end of file