aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-11 03:46:54 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-11 03:46:54 +0200
commit6991c7375d35706b63f8d4347df72696cbdde860 (patch)
treed5a29fe2f7b1950bc9d70bc1123aaacfd15ef05a /src/main/java
parentf5bd9e61c3e70079ba08c0dd78db22f402023571 (diff)
downloadskyhanni-6991c7375d35706b63f8d4347df72696cbdde860.tar.gz
skyhanni-6991c7375d35706b63f8d4347df72696cbdde860.tar.bz2
skyhanni-6991c7375d35706b63f8d4347df72696cbdde860.zip
Added support for custom hypixel ip addresses (looking at ilovecatgirls.xyz)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt9
8 files changed, 45 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index cab37ecc0..d1f8d3317 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.events.IslandChangeEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.utils.LorenzLogger
+import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import net.minecraft.client.Minecraft
@@ -15,7 +16,8 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent
class HypixelData {
companion object {
- var hypixel = false
+ var hypixelLive = false
+ var hypixelAlpha = false
var skyBlock = false
var skyBlockIsland = IslandType.UNKNOWN
@@ -38,13 +40,13 @@ class HypixelData {
private var loggerIslandChange = LorenzLogger("debug/island_change")
- @SubscribeEvent
- fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
- hypixel = Minecraft.getMinecraft().runCatching {
- !event.isLocal && (thePlayer?.clientBrand?.lowercase()?.contains("hypixel")
- ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel") ?: false)
- }.onFailure { it.printStackTrace() }.getOrDefault(false)
- }
+// @SubscribeEvent
+// fun onConnect(event: FMLNetworkEvent.ClientConnectedToServerEvent) {
+// hypixel = Minecraft.getMinecraft().runCatching {
+// !event.isLocal && (thePlayer?.clientBrand?.lowercase()?.contains("hypixel")
+// ?: currentServerData?.serverIP?.lowercase()?.contains("hypixel") ?: false)
+// }.onFailure { it.printStackTrace() }.getOrDefault(false)
+// }
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
@@ -53,13 +55,14 @@ class HypixelData {
@SubscribeEvent
fun onDisconnect(event: FMLNetworkEvent.ClientDisconnectionFromServerEvent) {
- hypixel = false
+ hypixelLive = false
+ hypixelAlpha = false
skyBlock = false
}
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!hypixel) return
+ if (!LorenzUtils.isHypixel) return
val message = event.message.removeColor().lowercase()
if (message.startsWith("your profile was changed to:")) {
@@ -79,13 +82,15 @@ class HypixelData {
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
- if (!hypixel) return
if (event.phase != TickEvent.Phase.START) return
tick++
-
if (tick % 5 != 0) return
+ checkHypixel()
+
+ if (!LorenzUtils.isHypixel) return
+
val inSkyBlock = checkScoreboard()
if (inSkyBlock) {
checkIsland()
@@ -96,6 +101,21 @@ class HypixelData {
skyBlock = inSkyBlock
}
+ private fun checkHypixel() {
+ val list = ScoreboardData.sidebarLinesFormatted
+ if (list.isEmpty()) return
+
+ val last = list.last()
+ hypixelLive = last == "§ewww.hypixel.net"
+ hypixelAlpha = last == "§ealpha.hypixel.net"
+
+ println("")
+ println("hypixelLive: $hypixelLive")
+ println("hypixelAlpha: $hypixelAlpha")
+ println("last: '$last'")
+
+ }
+
private fun checkSidebar() {
ironman = false
stranded = false
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
index e5494c328..7a746299e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
@@ -11,7 +11,7 @@ class ChatFilter {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.isHyPixel) return
+ if (!LorenzUtils.isHypixel) return
val blockReason = block(event.message)
if (blockReason != "") {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt
index 9bd5149cc..4f45cdde4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonChatFilter.kt
@@ -10,7 +10,7 @@ class DungeonChatFilter {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.isHyPixel) return
+ if (!LorenzUtils.isHypixel) return
// Workaround since the potion message gets always sent in that moment when skyblock is set as false
if (!LorenzUtils.inSkyBlock && !event.message.startsWith("§aYour active Potion Effects")) return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt
index c28119857..508927613 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ButtonOnPause.kt
@@ -13,7 +13,7 @@ class ButtonOnPause {
@SubscribeEvent
fun onGuiAction(event: GuiScreenEvent.ActionPerformedEvent.Post) {
- if (!LorenzUtils.isHyPixel) return
+ if (!LorenzUtils.isHypixel) return
if (SkyHanniMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu && event.button.id == buttonId) {
ConfigGuiManager.openConfigGui()
@@ -22,7 +22,7 @@ class ButtonOnPause {
@SubscribeEvent
fun onGuiInitPost(event: GuiScreenEvent.InitGuiEvent.Post) {
- if (!LorenzUtils.isHyPixel) return
+ if (!LorenzUtils.isHypixel) return
if (SkyHanniMod.feature.misc.configButtonOnPause && event.gui is GuiIngameMenu) {
val x = event.gui.width - 105
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
index e2572cb0e..648b051bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PasteIntoSigns.kt
@@ -1,7 +1,6 @@
package at.hannibal2.skyhanni.features.misc
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.OSUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -12,7 +11,7 @@ class PasteIntoSigns {
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
- if (!HypixelData.hypixel) return
+ if (!LorenzUtils.isHypixel) return
if (!SkyHanniMod.feature.misc.pasteIntoSigns) return
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_V)) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
index 7b3a5a667..511c43aab 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt
@@ -37,7 +37,7 @@ class SummoningMobManager {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.isHyPixel) return
+ if (!LorenzUtils.isHypixel) return
val message = event.message
val matcher = spawnPatter.matcher(message)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
index 77fc27298..1f03ed837 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt
@@ -81,6 +81,6 @@ object APIUtil {
fun toggleApiErrorMessages() {
showApiErrors = !showApiErrors
- LorenzUtils.chat("§e[SkyHanni] HyPixel API error messages " + if (showApiErrors) "§chidden" else "§ashown")
+ LorenzUtils.chat("§e[SkyHanni] Hypixel API error messages " + if (showApiErrors) "§chidden" else "§ashown")
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index a856ae481..b44e9e52e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -22,11 +22,14 @@ import java.util.*
object LorenzUtils {
- val isHyPixel: Boolean
- get() = HypixelData.hypixel && Minecraft.getMinecraft().thePlayer != null
+ val isHypixel: Boolean
+ get() = (HypixelData.hypixelLive || HypixelData.hypixelAlpha) && Minecraft.getMinecraft().thePlayer != null
+
+ val isOnAlphaServer: Boolean
+ get() = isHypixel && HypixelData.hypixelAlpha
val inSkyBlock: Boolean
- get() = isHyPixel && HypixelData.skyBlock
+ get() = isHypixel && HypixelData.skyBlock
val inDungeons: Boolean
get() = inSkyBlock && DungeonData.inDungeon()