Created
September 16, 2015 13:10
-
-
Save PEMapModder/cbbf629e49389acbf7cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import static FieldType.*; | |
| public enum MCPEProtocolInfoV27{ | |
| LOGIN_PACKET( | |
| LoginRequest.class, | |
| new PF(STRING, "username"), | |
| new PF(LONG, "clientId") | |
| ); | |
| MCPEProtocolInfoV27(Class<? extends Request> requestClass, PF... fields){ | |
| // initialize fields | |
| } | |
| } | |
| public class PF{ | |
| public FieldType type; | |
| public String name; | |
| public PF(FieldType type, String name){ | |
| this.type = type; | |
| this.name = name; | |
| } | |
| } | |
| public enum FieldType{ | |
| STRING{ | |
| @Override public Object read(Buffer buffer){ | |
| byte[] bytes = new byte[buffer.getShort()]; | |
| buffer.read(bytes); | |
| return new String(bytes); | |
| } | |
| @Override public void write(Buffer buffer, Object param){ | |
| buffer.write(params.getBytes()); | |
| } | |
| }, | |
| BLAH, | |
| BLAH, | |
| BLAH; | |
| public abstract void write(Buffer buffer, Object param); | |
| public abstract Object read(Buffer buffer); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment