@@ -75,43 +75,42 @@ public void handlePacket(PEPacket packet) {
7575
7676 System .out .println (" <<PE " + org .dragonet .proxy .utilities .DebugTools .matchConstant ((byte )(packet .pid () & 0xFF ), ProtocolInfo .class ));
7777
78- // System.out.println("RECEIVED PACKET=" + packet.getClass().getSimpleName());
79- /*
80- * try{ FileOutputStream fos = new FileOutputStream("cap_" +
81- * System.currentTimeMillis() + "_" + packet.getClass().getSimpleName() +
82- * ".bin"); fos.write(packet.getBuffer()); fos.close(); }catch(Exception e){}
83- */
78+
79+ if (packet .pid () == ProtocolInfo .MOVE_PLAYER_PACKET ) {
80+ if (client .getDataCache ().containsKey (CacheKey .AUTHENTICATION_STATE ) &&
81+ client .getDataCache ().get (CacheKey .AUTHENTICATION_STATE ).equals ("online_login_wait" )) {
82+ // client.getDataCache().put(CacheKey.AUTHENTICATION_STATE, "online_login");
83+ ModalFormRequestPacket packetForm = new ModalFormRequestPacket ();
84+ CustomFormComponent form = new CustomFormComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_TITLE ));
85+ form .addComponent (new LabelComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_DESC )));
86+ form .addComponent (new LabelComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_PROMPT )));
87+ form .
addComponent (
new InputComponent (
client .
getProxy ().
getLang ().
get (
Lang .
FORM_LOGIN_USERNAME )).
setPlaceholder (
"[email protected] " ));
88+ form .addComponent (new InputComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_PASSWORD )).setPlaceholder ("123456" ));
89+ packetForm .formId = 1 ;
90+ packetForm .formData = form .serializeToJson ().toString ();
91+ client .sendPacket (packetForm );
92+ return ;
93+ }
94+ }
95+
96+ if (packet .pid () == ProtocolInfo .MODAL_FORM_RESPONSE_PACKET ) {
97+ if (client .getDataCache ().containsKey (CacheKey .AUTHENTICATION_STATE ) &&
98+ client .getDataCache ().get (CacheKey .AUTHENTICATION_STATE ).equals ("online_login_wait" )) {
99+ client .sendChat (client .getProxy ().getLang ().get (Lang .MESSAGE_LOGIN_PROGRESS ));
100+
101+ client .getDataCache ().remove (CacheKey .AUTHENTICATION_STATE );
102+
103+ ModalFormResponsePacket formResponse = (ModalFormResponsePacket ) packet ;
104+ JSONArray array = new JSONArray (formResponse .formData );
105+ client .authenticate (array .get (2 ).toString (), array .get (3 ).toString ());
106+ return ;
107+ }
108+ }
109+
84110 switch (packet .pid ()) {
85111 case ProtocolInfo .LOGIN_PACKET :
86112 client .onLogin ((LoginPacket ) packet );
87113 break ;
88- case ProtocolInfo .MOVE_PLAYER_PACKET :
89- if (client .getDataCache ().containsKey (CacheKey .AUTHENTICATION_STATE ) &&
90- client .getDataCache ().get (CacheKey .AUTHENTICATION_STATE ).equals ("online_login_wait" )) {
91- // client.getDataCache().put(CacheKey.AUTHENTICATION_STATE, "online_login");
92- ModalFormRequestPacket packetForm = new ModalFormRequestPacket ();
93- CustomFormComponent form = new CustomFormComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_TITLE ));
94- form .addComponent (new LabelComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_DESC )));
95- form .addComponent (new LabelComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_PROMPT )));
96- form .
addComponent (
new InputComponent (
client .
getProxy ().
getLang ().
get (
Lang .
FORM_LOGIN_USERNAME )).
setPlaceholder (
"[email protected] " ));
97- form .addComponent (new InputComponent (client .getProxy ().getLang ().get (Lang .FORM_LOGIN_PASSWORD )).setPlaceholder ("123456" ));
98- packetForm .formId = 1 ;
99- packetForm .formData = form .serializeToJson ().toString ();
100- client .sendPacket (packetForm );
101- break ;
102- }
103- case ProtocolInfo .MODAL_FORM_RESPONSE_PACKET :
104- if (client .getDataCache ().containsKey (CacheKey .AUTHENTICATION_STATE ) &&
105- client .getDataCache ().get (CacheKey .AUTHENTICATION_STATE ).equals ("online_login_wait" )) {
106- client .sendChat (client .getProxy ().getLang ().get (Lang .MESSAGE_LOGIN_PROGRESS ));
107-
108- client .getDataCache ().remove (CacheKey .AUTHENTICATION_STATE );
109-
110- ModalFormResponsePacket formResponse = (ModalFormResponsePacket ) packet ;
111- JSONArray array = new JSONArray (formResponse .formData );
112- client .authenticate (array .get (2 ).toString (), array .get (3 ).toString ());
113- break ;
114- }
115114 case ProtocolInfo .RESOURCE_PACK_CLIENT_RESPONSE_PACKET :
116115 if (client .isLoggedIn ()) {
117116 return ;
0 commit comments