Skip to content

Commit

Permalink
Merge pull request #1 from Chissl/main
Browse files Browse the repository at this point in the history
Hoppity Call Support
  • Loading branch information
superhize authored Jul 22, 2024
2 parents a956464 + f052317 commit 43ad2c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/be/hize/afknotifier/config/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ public class MainConfig {
@ConfigOption(name = "Retry", desc = "Number of time you want to retry checking if you are still on skyblock before sending the message.")
@ConfigEditorSlider(minValue = 5, maxValue = 10, minStep = 1)
public int retryValue = 10;

@Expose
@ConfigOption(name = "Hoppity Call Notification", desc = "Will send a message when Hoppity calls.")
@ConfigEditorBoolean
public boolean hoppityCall = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ object ConfigManager {
}

fun saveConfig(reason: String) {
println("saveConfig: $reason")
//println("saveConfig: $reason")
val file = configFile ?: throw Error("Can not save config, configFile is null!")
try {
println("Saving config file")
//println("Saving config file")
file.parentFile.mkdirs()
val unit = file.parentFile.resolve("config.json.write")
unit.createNewFile()
Expand Down
15 changes: 14 additions & 1 deletion src/main/kotlin/be/hize/afknotifier/features/Notifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object Notifier {

private val restartingPattern = "§cServer closing: (?<minutes>\\d+):(?<seconds>\\d+) ?§8.*".toPattern()
private val rebootReasonPattern = "§c\\[Important] §r§eThis server will restart soon: §r§b(?<reason>.*)".toPattern()
private val hoppityCallPattern = "§e✆ §r§aHoppity.*".toPattern()

@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
Expand Down Expand Up @@ -94,6 +95,18 @@ object Notifier {
}
}

@SubscribeEvent
fun onHoppityCall(event: ChatEvent) {
if (!isEnabled()) return
hoppityCallPattern.matchMatcher(event.message) {
logger.log("Detected Hoppity Call")
if (config.hoppityCall) {
DiscordUtil.sendAfkWarning("Hoppity has called %%user%%")
logger.log("Sending Hoppity Call Notification")
}
}
}

@SubscribeEvent
fun onSkyblockJoin(event: SkyblockJoinEvent) {
messageSent = false
Expand Down Expand Up @@ -144,7 +157,7 @@ object Notifier {
if (old == config.islandType) {
if (config.onlyOnLobbyRestart && !lobbyRestarting) return
DiscordUtil.sendAfkWarning(
config.islandLeaveMessage.replace("%%island%%", old.displayName.uppercase())
config.islandLeaveMessage.replace("%%island%%", old.displayName.uppercase()),
)
logger.log("Private island leave message sent.")
islandMessageSent = true
Expand Down

0 comments on commit 43ad2c0

Please sign in to comment.