aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-24 10:13:09 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-24 10:13:09 +0100
commitc394d46f9c73e8283df127b8c9d9f8edfb6d0c52 (patch)
treebfcaf13d3eb913089c1345dcafe45feec5a49713 /src
parent374b56662212253f844c963c353167064fb2f592 (diff)
downloadskyhanni-c394d46f9c73e8283df127b8c9d9f8edfb6d0c52.tar.gz
skyhanni-c394d46f9c73e8283df127b8c9d9f8edfb6d0c52.tar.bz2
skyhanni-c394d46f9c73e8283df127b8c9d9f8edfb6d0c52.zip
code cleanup
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt53
1 files changed, 22 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
index 77eb27799..cf0da4b6c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt
@@ -44,45 +44,37 @@ class LimboPlaytime {
@SubscribeEvent
fun replaceItem(event: ReplaceItemEvent) {
if (event.inventory !is ContainerLocalMenu) return
- if (event.inventory.displayName.unformattedText != "Detailed /playtime") return
+ if (event.inventory.name != "Detailed /playtime") return
if (event.slotNumber != 43) return
val playtime = storage?.playtime ?: 0
if (playtime < 60) return
if (lastCreateCooldown.passedSince() > 3.seconds) {
lastCreateCooldown = SimpleTimeMark.now()
- limboItem = when {
- wholeMinutes >= 60 -> {
- Utils.createItemStack(
- itemID.getItemStack().item,
- itemName,
- "§7Playtime: §a${wholeMinutes.addSeparators()} minutes",
- "§7Or: §b$hoursString hours"
- )
- }
- wholeMinutes == 1 -> {
- Utils.createItemStack(
- itemID.getItemStack().item,
- itemName,
- "§7Playtime: §a$wholeMinutes minute"
- )
- }
- else -> {
- Utils.createItemStack(
- itemID.getItemStack().item,
- itemName,
- "§7Playtime: §a$wholeMinutes minutes"
- )
- }
- }
+ limboItem = Utils.createItemStack(
+ itemID.getItemStack().item,
+ itemName,
+ *createItemLore()
+ )
}
event.replaceWith(limboItem)
}
+ private fun createItemLore(): Array<String> = when {
+ wholeMinutes >= 60 -> arrayOf(
+ "§7Playtime: §a${wholeMinutes.addSeparators()} minutes",
+ "§7Or: §b$hoursString hours"
+ )
+
+ wholeMinutes == 1 -> arrayOf("§7Playtime: §a$wholeMinutes minute")
+
+ else -> arrayOf("§7Playtime: §a$wholeMinutes minutes")
+ }
+
@SubscribeEvent
fun onHoverItem(event: LorenzToolTipEvent) {
if (!LorenzUtils.inSkyBlock) return
- if (!event.slot.inventory.displayName.unformattedText.startsWith("Detailed /playtime")) return
+ if (!event.slot.inventory.name.startsWith("Detailed /playtime")) return
if (event.slot.slotIndex != 4) return
val playtime = storage?.playtime ?: 0
if (playtime <= 120) return
@@ -98,9 +90,8 @@ class LimboPlaytime {
@SubscribeEvent
fun onRenderGUI(event: InventoryOpenEvent) {
if (event.inventoryName != "Detailed /playtime") return
- val storedPlaytime = storage?.playtime ?: 0
- if (storedPlaytime < 60) return
- val playtime = storedPlaytime.seconds
+ val playtime = (storage?.playtime ?: 0).seconds
+ if (playtime < 60.seconds) return
val wholeHours = playtime.inWholeHours
wholeMinutes = playtime.inWholeMinutes.toInt()
if ((wholeMinutes % 60) == 0) {
@@ -144,7 +135,7 @@ class LimboPlaytime {
private fun remakeList(
toolTip: MutableList<String>,
minutesList: MutableList<String>,
- hoursList: MutableList<String>
+ hoursList: MutableList<String>,
) {
val firstLine = toolTip.first()
val totalPlaytime = toolTip.last()
@@ -163,6 +154,6 @@ class LimboPlaytime {
private fun findFloatDecimalPlace(input: Float): Int {
val string = input.toString()
val dotIndex = string.indexOf(".")
- return (string[dotIndex+1].toString().toInt())
+ return (string[dotIndex + 1].toString().toInt())
}
}