From 1ac0d97ce768d3df660bb28e3ff6f4bf9d9af3b5 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Wed, 28 Oct 2020 17:50:16 +0100 Subject: [PATCH] Packets may now be constructed with string input --- src/main/java/Main/ProtocolMessage.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/Main/ProtocolMessage.java b/src/main/java/Main/ProtocolMessage.java index fca8530..26f7e51 100644 --- a/src/main/java/Main/ProtocolMessage.java +++ b/src/main/java/Main/ProtocolMessage.java @@ -35,6 +35,13 @@ public class ProtocolMessage { System.arraycopy(message, 0, this.raw, 4, message.length); } + public ProtocolMessage(String message) { + this.length = message.length(); + this.message = message.toCharArray(); + + composeRawData(this.length, this.message); + } + public ProtocolMessage(int length, char[] message) { this.length = length; this.message = message;