aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-06-21 07:39:24 +1000
committerGitHub <noreply@github.com>2024-06-20 23:39:24 +0200
commitd534f73b63578d384c7a69462ca18cf0883926f5 (patch)
tree80e21e1f0ec41c5dee47712c5d2144281afeb0e7 /src/main/java/at/hannibal2/skyhanni/data
parent6410dcf999a08d4b6625fdc25f2db148c9df8338 (diff)
downloadskyhanni-d534f73b63578d384c7a69462ca18cf0883926f5.tar.gz
skyhanni-d534f73b63578d384c7a69462ca18cf0883926f5.tar.bz2
skyhanni-d534f73b63578d384c7a69462ca18cf0883926f5.zip
Backend: Remove deprecated function ChatUtils.error (#2021)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt48
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt59
2 files changed, 60 insertions, 47 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index fdd4d23d2..7599cc80f 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -318,33 +318,20 @@ object HypixelData {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
if (!LorenzUtils.inSkyBlock) {
- // Modified from NEU.
- // NEU does not send locraw when not in SkyBlock.
- // So, as requested by Hannibal, use locraw from
- // NEU and have NEU send it.
- // Remove this when NEU dependency is removed
- if (LorenzUtils.onHypixel && locrawData == null && lastLocRaw.passedSince() > 15.seconds) {
- lastLocRaw = SimpleTimeMark.now()
- thread(start = true) {
- Thread.sleep(1000)
- NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw")
- }
- }
+ checkNEULocraw()
}
- if (LorenzUtils.onHypixel) {
- if (LorenzUtils.inSkyBlock) {
- loop@ for (line in ScoreboardData.sidebarLinesFormatted) {
- skyblockAreaPattern.matchMatcher(line) {
- val originalLocation = group("area")
- skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation
- skyBlockAreaWithSymbol = line.trim()
- break@loop
- }
+ if (LorenzUtils.onHypixel && LorenzUtils.inSkyBlock) {
+ loop@ for (line in ScoreboardData.sidebarLinesFormatted) {
+ skyblockAreaPattern.matchMatcher(line) {
+ val originalLocation = group("area")
+ skyBlockArea = LocationFixData.fixLocation(skyBlockIsland) ?: originalLocation
+ skyBlockAreaWithSymbol = line.trim()
+ break@loop
}
-
- checkProfileName()
}
+
+ checkProfileName()
}
if (!LorenzUtils.onHypixel) {
@@ -368,6 +355,21 @@ object HypixelData {
skyBlock = inSkyBlock
}
+ // Modified from NEU.
+ // NEU does not send locraw when not in SkyBlock.
+ // So, as requested by Hannibal, use locraw from
+ // NEU and have NEU send it.
+ // Remove this when NEU dependency is removed
+ private fun checkNEULocraw() {
+ if (LorenzUtils.onHypixel && locrawData == null && lastLocRaw.passedSince() > 15.seconds) {
+ lastLocRaw = SimpleTimeMark.now()
+ thread(start = true) {
+ Thread.sleep(1000)
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw")
+ }
+ }
+ }
+
@SubscribeEvent
fun onTabListUpdate(event: WidgetUpdateEvent) {
when (event.widget) {
diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
index 358b00c9c..2080a1354 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt
@@ -8,8 +8,12 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.chat.Text
+import at.hannibal2.skyhanni.utils.chat.Text.asComponent
+import at.hannibal2.skyhanni.utils.chat.Text.send
import com.google.gson.JsonObject
import net.minecraft.client.Minecraft
+import net.minecraft.util.IChatComponent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import org.apache.commons.io.FileUtils
import java.io.BufferedReader
@@ -98,15 +102,16 @@ class RepoManager(private val configLocation: File) {
}
if (latestRepoCommit == null || latestRepoCommit!!.isEmpty()) return@supplyAsync false
val file = File(configLocation, "repo")
- if (file.exists() && currentCommitJSON != null && currentCommitJSON["sha"].asString == latestRepoCommit
+ if (file.exists() &&
+ currentCommitJSON?.get("sha")?.asString == latestRepoCommit &&
+ unsuccessfulConstants.isEmpty() &&
+ lastRepoUpdate.passedSince() < 1.minutes
) {
- if (unsuccessfulConstants.isEmpty() && lastRepoUpdate.passedSince() < 1.minutes) {
- if (command) {
- ChatUtils.chat("§7The repo is already up to date!")
- atomicShouldManuallyReload.set(false)
- }
- return@supplyAsync false
+ if (command) {
+ ChatUtils.chat("§7The repo is already up to date!")
+ atomicShouldManuallyReload.set(false)
}
+ return@supplyAsync false
}
lastRepoUpdate = SimpleTimeMark.now()
RepoUtils.recursiveDelete(repoLocation)
@@ -125,7 +130,7 @@ class RepoManager(private val configLocation: File) {
urlConnection.getInputStream().use { `is` ->
FileUtils.copyInputStreamToFile(
`is`,
- itemsZip
+ itemsZip,
)
}
} catch (e: IOException) {
@@ -139,7 +144,7 @@ class RepoManager(private val configLocation: File) {
}
RepoUtils.unzipIgnoreFirstFolder(
itemsZip.absolutePath,
- repoLocation.absolutePath
+ repoLocation.absolutePath,
)
if (currentCommitJSON == null || currentCommitJSON["sha"].asString != latestRepoCommit) {
val newCurrentCommitJSON = JsonObject()
@@ -187,7 +192,7 @@ class RepoManager(private val configLocation: File) {
onClick = {
SkyHanniMod.repo.updateRepo()
},
- prefixColor = "§c"
+ prefixColor = "§c",
)
if (unsuccessfulConstants.isEmpty()) {
unsuccessfulConstants.add("All Constants")
@@ -224,15 +229,19 @@ class RepoManager(private val configLocation: File) {
fun displayRepoStatus(joinEvent: Boolean) {
if (joinEvent) {
if (unsuccessfulConstants.isNotEmpty()) {
- ChatUtils.error(
- "§7Repo Issue! Some features may not work. Please report this error on the Discord!\n"
- + "§7Repo Auto Update Value: §c${config.repoAutoUpdate}\n"
- + "§7If you have Repo Auto Update turned off, please try turning that on.\n"
- + "§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):"
+ val text = mutableListOf<IChatComponent>()
+ text.add(
+ ("§c[SkyHanni-${SkyHanniMod.version}] §7Repo Issue! Some features may not work. " +
+ "Please report this error on the Discord!").asComponent(),
)
+ text.add("§7Repo Auto Update Value: §c${config.repoAutoUpdate}".asComponent())
+ text.add("§7If you have Repo Auto Update turned off, please try turning that on.".asComponent())
+ text.add("§cUnsuccessful Constants §7(${unsuccessfulConstants.size}):".asComponent())
+
for (constant in unsuccessfulConstants) {
- ChatUtils.chat(" §e- §7$constant")
+ text.add(" §e- §7$constant".asComponent())
}
+ Text.multiline(text).send()
}
return
}
@@ -243,7 +252,7 @@ class RepoManager(private val configLocation: File) {
ChatUtils.chat("Repo has errors! Commit has: ${latestRepoCommit ?: "null"}", prefixColor = "§c")
if (successfulConstants.isNotEmpty()) ChatUtils.chat(
"Successful Constants §7(${successfulConstants.size}):",
- prefixColor = "§a"
+ prefixColor = "§a",
)
for (constant in successfulConstants) {
ChatUtils.chat(" §a- §7$constant", false)
@@ -262,8 +271,8 @@ class RepoManager(private val configLocation: File) {
BufferedReader(
InputStreamReader(
FileInputStream(file),
- StandardCharsets.UTF_8
- )
+ StandardCharsets.UTF_8,
+ ),
).use { reader ->
return gson.fromJson(reader, JsonObject::class.java)
}
@@ -291,8 +300,8 @@ class RepoManager(private val configLocation: File) {
BufferedWriter(
OutputStreamWriter(
FileOutputStream(file),
- StandardCharsets.UTF_8
- )
+ StandardCharsets.UTF_8,
+ ),
).use { writer -> writer.write(gson.toJson(json)) }
}
@@ -318,11 +327,13 @@ class RepoManager(private val configLocation: File) {
name = defaultName
branch = defaultBranch
if (manual) {
- ChatUtils.clickableChat("Reset Repo settings to default. " +
- "Click §aUpdate Repo Now §ein config or run /shupdaterepo to update!",
+ ChatUtils.clickableChat(
+ "Reset Repo settings to default. " +
+ "Click §aUpdate Repo Now §ein config or run /shupdaterepo to update!",
onClick = {
updateRepo()
- })
+ },
+ )
}
}
}