RuneHive-Game
Loading...
Searching...
No Matches
KeyPacketListener.java
Go to the documentation of this file.
1package com.runehive.net.packet.in;
2
3import com.runehive.game.world.entity.mob.data.PacketType;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.GamePacket;
6import com.runehive.net.packet.PacketListener;
7import com.runehive.net.packet.PacketListenerMeta;
8import org.jire.runehiveps.event.widget.KeyPacketEvent;
9
10/**
11 * The {@code GamePacket} responsible for clicking keyboard buttons.
12 *
13 * @author Daniel | Obey
14 */
16public class KeyPacketListener implements PacketListener {
17
18 @Override
19 public void handlePacket(Player player, GamePacket packet) {
20 final int key = packet.readShort();
21
22 if (key < 0)
23 return;
24 if (player.locking.locked(PacketType.KEY))
25 return;
26
27 player.getEvents().widget(player, new KeyPacketEvent(key));
28 }
29}
boolean locked()
Checks if the mob is locked.
Definition Locking.java:52
This class represents a character controlled by a player.
Definition Player.java:125
Represents a single game packet.
The GamePacket responsible for clicking keyboard buttons.
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.