Skip to content

Commit

Permalink
fix(custom-events): call events sync, remove useless online check for…
Browse files Browse the repository at this point in the history
… player? call
  • Loading branch information
joshbker committed Nov 5, 2023
1 parent fe1ec23 commit f382c61
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maven
<dependency>
<groupId>gg.flyte</groupId>
<artifactId>twilight</artifactId>
<version>1.0.26</version>
<version>1.0.27</version>
</dependency>
```

Expand All @@ -29,14 +29,14 @@ maven {
url "https://repo.flyte.gg/releases"
}
implementation "gg.flyte:twilight:1.0.26"
implementation "gg.flyte:twilight:1.0.27"
```

Gradle (Kotlin DSL)
```kotlin
maven("https://repo.flyte.gg/releases")

implementation("gg.flyte:twilight:1.0.26")
implementation("gg.flyte:twilight:1.0.27")
```

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:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "gg.flyte"
version = "1.0.26"
version = "1.0.27"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class PlayerDeopEvent(
* Represents the online player associated with this event, if available.
* This property will be null if the player is not currently online.
*/
val player: Player? = if (offlinePlayer.isOnline) offlinePlayer.player else null
val player: Player? = offlinePlayer.player
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class PlayerOpChangeEvent(
* Represents the online player associated with this event, if available.
* This property will be null if the player is not currently online.
*/
val player: Player? = if (offlinePlayer.isOnline) offlinePlayer.player else null
val player: Player? = offlinePlayer.player
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class PlayerOpEvent(
* Represents the online player associated with this event, if available.
* This property will be null if the player is not currently online.
*/
val player: Player? = if (offlinePlayer.isOnline) offlinePlayer.player else null
val player: Player? = offlinePlayer.player
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import gg.flyte.twilight.event.custom.admin.PlayerOpEvent
import gg.flyte.twilight.extension.applyForEach
import gg.flyte.twilight.gson.GSON
import gg.flyte.twilight.scheduler.repeat
import gg.flyte.twilight.scheduler.sync
import java.io.File
import java.util.*

object OpEventListener : CustomTwilightListener() {

private val opsFile = File("${Twilight.plugin.dataFolder}/../../ops.json")
private var opsData = mutableSetOf<OpData>()
private var opsLastChanged: Long? = null
Expand All @@ -31,15 +33,19 @@ object OpEventListener : CustomTwilightListener() {
// Removed ops
opsData.subtract(newOpsData).toSet().applyForEach {
opsData -= this
Twilight.plugin.server.pluginManager.callEvent(PlayerDeopEvent(uuid, name))
Twilight.plugin.server.pluginManager.callEvent(PlayerOpChangeEvent(uuid, name))
sync {
Twilight.plugin.server.pluginManager.callEvent(PlayerDeopEvent(uuid, name))
Twilight.plugin.server.pluginManager.callEvent(PlayerOpChangeEvent(uuid, name))
}
}

// Added ops
newOpsData.subtract(opsData).toSet().applyForEach {
opsData += this
Twilight.plugin.server.pluginManager.callEvent(PlayerOpEvent(uuid, name))
Twilight.plugin.server.pluginManager.callEvent(PlayerOpChangeEvent(uuid, name))
sync {
Twilight.plugin.server.pluginManager.callEvent(PlayerOpEvent(uuid, name))
Twilight.plugin.server.pluginManager.callEvent(PlayerOpChangeEvent(uuid, name))
}
}
}
}
Expand Down

0 comments on commit f382c61

Please sign in to comment.