RuneHive-Game
Loading...
Searching...
No Matches
SendInputAmount.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2
3import com.runehive.net.packet.OutgoingPacket;
4import com.runehive.net.packet.PacketType;
5import com.runehive.net.codec.ByteModification;
6import com.runehive.game.world.entity.mob.player.Player;
7
8import java.util.Optional;
9import java.util.function.Consumer;
10
11/**
12 * Sends an input dialogue.
13 *
14 * @author Daniel
15 * @author Michael
16 */
17public class SendInputAmount extends OutgoingPacket {
18
19 private final Consumer<String> action;
20 private final String inputMessage;
21 private final int inputLength;
22
23 public SendInputAmount(Consumer<String> action) {
24 this("Enter an amount:", 10, action);
25 }
26
27 public SendInputAmount(String message, int length, Consumer<String> action) {
28 super(27, PacketType.VAR_SHORT);
29 this.action = action;
30 this.inputMessage = message;
31 this.inputLength = length;
32 }
33
34 @Override
35 public boolean encode(Player player) {
36 player.enterInputListener = Optional.of(action);
37 builder.writeString(inputMessage)
38 .writeShort(inputLength, ByteModification.ADD);
39 return true;
40 }
41
42}
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
SendInputAmount(String message, int length, Consumer< String > action)
Represents RuneScape's custom value types.
ADD
Adds 128 to the value when written, subtracts 128 from the rarity when read.
Represents a type of packet.
VAR_SHORT
A variable packet where the size is indicated by a short.