RuneHive-Game
Loading...
Searching...
No Matches
SendConfig.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.net.codec.ByteOrder;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.OutgoingPacket;
6
7/**
8 * The {@code OutgoingPacket} responsible for changing settings on a client.
9 *
10 * @author Daniel | Obey
11 */
12public class SendConfig extends OutgoingPacket {
13
14 private final int id;
15 private final int value;
16 private final boolean intValue;
17
18 public SendConfig(int id, int value, boolean intValue) {
19 super(intValue ? 87 : 36, intValue ? 6 : 3);
20 this.id = id;
21 this.value = value;
22 this.intValue = intValue;
23 }
24
25 public SendConfig(int id, int value) {
26 this(id, value, value < Byte.MIN_VALUE || value > Byte.MAX_VALUE);
27 }
28
29 @Override
30 public boolean encode(Player player) {
31 if (value == -1) {
32 return false;
33 }
34 if(intValue) {
35 builder.writeShort(id, ByteOrder.LE).writeInt(value, ByteOrder.ME);
36 } else {
37 builder.writeShort(id, ByteOrder.LE).writeByte(value);
38 }
39
40 return true;
41 }
42
43}
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
SendConfig(int id, int value, boolean intValue)
Represents the order in which bytes are written.
Definition ByteOrder.java:8
LE
Represents Little-endian.
ME
Represents Middle-endian.