This repository has been archived by the owner on Apr 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bd478d
commit ceab389
Showing
12 changed files
with
121 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(" <<PE " + org.dragonet.proxy.utilities.DebugTools.matchConstant((byte)(packet.pid() & 0xFF), ProtocolInfo.class)); | ||
|
||
// System.out.println("RECEIVED PACKET=" + packet.getClass().getSimpleName()); | ||
/* | ||
* try{ FileOutputStream fos = new FileOutputStream("cap_" + | ||
|
@@ -80,6 +85,32 @@ public void handlePacket(PEPacket packet) { | |
case ProtocolInfo.LOGIN_PACKET: | ||
client.onLogin((LoginPacket) packet); | ||
break; | ||
case ProtocolInfo.MOVE_PLAYER_PACKET: | ||
if(client.getDataCache().containsKey(CacheKey.AUTHENTICATION_STATE) && | ||
client.getDataCache().get(CacheKey.AUTHENTICATION_STATE).equals("online_login_wait")) { | ||
// client.getDataCache().put(CacheKey.AUTHENTICATION_STATE, "online_login"); | ||
ModalFormRequestPacket packetForm = new ModalFormRequestPacket(); | ||
CustomFormComponent form = new CustomFormComponent(client.getProxy().getLang().get(Lang.FORM_LOGIN_TITLE)); | ||
form.addComponent(new LabelComponent(client.getProxy().getLang().get(Lang.FORM_LOGIN_DESC))); | ||
form.addComponent(new LabelComponent(client.getProxy().getLang().get(Lang.FORM_LOGIN_PROMPT))); | ||
form.addComponent(new InputComponent(client.getProxy().getLang().get(Lang.FORM_LOGIN_USERNAME)).setPlaceholder("[email protected]")); | ||
form.addComponent(new InputComponent(client.getProxy().getLang().get(Lang.FORM_LOGIN_PASSWORD)).setPlaceholder("123456")); | ||
packetForm.formId = 1; | ||
packetForm.formData = form.serializeToJson().toString(); | ||
client.sendPacket(packetForm); | ||
break; | ||
} | ||
case ProtocolInfo.MODAL_FORM_RESPONSE_PACKET: | ||
if(client.getDataCache().containsKey(CacheKey.AUTHENTICATION_STATE) && | ||
client.getDataCache().get(CacheKey.AUTHENTICATION_STATE).equals("online_login_wait")) { | ||
client.sendChat(client.getProxy().getLang().get(Lang.MESSAGE_LOGIN_PROGRESS)); | ||
|
||
ModalFormResponsePacket formResponse = (ModalFormResponsePacket) packet; | ||
JSONArray array = new JSONArray(formResponse.formData); | ||
client.authenticate(array.get(2).toString(), array.get(3).toString()); | ||
client.getDataCache().remove(CacheKey.AUTHENTICATION_STATE); | ||
break; | ||
} | ||
case ProtocolInfo.RESOURCE_PACK_CLIENT_RESPONSE_PACKET: | ||
if (client.isLoggedIn()) { | ||
return; | ||
|
@@ -89,11 +120,6 @@ public void handlePacket(PEPacket packet) { | |
case ProtocolInfo.REQUEST_CHUNK_RADIUS_PACKET: | ||
client.sendPacket(new ChunkRadiusUpdatedPacket(((RequestChunkRadiusPacket) packet).radius)); | ||
break; | ||
case ProtocolInfo.TEXT_PACKET: // Text (check CLS Login) | ||
if (client.getDataCache().get(CacheKey.AUTHENTICATION_STATE) != null) { | ||
PacketTranslatorRegister.translateToPC(client, packet); | ||
break; | ||
} | ||
default: | ||
if (client.getDownstream() == null) { | ||
break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters