RuneHive-Game
Loading...
Searching...
No Matches
SendMarquee.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.net.packet.OutgoingPacket;
6import com.runehive.net.packet.PacketType;
7
8public class SendMarquee extends OutgoingPacket {
9
10 private final String[] strings;
11 private final int id;
12
13 public SendMarquee(int id, String... strings) {
14 super(205, PacketType.VAR_SHORT);
15 this.strings = strings;
16 this.id = id;
17 }
18
19 @Override
20 public boolean encode(Player player) {
21 builder.writeInt(id);
22 for (int index = 0; index < 5; index++) {
23 builder.writeString(index >= strings.length
24 ? ""
25 : strings[index].replace("#players", World.getPlayerCount() + ""));
26 }
27 return true;
28 }
29}
Represents the game world.
Definition World.java:46
static int getPlayerCount()
Gets the amount of valid players online.
Definition World.java:490
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
SendMarquee(int id, String... strings)
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.