RuneHive-Game
Loading...
Searching...
No Matches
SendInputMessage.java
Go to the documentation of this file.
1package com.runehive.net.packet.out;
2import com.runehive.net.packet.OutgoingPacket;
3import com.runehive.net.packet.PacketType;
4import com.runehive.net.codec.ByteModification;
5import com.runehive.game.world.entity.mob.player.Player;
6
7import java.util.Optional;
8import java.util.function.Consumer;
9
10/**
11 * Sends a chatbox input prompt that accepts full text with spaces.
12 * This creates an input field in the chatbox where players can type messages.
13 * Based on 317 protocol inputDialogState system - packet triggers client-side
14 * text input mode that sends back typed string via packet 60.
15 *
16 * @author Daniel
17 * @author Michael
18 * @author AI Port (317 inputDialogState pattern)
19 */
20public class SendInputMessage extends OutgoingPacket {
21
22 private final Consumer<String> action;
23 private final String inputMessage;
24 private final int inputLength;
25
26 public SendInputMessage(String message, int length, Consumer<String> action) {
27 super(187, PacketType.VAR_BYTE);
28 this.action = action;
29 this.inputMessage = message;
30 this.inputLength = length;
31 }
32
33 @Override
34 public boolean encode(Player player) {
35 player.enterInputListener = Optional.of(action);
36 // Packet 187 VAR_BYTE format: writes prompt string
37 // Client should display chatbox input interface and send back via packet 60
38 builder.writeString(inputMessage);
39 return true;
40 }
41
42}
This class represents a character controlled by a player.
Definition Player.java:125
OutgoingPacket(int opcode, int capacity)
SendInputMessage(String message, int length, Consumer< String > action)
Represents a type of packet.
VAR_BYTE
A variable packet where the size is indicated by a byte.