diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-07 20:26:51 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-07 20:26:51 +0200 |
commit | 88858a279db0e9c66c1a736362f058d8c936ffa3 (patch) | |
tree | cfaca5cfc14ff8d8d681909a8344b88ac3c2fbef /src/main/java | |
parent | 89fad54d7dedfced8b06b88b9e46f93682e22cd2 (diff) | |
download | skyhanni-88858a279db0e9c66c1a736362f058d8c936ffa3.tar.gz skyhanni-88858a279db0e9c66c1a736362f058d8c936ffa3.tar.bz2 skyhanni-88858a279db0e9c66c1a736362f058d8c936ffa3.zip |
added guild api
Diffstat (limited to 'src/main/java')
5 files changed, 53 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index c7ed9b3c6..fd56e2bc0 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.data.GardenComposterUpgradesData import at.hannibal2.skyhanni.data.GardenCropMilestones import at.hannibal2.skyhanni.data.GardenCropUpgrades import at.hannibal2.skyhanni.data.GuiEditManager +import at.hannibal2.skyhanni.data.GuildAPI import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.ItemClickData import at.hannibal2.skyhanni.data.ItemRenderBackground @@ -355,6 +356,7 @@ class SkyHanniMod { loadModule(FarmingContestAPI) loadModule(FriendAPI()) loadModule(PartyAPI()) + loadModule(GuildAPI) loadModule(SlayerAPI) loadModule(PurseAPI()) loadModule(RiftAPI) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index c495eb9fa..a80211e3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -58,6 +58,9 @@ public class Storage { @Expose public long nextAccountUpgradeCompletionTime = -1L; + + @Expose + public List<String> guildMembers = new ArrayList<>(); } public static class ProfileSpecific { diff --git a/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt new file mode 100644 index 000000000..cb8288e52 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt @@ -0,0 +1,41 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.StringUtils.cleanPlayerName +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object GuildAPI { + private var inGuildMessage = false + private val list = mutableListOf<String>() + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith("§6Guild Name: ")) { + inGuildMessage = true + list.clear() + return + } + if (message.startsWith("§eTotal Members: ")) { + inGuildMessage = false + ProfileStorageData.playerSpecific?.guildMembers?.let { + it.clear() + it.addAll(list) + } + list.clear() + return + } + + if (inGuildMessage) { + if (message.contains("●")) { + for (word in message.split("●")) { + list.add(word.cleanPlayerName()) + } + } + } + } + + fun isInGuild(name: String) = ProfileStorageData.playerSpecific?.guildMembers?.let { + name in it + } ?: false +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt index f71e8e961..5dee3ef25 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/compacttablist/AdvancedPlayerList.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.compacttablist import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.FriendAPI +import at.hannibal2.skyhanni.data.GuildAPI import at.hannibal2.skyhanni.data.PartyAPI import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.utils.LorenzUtils @@ -155,18 +156,17 @@ object AdvancedPlayerList { MarkedPlayerManager.isMarkedPlayer(name) -> 8 PartyAPI.partyMembers.contains(name) -> 5 FriendAPI.getAllFriends().any { it.name.contains(name) } -> 4 - // TODO add guild + GuildAPI.isInGuild(name) -> 3 else -> 1 } private fun getSocialScoreIcon(score: Int) = when (score) { - 10 -> "§cTHIS IS ME" - 8 -> "§eMARKED" + 10 -> "§c§lME" + 8 -> "§e§lMARKED" 5 -> "§7§lP" - 4 -> "§9§lF" - 3 -> "§aG" - // TODO add guild + 4 -> "§6§lF" + 3 -> "§2§lG" else -> "" } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index 4b8732c41..a26c0323f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -78,7 +78,7 @@ object StringUtils { matcher(text).let { if (it.matches()) consumer(it) else null } fun String.cleanPlayerName(): String { - val split = split(" ") + val split = trim().split(" ") return if (split.size > 1) { split[1].removeColor() } else { |