RuneHive-Game
Loading...
Searching...
No Matches
PacketSizeParser.java
Go to the documentation of this file.
1package com.runehive.util.parser.impl;
2
3import com.google.gson.JsonObject;
4import com.runehive.net.packet.PacketRepository;
5import com.runehive.util.parser.GsonParser;
6
7/**
8 * Parses through the packet sizes file and associates their opcode with a size.
9 *
10 * @author SeVen
11 */
12public final class PacketSizeParser extends GsonParser {
13
14 /**
15 * Creates a new {@code PacketSizeParser}.
16 */
18 super("io/message_sizes", false);
19 }
20
21 @Override
22 protected void parse(JsonObject data) {
23 final int opcode = data.get("opcode").getAsInt();
24 final int size = data.get("size").getAsInt();
25 PacketRepository.registerType(opcode, size);
26 }
27
28}
The repository that stores packets sizes and listeners for how to execute the packets.
static void registerType(int opcode, int type)
Registers a type for a packet.
GsonParser(String path)
Creates a new GsonParser.
void parse(JsonObject data)
The method allows a user to modify the data as its being parsed.
PacketSizeParser()
Creates a new PacketSizeParser.