|
| 1 | +package com.dark.zewo2.modules; |
| 2 | + |
| 3 | +import com.dark.zewo2.Addon; |
| 4 | +import meteordevelopment.meteorclient.systems.modules.Category; |
| 5 | +import meteordevelopment.meteorclient.systems.modules.Module; |
| 6 | +import com.google.common.collect.Multimap; |
| 7 | +import com.google.common.collect.MultimapBuilder; |
| 8 | +import net.minecraft.client.MinecraftClient; |
| 9 | +import net.minecraft.entity.player.PlayerEntity; |
| 10 | +import net.minecraft.text.Text; |
| 11 | + |
| 12 | +import java.nio.ByteBuffer; |
| 13 | +import java.util.*; |
| 14 | + |
| 15 | + |
| 16 | +public class Girlboss extends Module { |
| 17 | + public Girlboss() { |
| 18 | + super(Addon.CATEGORY, "Girlboss", "Notifies you when someone receives a private message."); |
| 19 | + } |
| 20 | + |
| 21 | + private static final Multimap<ByteBuffer, UUID> signatures = MultimapBuilder.hashKeys().hashSetValues().build(); |
| 22 | + private static final Set<ByteBuffer> seen = new HashSet<>(); |
| 23 | + private static final Set<String> alertsSent = new HashSet<>(); |
| 24 | + private static int alertsClearedTick = -1; |
| 25 | + private static boolean hasSentFirstAlert = false; |
| 26 | + |
| 27 | + public static void receivedMessage(final ByteBuffer signature) { |
| 28 | + seen.add(signature); |
| 29 | + } |
| 30 | + |
| 31 | + public static void addSeenSignature(final UUID sender, final ByteBuffer signature) { |
| 32 | + if (seen.contains(signature) || signatures.containsEntry(signature, sender)) { |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + signatures.put(signature, sender); |
| 37 | + if (MinecraftClient.getInstance().world == null) { |
| 38 | + return; |
| 39 | + } |
| 40 | + |
| 41 | + final Collection<UUID> uuids = signatures.get(signature); |
| 42 | + final List<String> names = new ArrayList<>(); |
| 43 | + for (final UUID uuid : uuids) { |
| 44 | + final PlayerEntity playerEntity = MinecraftClient.getInstance().world.getPlayerByUuid(uuid); |
| 45 | + if (playerEntity != null) { |
| 46 | + names.add(playerEntity.getName().getString()); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + final int last = names.size() - 1; |
| 51 | + final String joinedNames = String.join(" and ", String.join(", ", names.subList(0, last)), names.get(last)); |
| 52 | + final String verb = names.size() > 1 ? "have" : "has"; |
| 53 | + |
| 54 | + final String message = "§a[Girlboss] §7" + (names.size() == 1 ? names.get(0) : joinedNames) + " " + verb + " seen a message you haven't!"; |
| 55 | + if (MinecraftClient.getInstance().player.age != alertsClearedTick) { |
| 56 | + alertsClearedTick = MinecraftClient.getInstance().player.age; |
| 57 | + alertsSent.clear(); |
| 58 | + } |
| 59 | + if (alertsSent.add(message) && hasSentFirstAlert) { |
| 60 | + MinecraftClient.getInstance().player.sendMessage(Text.literal(message)); |
| 61 | + } |
| 62 | + hasSentFirstAlert = true; |
| 63 | + } |
| 64 | + |
| 65 | +} |
0 commit comments