Skip to content

Commit

Permalink
gộp 2 event join
Browse files Browse the repository at this point in the history
  • Loading branch information
amadeusmz committed Jul 7, 2024
1 parent 776f9af commit 6c9a536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 6 additions & 10 deletions dotman-plugin/src/main/java/net/minevn/dotman/DotMan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ class DotMan : MineVNPlugin(), Listener {
fun onQuit(e: PlayerQuitEvent) = updateUUID(e.player)

@EventHandler
fun onJoin(e: PlayerJoinEvent) = UpdateChecker.sendUpdateMessage(e.player)
fun onJoin(e: PlayerJoinEvent) {
val player = e.player

milestonesMaster.onJoin(player)
UpdateChecker.sendUpdateMessage(player)
}
// endregion

/**
Expand Down Expand Up @@ -166,15 +171,6 @@ class DotMan : MineVNPlugin(), Listener {
}
}

@EventHandler
fun onPlayerJoin(e: PlayerJoinEvent) {
val player = e.player
val milestones = milestonesMaster.getAll()
milestones.forEach {
it.bar?.addPlayer(player)
}
}

companion object {
lateinit var instance: DotMan private set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.minevn.dotman.config.Milestones.Component
import net.minevn.dotman.utils.Utils.Companion.info
import net.minevn.dotman.utils.Utils.Companion.warning
import net.minevn.libs.bukkit.color
import org.bukkit.entity.Player

class MilestonesMaster : FileConfig("mocnaptong") {
private var components: List<Component> = emptyList()
Expand Down Expand Up @@ -55,6 +56,12 @@ class MilestonesMaster : FileConfig("mocnaptong") {

fun getAll() = components.toList()

fun onJoin(player: Player) {
components.forEach {
it.bar?.addPlayer(player)
}
}

fun removeBossBars() {
getAll().forEach {
it.barTask?.cancel()
Expand Down

0 comments on commit 6c9a536

Please sign in to comment.