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
b517d6f
commit 4bd478d
Showing
9 changed files
with
220 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
src/main/java/org/dragonet/proxy/gui/BaseModalFormComponent.java
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,28 @@ | ||
package org.dragonet.proxy.gui; | ||
|
||
import org.json.JSONObject; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public abstract class BaseModalFormComponent implements ModalFormComponent { | ||
|
||
private final String type; | ||
|
||
public BaseModalFormComponent(String type) { | ||
this.type = type; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public final JSONObject serializeToJson() { | ||
JSONObject obj = new JSONObject(); | ||
obj.put("type", type); | ||
serializeData(obj); | ||
return obj; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/org/dragonet/proxy/gui/CustomFormComponent.java
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,39 @@ | ||
package org.dragonet.proxy.gui; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public class CustomFormComponent extends BaseModalFormComponent { | ||
|
||
private String title; | ||
|
||
private final List<ModalFormComponent> components = new ArrayList<>(); | ||
|
||
public CustomFormComponent(String title) { | ||
super("custom_form"); | ||
this.title = title; | ||
} | ||
|
||
public CustomFormComponent addComponent(ModalFormComponent component){ | ||
components.add(component); | ||
return this; | ||
} | ||
|
||
public List<ModalFormComponent> getComponents() { | ||
return components; | ||
} | ||
|
||
@Override | ||
public void serializeData(JSONObject out) { | ||
out.put("title", title); | ||
JSONArray content = new JSONArray(); | ||
components.forEach((c) -> content.put(c.serializeToJson())); | ||
out.put("content", content); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/dragonet/proxy/gui/DropDownComponent.java
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,27 @@ | ||
package org.dragonet.proxy.gui; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public class DropDownComponent extends BaseModalFormComponent { | ||
|
||
private String text; | ||
private List<String> options; | ||
|
||
public DropDownComponent(String text, List<String> options) { | ||
super("dropdown"); | ||
this.text = text; | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public void serializeData(JSONObject out) { | ||
out.put("text", text); | ||
out.put("options", new JSONArray(options)); | ||
} | ||
} |
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,25 @@ | ||
package org.dragonet.proxy.gui; | ||
|
||
import org.json.JSONObject; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public class LabelComponent extends BaseModalFormComponent { | ||
|
||
private String text; | ||
|
||
public LabelComponent(String text) { | ||
super("label"); | ||
this.text = text; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
@Override | ||
public void serializeData(JSONObject out) { | ||
out.put("text", text); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/dragonet/proxy/gui/ModalFormComponent.java
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,16 @@ | ||
package org.dragonet.proxy.gui; | ||
|
||
import org.json.JSONObject; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public interface ModalFormComponent { | ||
|
||
String getType(); | ||
|
||
void serializeData(JSONObject out); | ||
|
||
JSONObject serializeToJson(); | ||
|
||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/dragonet/proxy/protocol/packets/ModalFormRequestPacket.java
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,30 @@ | ||
package org.dragonet.proxy.protocol.packets; | ||
|
||
import org.dragonet.proxy.protocol.PEPacket; | ||
import org.dragonet.proxy.protocol.ProtocolInfo; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public class ModalFormRequestPacket extends PEPacket { | ||
|
||
public int formId; | ||
public String formData; | ||
|
||
@Override | ||
public int pid() { | ||
return ProtocolInfo.MODAL_FORM_REQUEST_PACKET; | ||
} | ||
|
||
@Override | ||
public void encodePayload() { | ||
putUnsignedVarInt(formId); | ||
putString(formData); | ||
} | ||
|
||
@Override | ||
public void decodePayload() { | ||
formId = (int) (getUnsignedVarInt() & 0xFFFFFFFF); | ||
formData = getString(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/dragonet/proxy/protocol/packets/ModalFormResponsePacket.java
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,30 @@ | ||
package org.dragonet.proxy.protocol.packets; | ||
|
||
import org.dragonet.proxy.protocol.PEPacket; | ||
import org.dragonet.proxy.protocol.ProtocolInfo; | ||
|
||
/** | ||
* Created on 2017/12/26. | ||
*/ | ||
public class ModalFormResponsePacket extends PEPacket { | ||
|
||
private int formId; | ||
private String formData; | ||
|
||
@Override | ||
public int pid() { | ||
return ProtocolInfo.MODAL_FORM_RESPONSE_PACKET; | ||
} | ||
|
||
@Override | ||
public void encodePayload() { | ||
putUnsignedVarInt(formId); | ||
putString(formData); | ||
} | ||
|
||
@Override | ||
public void decodePayload() { | ||
formId = (int) (getUnsignedVarInt() & 0xFFFFFFFF); | ||
formData = getString(); | ||
} | ||
} |