-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Chocolate change leaderboard (#1602)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
- Loading branch information
1 parent
dad2c5b
commit ff52872
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package at.hannibal2.skyhanni.features.inventory.chocolatefactory | ||
|
||
import at.hannibal2.skyhanni.utils.ChatUtils | ||
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators | ||
import at.hannibal2.skyhanni.utils.SimpleTimeMark | ||
import at.hannibal2.skyhanni.utils.TimeUtils.format | ||
|
||
object ChocolatePositionChange { | ||
|
||
private val config get() = ChocolateFactoryAPI.config | ||
private val storage get() = ChocolateFactoryAPI.profileStorage?.positionChange | ||
|
||
fun update(position: Int?, leaderboard: String) { | ||
position ?: return | ||
val storage = storage ?: return | ||
val lastTime = storage.lastTime?.let { SimpleTimeMark(it) } | ||
val lastPosition = storage.lastPosition | ||
val lastLeaderboard = storage.lastLeaderboard | ||
|
||
if (lastLeaderboard == leaderboard) return | ||
|
||
lastLeaderboard?.let { lastLb -> | ||
var message = "$lastLb §c-> $leaderboard" | ||
val change = lastPosition - position | ||
val color = if (change > 0) "§a+" else "§c" | ||
message += "\n §7Changed by $color${change.addSeparators()} spots" | ||
|
||
lastTime?.let { | ||
message += " §7in §b${it.passedSince().format(maxUnits = 2)}" | ||
} | ||
if (config.leaderboardChange && lastPosition != -1) { | ||
ChatUtils.chat(" \n §6Chocolate Leaderboard Change: §7(SkyHanni)\n $message\n ", prefix = false) | ||
} | ||
} | ||
|
||
storage.lastTime = SimpleTimeMark.now().toMillis() | ||
storage.lastLeaderboard = leaderboard | ||
storage.lastPosition = position | ||
} | ||
} |