RuneHive-Game
Loading...
Searching...
No Matches
CommandPacketListener.java
Go to the documentation of this file.
1package com.runehive.net.packet.in;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.entity.mob.player.relations.ChatMessage;
5import com.runehive.net.packet.ClientPackets;
6import com.runehive.net.packet.GamePacket;
7import com.runehive.net.packet.PacketListener;
8import com.runehive.net.packet.PacketListenerMeta;
9
10/**
11 * The {@code GamePacket} responsible for handling user commands send from the
12 * client.
13 *
14 * @author Michael | Chex
15 */
17public final class CommandPacketListener implements PacketListener {
18
19 @Override
20 public void handlePacket(Player player, GamePacket packet) {
21 final String input = packet.getRS2String().trim().toLowerCase();
22 if (input.isEmpty() || input.length() > ChatMessage.CHARACTER_LIMIT) {
23 return;
24 }
25
26 player.getEvents().widget(player, new org.jire.runehiveps.event.widget.CommandEvent(input));
27 }
28
29}
This class represents a character controlled by a player.
Definition Player.java:125
Represents a chat message that can be displayed over an entities head.
static final int CHARACTER_LIMIT
When a chat message decoded there's a character buffer that can only hold 100 characters.
Client -> Server packet opcodes.
Represents a single game packet.
The GamePacket responsible for handling user commands send from the client.
void handlePacket(Player player, GamePacket packet)
Handles the packet that has just been received.
An annotation that describes what client -> server packets a PacketListener can listen to.