From 1f09616784e2371b8352a23db3f06aff05458d2a Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 8 Mar 2016 18:28:54 +0000 Subject: [PATCH] chat packet listener --- .../src/mineplex/core/vanish/Vanish.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java index c6f51cc64..4369dd96f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/vanish/Vanish.java @@ -17,6 +17,8 @@ import mineplex.core.vanish.commands.VanishCommand; import mineplex.core.vanish.events.PreVanishEvent; import mineplex.core.vanish.repository.VanishClient; import mineplex.core.vanish.repository.VanishRepository; +import mineplex.game.clans.tutorials.Tutorial; +import net.md_5.bungee.api.ChatColor; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; public class Vanish extends MiniClientPlugin @@ -31,8 +33,33 @@ public class Vanish extends MiniClientPlugin _repository = new VanishRepository(this); _clientManager = clientManager; - packetHandler.addPacketHandler(packet -> { + packetHandler.addPacketHandler(info -> { + PacketPlayOutChat packet = (PacketPlayOutChat) info.getPacket(); + if (packet.getPacket() instanceof PacketPlayOutChat) + { + PacketPlayOutChat chat = (PacketPlayOutChat) packet.getPacket(); + + if (chat.b == 1) + { + if (chat.a.a().isEmpty()) + { + return; + } + + if (chat.a.a().get(0).c().equals(ChatColor.stripColor(Tutorial.AllowedMessage))) + { + chat.a.a().remove(0); + } + else if (!chat.a.a().get(0).c().contains(Tutorial.AllowedBypass)) + { + if (isInTutorial(packet.getPlayer())) + { + packet.setCancelled(true); + } + } + } + } }, PacketPlayOutChat.class); }