Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.comphenix.protocol.PacketType;
- import com.comphenix.protocol.events.ListenerPriority;
- import com.comphenix.protocol.events.PacketAdapter;
- import com.comphenix.protocol.events.PacketEvent;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- /**
- * @author VINETOS on 08/11/2015.
- */
- public class Listener {
- private static boolean on = false;
- public static void listenChatPackets(){
- if(on)return;
- on = true;
- Main.getprotocolManager().addPacketListener(new PacketAdapter(Main.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.CHAT) {
- @Override
- public void onPacketReceiving(PacketEvent e) {
- if(e.getPacketType() == PacketType.Play.Client.CHAT){
- Player p = e.getPlayer();
- String msg = e.getPacket().getStrings().read(0);
- Bukkit.broadcastMessage("§c"+p.getName()+" §7a écrit: "+msg);
- e.setCancelled(true);
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment