Skip to content

Instantly share code, notes, and snippets.

@PEMapModder
Created September 16, 2015 13:10
Show Gist options
  • Select an option

  • Save PEMapModder/cbbf629e49389acbf7cd to your computer and use it in GitHub Desktop.

Select an option

Save PEMapModder/cbbf629e49389acbf7cd to your computer and use it in GitHub Desktop.
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