From 797b858e27c5e3c502e35f8fca74ee06f31e04a7 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Tue, 1 Nov 2022 23:16:54 +0100 Subject: Prevents wrong coopadd commands (#412) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../notenoughupdates/miscfeatures/AntiCoopAdd.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java index 70ac4489..aaa13d39 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java @@ -27,12 +27,19 @@ import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C01PacketChatMessage; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class AntiCoopAdd { + private static final AntiCoopAdd INSTANCE = new AntiCoopAdd(); + + public static AntiCoopAdd getInstance() { + return INSTANCE; + } + @SubscribeEvent public void onMouseClick(SlotClickEvent event) { if (!NotEnoughUpdates.INSTANCE.config.misc.coopWarning) return; @@ -59,4 +66,15 @@ public class AntiCoopAdd { event.setCanceled(true); } } + + public Boolean onPacketChatMessage(C01PacketChatMessage packet) { + if (!NotEnoughUpdates.INSTANCE.config.misc.coopWarning) return false; + + String message = packet.getMessage().toLowerCase(); + if (message.startsWith("/hypixelcommand:coopadd")) { + Utils.addChatMessage("§e[NEU] You just entered a malicious looking Co-op add command! If you truly want to add someone to your coop, type §e/coopadd "); + return true; + } + return false; + } } -- cgit