chat packet listener
This commit is contained in:
parent
26b7ea2d59
commit
1f09616784
@ -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<VanishClient>
|
||||
@ -31,8 +33,33 @@ public class Vanish extends MiniClientPlugin<VanishClient>
|
||||
_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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user