RuneHive-Game
Loading...
Searching...
No Matches
SendString.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.net.codec.ByteModification;
5import com.runehive.net.packet.OutgoingPacket;
6import com.runehive.net.packet.PacketType;
7
8/**
9 * The {@code OutgoingPacket} that sends a string to a {@code Player}s itemcontainer
10 * in the client.
11 *
12 * @author Daniel | Obey
13 */
14public class SendString extends OutgoingPacket {
15
16 private final Object string;
17 private final int id;
18 private final boolean override;
19
20 public SendString(Object string, int id, boolean override) {
21 super(126, PacketType.VAR_SHORT);
22 this.string = string;
23 this.id = id;
24 this.override = override;
25 }
26
27 public SendString(Object string, int id) {
28 this(string, id, false);
29 }
30
31 @Override
32 public boolean encode(Player player) {
33 if (!override) {
34 if (id != 0 && !player.playerAssistant.checkSendString(String.valueOf(string), id)) {
35 return false;
36 }
37 }
38 builder.writeString(String.valueOf(string)).writeInt(id);
39 return true;
40 }
41
42}
boolean checkSendString(String text, int id)
Checks if the string is already stored in the list.
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
SendString(Object string, int id, boolean override)
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.