Archived
0

Chat message

This commit is contained in:
2018-04-30 12:16:22 +03:00
parent 80a351adfd
commit 9a346c2081
6 changed files with 54 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2018-04-30
*/
package mc.core.network.proto_125.packets;
import lombok.*;
import mc.core.network.CSPacket;
import mc.core.network.NetStream;
import mc.core.network.SCPacket;
import mc.core.network.proto_125.ByteArrayOutputNetStream;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class ChatMessagePacket implements SCPacket, CSPacket {
private String message;
@Override
public void readSelf(NetStream netStream) {
message = netStream.readString();
}
@Override
public byte[] toByteArray() {
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
netStream.writeString(message);
return netStream.toByteArray();
}
}

View File

@@ -8,13 +8,13 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import mc.core.network.CSPacket;
import mc.core.network.SCPacket;
import mc.core.network.proto_125.packets.*;
public class PacketManager {
private static final BiMap<Integer, Class<?>> packetMap = ImmutableBiMap.<Integer, Class<?>>builder()
.put(0x00, KeepAlivePacket.class)
.put(0x01, LoginPacket.class)
.put(0x02, HandshakePacket.class)
.put(0x03, ChatMessagePacket.class)
.put(0x04, TimeUpdatePacket.class)
.put(0x06, SpawnPositionPacket.class)
.put(0x0B, PlayerPositionPacket.class)