1package com.runehive.net.packet;
3import com.google.common.base.Preconditions;
4import com.runehive.game.world.entity.mob.player.Player;
5import org.apache.logging.log4j.LogManager;
6import org.apache.logging.log4j.Logger;
8import javax.annotation.Nullable;
36 if (listener !=
null) {
37 if (
packet.getOpcode() != 0) {
51 Preconditions.checkArgument(opcode >= 0 && opcode <
packetListeners.length);
85 }
else if (size == -1) {
87 }
else if (size > 0) {
121 Preconditions.checkArgument(opcode >= 0 && opcode <
packetListeners.length);
This class represents a character controlled by a player.
Represents a single game packet.
The repository that stores packets sizes and listeners for how to execute the packets.
static void registerListener(int opcode, PacketListener listener)
Registers a listener to listen for client -> server packet events.
static final int MAX_CLIENT_PACKETS
The number of client packets known.
static void sendToListener(Player player, GamePacket packet)
static void registerType(int opcode, int type)
Registers a type for a packet.
static PacketListener lookupListener(final int opcode)
Looks up the listener for this packet.
static final int[] packetTypes
The array that holds packet types.
static final Logger logger
static PacketType lookupType(int opcode)
The method that looks up the packets type.
static final PacketListener[] packetListeners
The client -> server packet listeners.
static int lookupSize(int opcode)
Looks up the reference size of a packet.
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.
FIXED
A fixed size packet where the size never changes.
VAR_BYTE
A variable packet where the size is indicated by a byte.
void handlePacket(Player player, GamePacket packet)
Handles the packet that has just been received.