RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ChatMessagePacketListener.java
1package com.osroyale.net.packet.in;
2
3import com.osroyale.game.world.entity.mob.data.PacketType;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.mob.player.relations.ChatColor;
6import com.osroyale.game.world.entity.mob.player.relations.ChatEffect;
7import com.osroyale.net.codec.ByteModification;
8import com.osroyale.net.packet.ClientPackets;
9import com.osroyale.net.packet.GamePacket;
10import com.osroyale.net.packet.PacketListener;
11import com.osroyale.net.packet.PacketListenerMeta;
12import com.osroyale.net.packet.out.SendMessage;
13import org.jire.tarnishps.event.widget.ChatMessageEvent;
14
15
43
45
46 @Override
47 public void handlePacket(Player player, GamePacket packet) {
48 final int effect = packet.readByte(false, ByteModification.SUB);
49 final int color = packet.readByte(false, ByteModification.SUB);
50 final int size = packet.getSize() - 2;
51
52 if (effect < 0 || effect >= ChatEffect.values.length || color < 0 || color >= ChatColor.values.length || size <= 0) {
53 return;
54 }
55
56 if (player.locking.locked(PacketType.CHAT)) {
57 return;
58 }
59
60 player.idle = false;
61
62 if (player.punishment.isMuted()) {
63 player.send(new SendMessage("You are currently muted and can not talk!"));
64 return;
65 }
66
67 final byte[] bytes = packet.readBytesReverse(size, ByteModification.ADD);
68 player.getEvents().widget(player, new ChatMessageEvent(effect, color, size, bytes));
69 }
70
71}