From 88858a279db0e9c66c1a736362f058d8c936ffa3 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Oct 2023 20:26:51 +0200 Subject: added guild api --- .../java/at/hannibal2/skyhanni/data/GuildAPI.kt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/GuildAPI.kt (limited to 'src/main/java/at/hannibal2/skyhanni/data') 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() + + @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 -- cgit