diff options
Diffstat (limited to 'src/main/java/at')
8 files changed, 138 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 9c705c8a9..ab6629ed4 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -48,6 +48,7 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new HypixelData()); MinecraftForge.EVENT_BUS.register(new DungeonData()); MinecraftForge.EVENT_BUS.register(new ScoreboardData()); + MinecraftForge.EVENT_BUS.register(new ApiData()); MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper()); MinecraftForge.EVENT_BUS.register(new ChatFilter()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index f65d575f4..46bbe3482 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -48,6 +48,9 @@ public class Features { } @Expose + public String apiKey = ""; + + @Expose @Category(name = "Chat", desc = "Chat related features.") public Chat chat = new Chat(); diff --git a/src/main/java/at/hannibal2/skyhanni/events/ProfileApiDataLoadedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ProfileApiDataLoadedEvent.kt new file mode 100644 index 000000000..12640898f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/ProfileApiDataLoadedEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import com.google.gson.JsonObject + +class ProfileApiDataLoadedEvent(val profileData: JsonObject) : LorenzEvent()
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/ProfileJoinEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ProfileJoinEvent.kt new file mode 100644 index 000000000..ebf1e7b6d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/ProfileJoinEvent.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.events + +class ProfileJoinEvent(val name: String): LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index dd533b3d2..421a73140 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -171,7 +171,10 @@ class HideNotClickableItems { return true } - if (stack.cleanName().endsWith(" Bait")) return false + if (stack.getLore().any { it.removeColorCodes() == "Fishing Bait" }) { + return false + } +// if (stack.cleanName().endsWith(" Bait")) return false hideReason = "This item is not a fishing bait!" return true @@ -201,8 +204,8 @@ class HideNotClickableItems { private fun hideTrade(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("You ")) return false - if (ItemUtils.isCoOpSoulBound(stack)) { - hideReason = "Coop-Soulbound items cannot be traded!" + if (ItemUtils.isSoulBound(stack)) { + hideReason = "Soulbound items cannot be traded!" return true } @@ -262,6 +265,7 @@ class HideNotClickableItems { "Lever" -> return false "Fairy's Galoshes" -> return false + "Blaze Powder" -> return false } if (name.endsWith("Gem Rune I")) return false @@ -347,8 +351,13 @@ class HideNotClickableItems { items.add("Zombie Commander Whip") items.add("Sniper Bow") + //Crimson essence + items.add("Blade of the Volcano") + items.add("Slug Boots") + items.add("Flaming Chestplate") + for (item in items) { - if (name.endsWith(" $item")) { + if (name.endsWith(item)) { return false } } @@ -391,8 +400,8 @@ class HideNotClickableItems { } private fun isNotAuctionable(stack: ItemStack): Boolean { - if (ItemUtils.isCoOpSoulBound(stack)) { - hideReason = "Coop-Soulbound items cannot be auctioned!" + if (ItemUtils.isSoulBound(stack)) { + hideReason = "Soulbound items cannot be auctioned!" return true } diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ApiData.kt b/src/main/java/at/hannibal2/skyhanni/misc/ApiData.kt new file mode 100644 index 000000000..5cbedd164 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/misc/ApiData.kt @@ -0,0 +1,90 @@ +package at.hannibal2.skyhanni.misc + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ApiData { + + private var currentProfileName = "" + + @SubscribeEvent + fun onStatusBar(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith("§aYour new API key is §r§b")) { + SkyHanniMod.feature.apiKey = message.substring(26) + LorenzUtils.chat("§b[SkyHanni] A new API Key has been detected and installed") + + if (currentProfileName != "") { + updateApiData() + } + } + } + + @SubscribeEvent + fun onStatusBar(event: ProfileJoinEvent) { + currentProfileName = event.name + updateApiData() + } + + private fun updateApiData() { + val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toString().replace("-", "") + + val apiKey = SkyHanniMod.feature.apiKey + + if (apiKey.isEmpty()) { + LorenzUtils.error("SkyHanni has no API Key set. Type /api new to reload.") + return + } + + val url = "https://api.hypixel.net/player?key=$apiKey&uuid=$uuid" + + val jsonObject = APIUtil.getJSONResponse(url) + + if (!jsonObject["success"].asBoolean) { + val cause = jsonObject["cause"].asString + if (cause == "Invalid API key") { + LorenzUtils.error("SkyHanni got an API error: Invalid API key! Type /api new to reload.") + return + } else { + throw RuntimeException("API error for url '$url': $cause") + } + } + + val player = jsonObject["player"].asJsonObject + val stats = player["stats"].asJsonObject + val skyblock = stats["SkyBlock"].asJsonObject + val profiles = skyblock["profiles"].asJsonObject + for (entry in profiles.entrySet()) { + val asJsonObject = entry.value.asJsonObject + val name = asJsonObject["cute_name"].asString + val profileId = asJsonObject["profile_id"].asString + if (currentProfileName == name.lowercase()) { + loadProfile(uuid, profileId) + return + } + } + } + + private fun loadProfile(playerUuid: String, profileId: String) { + val apiKey = SkyHanniMod.feature.apiKey + val url = "https://api.hypixel.net/skyblock/profile?key=$apiKey&profile=$profileId" + + val jsonObject = APIUtil.getJSONResponse(url) + + val profile = jsonObject["profile"].asJsonObject + val members = profile["members"].asJsonObject + for (entry in members.entrySet()) { + if (entry.key == playerUuid) { + val profileData = entry.value.asJsonObject + ProfileApiDataLoadedEvent(profileData).postAndCatch() + + } + } + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt index 29fa2a242..89db5edaf 100644 --- a/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.misc +import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S38PacketPlayerListItem import net.minecraft.network.play.server.S3DPacketDisplayScoreboard @@ -60,4 +63,21 @@ class HypixelData { skyblock = false dungeon = false } + + @SubscribeEvent + fun onStatusBar(event: LorenzChatEvent) { + if (!hypixel) return + + val message = event.message.removeColorCodes().lowercase() + + if (message.startsWith("your profile was changed to:")) { + val stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim(); + ProfileJoinEvent(stripped).postAndCatch() + } + if (message.startsWith("you are playing on profile:")) { + val stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim(); + ProfileJoinEvent(stripped).postAndCatch() + + } + } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index b077c4121..243cbc1dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -31,7 +31,7 @@ object ItemUtils { fun ItemStack.getLore() = ItemUtil.getItemLore(this) - fun isCoOpSoulBound(stack: ItemStack): Boolean = stack.getLore().any { it.contains("Co-op Soulbound") } + fun isSoulBound(stack: ItemStack): Boolean = stack.getLore().any { it.contains(" Soulbound ") } fun isRecombobulated(stack: ItemStack): Boolean = stack.getLore().any { it.contains("§k") } |