diff --git a/pom.xml b/pom.xml index 9727aba3d..7099fc629 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 proxy - 0.3.2 + 0.3.3 DragonProxy org.dragonet.proxy diff --git a/screenshots/form-login.jpg b/screenshots/form-login.jpg new file mode 100644 index 000000000..43f0a8b99 Binary files /dev/null and b/screenshots/form-login.jpg differ diff --git a/src/main/java/org/dragonet/proxy/configuration/Lang.java b/src/main/java/org/dragonet/proxy/configuration/Lang.java index 27e3b6c8d..aa39218d7 100644 --- a/src/main/java/org/dragonet/proxy/configuration/Lang.java +++ b/src/main/java/org/dragonet/proxy/configuration/Lang.java @@ -29,11 +29,18 @@ public class Lang extends PropertiesConfig { public static final String ERROR_CLS_UNREACHABLE = "error_cls_unreachable"; public static final String ERROR_CLS_ERROR = "error_cls_error"; public static final String ERROR_CLS_LOGIN = "error_cls_login"; - public static final String MESSAGE_ONLINE_NOTICE = "message_online_notice"; - public static final String MESSAGE_ONLINE_EMAIL = "message_online_email"; + //public static final String MESSAGE_ONLINE_NOTICE = "message_online_notice"; + //public static final String MESSAGE_ONLINE_EMAIL = "message_online_email"; + public static final String MESSAGE_LOGIN_PROMPT = "message_login_prompt"; + public static final String MESSAGE_LOGIN_PROGRESS = "message_login_progress"; + public static final String FORM_LOGIN_TITLE = "form_login_title"; + public static final String FORM_LOGIN_DESC = "form_login_desc"; + public static final String FORM_LOGIN_PROMPT = "form_login_prompt"; + public static final String FORM_LOGIN_USERNAME = "form_login_username"; + public static final String FORM_LOGIN_PASSWORD = "form_login_password"; public static final String MESSAGE_ONLINE_ERROR = "message_online_error"; public static final String MESSAGE_ONLINE_PASSWORD = "message_online_password"; - public static final String MESSAGE_ONLINE_LOGGIN_IN = "message_online_logging_in"; + public static final String MESSAGE_ONLINE_LOGGING_IN = "message_online_logging_in"; public static final String MESSAGE_ONLINE_LOGIN_SUCCESS = "message_online_login_success"; public static final String MESSAGE_ONLINE_LOGIN_SUCCESS_CONSOLE = "message_online_login_success_console"; public static final String MESSAGE_TELEPORT_TO_SPAWN = "message_teleport_to_spawn"; diff --git a/src/main/java/org/dragonet/proxy/gui/InputComponent.java b/src/main/java/org/dragonet/proxy/gui/InputComponent.java new file mode 100644 index 000000000..4ffdb82cf --- /dev/null +++ b/src/main/java/org/dragonet/proxy/gui/InputComponent.java @@ -0,0 +1,37 @@ +package org.dragonet.proxy.gui; + +import org.json.JSONObject; + +/** + * Created on 2017/12/26. + */ +public class InputComponent extends BaseModalFormComponent { + + private String text; + + private String defaultValue; + + private String placeholder; + + public InputComponent(String text) { + super("input"); + this.text = text; + } + + public InputComponent setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + return this; + } + + public InputComponent setPlaceholder(String placeholder) { + this.placeholder = placeholder; + return this; + } + + @Override + public void serializeData(JSONObject out) { + out.put("text", text); + if(defaultValue != null) out.put("default", defaultValue); + if(placeholder != null) out.put("placeholder", placeholder); + } +} diff --git a/src/main/java/org/dragonet/proxy/network/CacheKey.java b/src/main/java/org/dragonet/proxy/network/CacheKey.java index 103d40130..2f2d2c56b 100644 --- a/src/main/java/org/dragonet/proxy/network/CacheKey.java +++ b/src/main/java/org/dragonet/proxy/network/CacheKey.java @@ -23,9 +23,6 @@ public final class CacheKey { public static final String AUTHENTICATION_STATE = "auth_state"; public static final String WINDOW_OPENED_ID = "window_opened_id"; - // Strings - public static final String AUTHENTICATION_EMAIL = "auth_mail"; - // Positions public static final String BLOCK_BREAKING_POSITION = "block_breaking_position"; public static final String WINDOW_BLOCK_POSITION = "window_block_position"; diff --git a/src/main/java/org/dragonet/proxy/network/PEPacketProcessor.java b/src/main/java/org/dragonet/proxy/network/PEPacketProcessor.java index 707142f18..bcac69d5d 100644 --- a/src/main/java/org/dragonet/proxy/network/PEPacketProcessor.java +++ b/src/main/java/org/dragonet/proxy/network/PEPacketProcessor.java @@ -17,12 +17,15 @@ import java.util.Deque; import com.github.steveice10.packetlib.packet.Packet; +import org.dragonet.proxy.configuration.Lang; +import org.dragonet.proxy.gui.CustomFormComponent; +import org.dragonet.proxy.gui.InputComponent; +import org.dragonet.proxy.gui.LabelComponent; import org.dragonet.proxy.protocol.PEPacket; import org.dragonet.proxy.protocol.Protocol; import org.dragonet.proxy.protocol.ProtocolInfo; -import org.dragonet.proxy.protocol.packets.ChunkRadiusUpdatedPacket; -import org.dragonet.proxy.protocol.packets.LoginPacket; -import org.dragonet.proxy.protocol.packets.RequestChunkRadiusPacket; +import org.dragonet.proxy.protocol.packets.*; +import org.json.JSONArray; public class PEPacketProcessor implements Runnable { @@ -70,6 +73,8 @@ public void handlePacket(PEPacket packet) { return; } + System.out.println(" < { try { - protocol = new MinecraftProtocol((String) dataCache.get(CacheKey.AUTHENTICATION_EMAIL), password, - false); + protocol = new MinecraftProtocol(email, password, false); } catch (RequestException ex) { if (ex.getMessage().toLowerCase().contains("invalid")) { sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_LOGIN_FAILD)); @@ -347,14 +346,13 @@ public void postLogin() { sendPacket(new FullChunkDataPacket(-1, 0, data.getBuffer())); sendPacket(new FullChunkDataPacket(-1, -1, data.getBuffer())); + dataCache.put(CacheKey.AUTHENTICATION_STATE, "online_login_wait"); + PlayStatusPacket pkStat = new PlayStatusPacket(); pkStat.status = PlayStatusPacket.PLAYER_SPAWN; sendPacket(pkStat, true); - dataCache.put(CacheKey.AUTHENTICATION_STATE, "email"); - - sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_NOTICE, username)); - sendChat(proxy.getLang().get(Lang.MESSAGE_ONLINE_EMAIL)); + sendChat(proxy.getLang().get(Lang.MESSAGE_LOGIN_PROMPT)); } else if (proxy.getAuthMode().equals("cls")) { // CLS LOGIN! if ((username.length() < 6 + 1 + 1) || (!username.contains("_"))) { diff --git a/src/main/java/org/dragonet/proxy/network/translator/pe/PEChatPacketTranslator.java b/src/main/java/org/dragonet/proxy/network/translator/pe/PEChatPacketTranslator.java index 47831d54e..2a397fbcc 100644 --- a/src/main/java/org/dragonet/proxy/network/translator/pe/PEChatPacketTranslator.java +++ b/src/main/java/org/dragonet/proxy/network/translator/pe/PEChatPacketTranslator.java @@ -14,17 +14,14 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket; import com.github.steveice10.packetlib.packet.Packet; -import org.dragonet.proxy.configuration.Lang; -import org.dragonet.proxy.network.CacheKey; import org.dragonet.proxy.network.UpstreamSession; import org.dragonet.proxy.network.translator.IPEPacketTranslator; import org.dragonet.proxy.protocol.packets.TextPacket; -import org.dragonet.proxy.utilities.PatternChecker; public class PEChatPacketTranslator implements IPEPacketTranslator { public Packet[] translate(UpstreamSession session, TextPacket packet) { - if (session.getDataCache().get(CacheKey.AUTHENTICATION_STATE) != null) { + /*if (session.getDataCache().get(CacheKey.AUTHENTICATION_STATE) != null) { if (session.getDataCache().get(CacheKey.AUTHENTICATION_STATE).equals("email")) { if (!PatternChecker.matchEmail(packet.message.trim())) { session.sendChat(session.getProxy().getLang().get(Lang.MESSAGE_ONLINE_ERROR)); @@ -40,12 +37,12 @@ public Packet[] translate(UpstreamSession session, TextPacket packet) { session.disconnect(session.getProxy().getLang().get(Lang.MESSAGE_ONLINE_ERROR)); return null; } - session.sendChat(session.getProxy().getLang().get(Lang.MESSAGE_ONLINE_LOGGIN_IN)); + session.sendChat(session.getProxy().getLang().get(Lang.MESSAGE_ONLINE_LOGGING_IN)); session.getDataCache().remove(CacheKey.AUTHENTICATION_STATE); session.authenticate(packet.message); // We NEVER cache password for better security. } return null; - } + }*/ ClientChatPacket pk = new ClientChatPacket(packet.message); return new Packet[]{pk}; diff --git a/src/main/java/org/dragonet/proxy/protocol/packets/ModalFormResponsePacket.java b/src/main/java/org/dragonet/proxy/protocol/packets/ModalFormResponsePacket.java index 3f442ea6d..c06bfe9df 100644 --- a/src/main/java/org/dragonet/proxy/protocol/packets/ModalFormResponsePacket.java +++ b/src/main/java/org/dragonet/proxy/protocol/packets/ModalFormResponsePacket.java @@ -8,8 +8,8 @@ */ public class ModalFormResponsePacket extends PEPacket { - private int formId; - private String formData; + public int formId; + public String formData; @Override public int pid() { diff --git a/src/main/java/org/dragonet/proxy/utilities/DebugTools.java b/src/main/java/org/dragonet/proxy/utilities/DebugTools.java index 1b287b3a1..44cd7772d 100644 --- a/src/main/java/org/dragonet/proxy/utilities/DebugTools.java +++ b/src/main/java/org/dragonet/proxy/utilities/DebugTools.java @@ -60,4 +60,22 @@ public static String getAllFields(Object obj) { } return data; } + + public static String matchConstant(Object obj, Class target) { + if(obj == null) return "NULL"; + try { + for (Field f : target.getDeclaredFields()) { + if ((f.getModifiers() & Modifier.STATIC) > 0) { + if (obj == f.get(null)) { + return f.getName(); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + System.out.println("DebugTools.matchConstant() ERROR! "); + return "ERROR(" + obj.toString() + ")"; + } + return "NOT_FOUND(" + obj.toString() + ")"; + } } diff --git a/src/main/java/org/dragonet/proxy/utilities/Versioning.java b/src/main/java/org/dragonet/proxy/utilities/Versioning.java index 1fa5dedc9..10b5c4bc6 100644 --- a/src/main/java/org/dragonet/proxy/utilities/Versioning.java +++ b/src/main/java/org/dragonet/proxy/utilities/Versioning.java @@ -16,7 +16,7 @@ public class Versioning { - public static final String RELEASE_VERSION = "0.3.2"; + public static final String RELEASE_VERSION = "0.3.3"; public static final String MINECRAFT_PC_VERSION = "1.12.2"; // public static final int MINECRAFT_PC_PROTOCOL = 47; // This is STRICT to MCPE binary's definition, DO NOT CHANGE diff --git a/src/main/resources/en_US.properties b/src/main/resources/en_US.properties index fb3e28e42..9bca2a9c5 100644 --- a/src/main/resources/en_US.properties +++ b/src/main/resources/en_US.properties @@ -10,9 +10,16 @@ init_creating_thread_pool=Creating thread pool(Size:%s)... init_binding=Binding on %s:%s ... init_done=The proxy has started! command_not_found=\u00a7cCommand not found! -message_client_connected=Player %s[%s] connected! -message_online_notice=\u00b7------------------------\n\u00b7* Minecraft Login *\n\u00b7Powered by DragonProxy! \n\u00b7http://dragonet.org/proxy\n\u00b7\n\u00b7Logging in as [%s]. \n\u00b7------------------------ -message_online_email=\u00b7Please enter your Minecraft PC/Mac account e-mail address in chat: +message_client_connected=Player %s[%s] connected! +message_login_prompt=\u00a7e==== \u00a7bLogin to \u00a74Minecraft \u00a7e====\n\ +\u00a7fpowered by DragonProxy\n\ +\u00a7aMove a bit to login! +message_login_progress=\u00a76authenticating... +form_login_title=\u00a71\u00a7lLogin to \u00a74\u00a7lMinecraft \u00a71\u00a7lAccount +form_login_desc=DragonProxy is a software to allow Bedrock players joining Minecraft: Java Edition servers. +form_login_prompt=\u00a7aYou are logging in to Minecraft: Java Edition account +form_login_username=\u00a7bUsername: +form_login_password=\u00a7bPassword: message_online_error=\u00a7cYour details were wrong. Please rejoin. message_online_password=\u00b7Please enter password: message_online_logging_in=\u00b7Logging in via Mojang AB, please wait...