diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2022-11-01 23:16:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-01 23:16:54 +0100 |
| commit | 797b858e27c5e3c502e35f8fca74ee06f31e04a7 (patch) | |
| tree | 24433270a0978588763878843e77dc10f9945062 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java | |
| parent | e42dd2aa0a2e0a988e820e1ceb13cf2bc30ba987 (diff) | |
| download | notenoughupdates-797b858e27c5e3c502e35f8fca74ee06f31e04a7.tar.gz notenoughupdates-797b858e27c5e3c502e35f8fca74ee06f31e04a7.tar.bz2 notenoughupdates-797b858e27c5e3c502e35f8fca74ee06f31e04a7.zip | |
Prevents wrong coopadd commands (#412)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AntiCoopAdd.java | 18 |
1 files changed, 18 insertions, 0 deletions
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 <name>"); + return true; + } + return false; + } } |
