Skip to content

Commit

Permalink
add bungee and destroy logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Motzkiste committed Sep 6, 2022
1 parent 96f070e commit f362c16
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.eratiem.uptimekumapush.bungee

import net.eratiem.eralogger.tools.EraLogger
import net.eratiem.uptimekumapush.tools.ConfigManager
import net.eratiem.uptimekumapush.tools.Tools
import net.md_5.bungee.api.plugin.Plugin
import net.md_5.bungee.api.scheduler.ScheduledTask
import org.slf4j.Logger
import java.util.concurrent.TimeUnit.SECONDS

class UptimeKumaPushPlugin : Plugin() {
private lateinit var task: ScheduledTask
private lateinit var logger: EraLogger

override fun onEnable() {
try {
ConfigManager(this.dataFolder)
logger = EraLogger.getInstance("UptimeKumaPush", getLogger() as Logger)
} catch (e: Exception) {
logger.warning("Failed to load config! Please check your config.yml\n${e.stackTraceToString()}")
this.onDisable()
return
}

task = proxy.scheduler.schedule(
this, Tools.pushToKuma(logger), 0, 60L, SECONDS
)

logger.info("UptimeKumaPush up and running!")
}

override fun onDisable() {
if (::task.isInitialized)
task.cancel()
logger.info("UptimeKumaPush disabled")
EraLogger.destroyInstance("UptimeKumaPush")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ class UptimeKumaPushPlugin : JavaPlugin() {
task.cancel()
}
logger.info("UptimeKumaPush disabled")
EraLogger.destroyInstance(name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ class UptimeKumaPushPlugin @Inject constructor(
task?.cancel()

logger.info("UptimeKumaPushVelocity is disabled")
EraLogger.destroyInstance("UptimeKumaPush")
}
}

0 comments on commit f362c16

Please sign in to comment.