From 319e82391bfb8822fd75684f17ae28b26c1e3b0c Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:49:40 +0200 Subject: Initial commit --- .../encrox/twitchbot/client/messages/Login.java | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 src/com/encrox/twitchbot/client/messages/Login.java (limited to 'src/com/encrox/twitchbot/client/messages/Login.java') diff --git a/src/com/encrox/twitchbot/client/messages/Login.java b/src/com/encrox/twitchbot/client/messages/Login.java new file mode 100755 index 0000000..b439c99 --- /dev/null +++ b/src/com/encrox/twitchbot/client/messages/Login.java @@ -0,0 +1,49 @@ +package com.encrox.twitchbot.client.messages; + +import java.io.UnsupportedEncodingException; + +import com.encrox.twitchbot.client.Utils; + +public class Login extends Message { + + private byte id = 1; + private String username, password; + + public Login(String username, String password) { + this.username = username; + this.password = password; + } + + public Login() { + username = null; + password = null; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setPassword(String password) { + this.password = password; + } + + public byte getID() { + return id; + } + + public byte[] getData() { + byte[] output = new byte[160]; + try { + byte[] user = Utils.fill(username.getBytes("UTF-8"), 32), pass = Utils.fill(password.getBytes("UTF-8"), 128); + for(int i = 0; i < 32; i++) + output[i] = user[i]; + for(int i = 0; i < 128; i++) + output[32+i] = pass[i]; + return output; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return null; + } + } + +} -- cgit v1.2.1