mirror of https://github.com/LOOHP/Limbo.git
Use file to handle packet id mappings
This commit is contained in:
parent
96bb492fc4
commit
212c8f2d41
|
|
@ -1,6 +1,7 @@
|
||||||
package com.loohp.limbo;
|
package com.loohp.limbo;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
@ -9,31 +10,16 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import com.loohp.limbo.File.ServerProperties;
|
import com.loohp.limbo.File.ServerProperties;
|
||||||
import com.loohp.limbo.Location.Location;
|
import com.loohp.limbo.Location.Location;
|
||||||
import com.loohp.limbo.Server.ServerConnection;
|
import com.loohp.limbo.Server.ServerConnection;
|
||||||
import com.loohp.limbo.Server.Packets.Packet;
|
import com.loohp.limbo.Server.Packets.Packet;
|
||||||
import com.loohp.limbo.Server.Packets.PacketHandshakingIn;
|
import com.loohp.limbo.Server.Packets.PacketIn;
|
||||||
import com.loohp.limbo.Server.Packets.PacketLoginInLoginStart;
|
import com.loohp.limbo.Server.Packets.PacketOut;
|
||||||
import com.loohp.limbo.Server.Packets.PacketLoginOutLoginSuccess;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayInChat;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayInKeepAlive;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayInPosition;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayInPositionAndLook;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutChat;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutKeepAlive;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutLogin;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutMapChunk;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerAbilities;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerInfo;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutPositionAndLook;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutShowPlayerSkins;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutSpawnPosition;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketPlayOutUpdateViewPosition;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketStatusInPing;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketStatusInRequest;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketStatusOutPong;
|
|
||||||
import com.loohp.limbo.Server.Packets.PacketStatusOutResponse;
|
|
||||||
import com.loohp.limbo.Utils.ImageUtils;
|
import com.loohp.limbo.Utils.ImageUtils;
|
||||||
import com.loohp.limbo.World.Schematic;
|
import com.loohp.limbo.World.Schematic;
|
||||||
import com.loohp.limbo.World.World;
|
import com.loohp.limbo.World.World;
|
||||||
|
|
@ -45,7 +31,7 @@ public class Limbo {
|
||||||
|
|
||||||
private static Limbo instance;
|
private static Limbo instance;
|
||||||
|
|
||||||
public static void main(String args[]) throws IOException {
|
public static void main(String args[]) throws IOException, ParseException, NumberFormatException, ClassNotFoundException {
|
||||||
new Limbo();
|
new Limbo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,7 +48,8 @@ public class Limbo {
|
||||||
|
|
||||||
private ServerProperties properties;
|
private ServerProperties properties;
|
||||||
|
|
||||||
public Limbo() throws IOException {
|
@SuppressWarnings("unchecked")
|
||||||
|
public Limbo() throws IOException, ParseException, NumberFormatException, ClassNotFoundException {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
console = new Console(System.in, System.out);
|
console = new Console(System.in, System.out);
|
||||||
|
|
@ -78,46 +65,67 @@ public class Limbo {
|
||||||
}
|
}
|
||||||
properties = new ServerProperties(sp);
|
properties = new ServerProperties(sp);
|
||||||
|
|
||||||
Map<Integer, Class<? extends Packet>> HandshakeIn = new HashMap<>();
|
String mappingName = "mapping.json";
|
||||||
HandshakeIn.put(0x00, PacketHandshakingIn.class);
|
File mappingFile = new File(mappingName);
|
||||||
|
if (!mappingFile.exists()) {
|
||||||
|
try (InputStream in = getClass().getClassLoader().getResourceAsStream(mappingName)) {
|
||||||
|
Files.copy(in, mappingFile.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = (JSONObject) new JSONParser().parse(new FileReader(mappingFile));
|
||||||
|
|
||||||
|
String classPrefix = Packet.class.getName().substring(0, Packet.class.getName().lastIndexOf(".") + 1);
|
||||||
|
|
||||||
|
Map<Integer, Class<? extends PacketIn>> HandshakeIn = new HashMap<>();
|
||||||
|
for (Object key : ((JSONObject) json.get("HandshakeIn")).keySet()) {
|
||||||
|
int packetId = Integer.decode((String) key);
|
||||||
|
HandshakeIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + (String) ((JSONObject) json.get("HandshakeIn")).get(key)));
|
||||||
|
}
|
||||||
Packet.setHandshakeIn(HandshakeIn);
|
Packet.setHandshakeIn(HandshakeIn);
|
||||||
|
|
||||||
Map<Integer, Class<? extends Packet>> StatusIn = new HashMap<>();
|
Map<Integer, Class<? extends PacketIn>> StatusIn = new HashMap<>();
|
||||||
StatusIn.put(0x00, PacketStatusInRequest.class);
|
for (Object key : ((JSONObject) json.get("StatusIn")).keySet()) {
|
||||||
StatusIn.put(0x01, PacketStatusInPing.class);
|
int packetId = Integer.decode((String) key);
|
||||||
|
StatusIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + (String) ((JSONObject) json.get("StatusIn")).get(key)));
|
||||||
|
}
|
||||||
Packet.setStatusIn(StatusIn);
|
Packet.setStatusIn(StatusIn);
|
||||||
|
|
||||||
Map<Class<? extends Packet>, Integer> StatusOut = new HashMap<>();
|
Map<Class<? extends PacketOut>, Integer> StatusOut = new HashMap<>();
|
||||||
StatusOut.put(PacketStatusOutResponse.class, 0x00);
|
for (Object key : ((JSONObject) json.get("StatusOut")).keySet()) {
|
||||||
StatusOut.put(PacketStatusOutPong.class, 0x01);
|
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + (String) key);
|
||||||
|
StatusOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("StatusOut")).get(key)));
|
||||||
|
}
|
||||||
Packet.setStatusOut(StatusOut);
|
Packet.setStatusOut(StatusOut);
|
||||||
|
|
||||||
Map<Integer, Class<? extends Packet>> LoginIn = new HashMap<>();
|
Map<Integer, Class<? extends PacketIn>> LoginIn = new HashMap<>();
|
||||||
LoginIn.put(0x00, PacketLoginInLoginStart.class);
|
for (Object key : ((JSONObject) json.get("LoginIn")).keySet()) {
|
||||||
|
int packetId = Integer.decode((String) key);
|
||||||
|
LoginIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + (String) ((JSONObject) json.get("LoginIn")).get(key)));
|
||||||
|
}
|
||||||
Packet.setLoginIn(LoginIn);
|
Packet.setLoginIn(LoginIn);
|
||||||
|
|
||||||
Map<Class<? extends Packet>, Integer> LoginOut = new HashMap<>();
|
Map<Class<? extends PacketOut>, Integer> LoginOut = new HashMap<>();
|
||||||
LoginOut.put(PacketLoginOutLoginSuccess.class, 0x02);
|
for (Object key : ((JSONObject) json.get("LoginOut")).keySet()) {
|
||||||
|
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + (String) key);
|
||||||
|
LoginOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("LoginOut")).get(key)));
|
||||||
|
}
|
||||||
Packet.setLoginOut(LoginOut);
|
Packet.setLoginOut(LoginOut);
|
||||||
|
|
||||||
Map<Integer, Class<? extends Packet>> PlayIn = new HashMap<>();
|
Map<Integer, Class<? extends PacketIn>> PlayIn = new HashMap<>();
|
||||||
PlayIn.put(0x10, PacketPlayInKeepAlive.class);
|
for (Object key : ((JSONObject) json.get("PlayIn")).keySet()) {
|
||||||
PlayIn.put(0x12, PacketPlayInPosition.class);
|
int packetId = Integer.decode((String) key);
|
||||||
PlayIn.put(0x13, PacketPlayInPositionAndLook.class);
|
PlayIn.put(packetId, (Class<? extends PacketIn>) Class.forName(classPrefix + (String) ((JSONObject) json.get("PlayIn")).get(key)));
|
||||||
PlayIn.put(0x03, PacketPlayInChat.class);
|
}
|
||||||
Packet.setPlayIn(PlayIn);
|
Packet.setPlayIn(PlayIn);
|
||||||
|
|
||||||
Map<Class<? extends Packet>, Integer> PlayOut = new HashMap<>();
|
Map<Class<? extends PacketOut>, Integer> PlayOut = new HashMap<>();
|
||||||
PlayOut.put(PacketPlayOutLogin.class, 0x25);
|
for (Object key : ((JSONObject) json.get("PlayOut")).keySet()) {
|
||||||
PlayOut.put(PacketPlayOutSpawnPosition.class, 0x42);
|
Class<? extends PacketOut> packetClass = (Class<? extends PacketOut>) Class.forName(classPrefix + (String) key);
|
||||||
PlayOut.put(PacketPlayOutPositionAndLook.class, 0x35);
|
PlayOut.put(packetClass, Integer.decode((String) ((JSONObject) json.get("PlayOut")).get(key)));
|
||||||
PlayOut.put(PacketPlayOutMapChunk.class, 0x21);
|
}
|
||||||
PlayOut.put(PacketPlayOutKeepAlive.class, 0x20);
|
|
||||||
PlayOut.put(PacketPlayOutUpdateViewPosition.class, 0x40);
|
|
||||||
PlayOut.put(PacketPlayOutPlayerInfo.class, 0x33);
|
|
||||||
PlayOut.put(PacketPlayOutShowPlayerSkins.class, 0x44);
|
|
||||||
PlayOut.put(PacketPlayOutPlayerAbilities.class, 0x31);
|
|
||||||
PlayOut.put(PacketPlayOutChat.class, 0x0E);
|
|
||||||
Packet.setPlayOut(PlayOut);
|
Packet.setPlayOut(PlayOut);
|
||||||
|
|
||||||
worlds.add(loadDefaultWorld());
|
worlds.add(loadDefaultWorld());
|
||||||
|
|
|
||||||
|
|
@ -4,77 +4,71 @@ import java.util.Map;
|
||||||
|
|
||||||
public class Packet {
|
public class Packet {
|
||||||
|
|
||||||
private static Map<Integer, Class<? extends Packet>> HandshakeIn;
|
private static Map<Integer, Class<? extends PacketIn>> HandshakeIn;
|
||||||
|
|
||||||
private static Map<Integer, Class<? extends Packet>> StatusIn;
|
private static Map<Integer, Class<? extends PacketIn>> StatusIn;
|
||||||
private static Map<Class<? extends Packet>, Integer> StatusOut;
|
private static Map<Class<? extends PacketOut>, Integer> StatusOut;
|
||||||
|
|
||||||
private static Map<Integer, Class<? extends Packet>> LoginIn;
|
private static Map<Integer, Class<? extends PacketIn>> LoginIn;
|
||||||
private static Map<Class<? extends Packet>, Integer> LoginOut;
|
private static Map<Class<? extends PacketOut>, Integer> LoginOut;
|
||||||
|
|
||||||
private static Map<Integer, Class<? extends Packet>> PlayIn;
|
private static Map<Integer, Class<? extends PacketIn>> PlayIn;
|
||||||
private static Map<Class<? extends Packet>, Integer> PlayOut;
|
private static Map<Class<? extends PacketOut>, Integer> PlayOut;
|
||||||
|
|
||||||
public static Map<Integer, Class<? extends Packet>> getHandshakeIn() {
|
public static Map<Integer, Class<? extends PacketIn>> getHandshakeIn() {
|
||||||
return HandshakeIn;
|
return HandshakeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHandshakeIn(Map<Integer, Class<? extends Packet>> handshakeIn) {
|
public static void setHandshakeIn(Map<Integer, Class<? extends PacketIn>> handshakeIn) {
|
||||||
HandshakeIn = handshakeIn;
|
HandshakeIn = handshakeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Class<? extends Packet>> getStatusIn() {
|
public static Map<Integer, Class<? extends PacketIn>> getStatusIn() {
|
||||||
return StatusIn;
|
return StatusIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStatusIn(Map<Integer, Class<? extends Packet>> statusIn) {
|
public static void setStatusIn(Map<Integer, Class<? extends PacketIn>> statusIn) {
|
||||||
StatusIn = statusIn;
|
StatusIn = statusIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Class<? extends Packet>, Integer> getStatusOut() {
|
public static Map<Class<? extends PacketOut>, Integer> getStatusOut() {
|
||||||
return StatusOut;
|
return StatusOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStatusOut(Map<Class<? extends Packet>, Integer> statusOut) {
|
public static void setStatusOut(Map<Class<? extends PacketOut>, Integer> statusOut) {
|
||||||
StatusOut = statusOut;
|
StatusOut = statusOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Class<? extends Packet>> getLoginIn() {
|
public static Map<Integer, Class<? extends PacketIn>> getLoginIn() {
|
||||||
return LoginIn;
|
return LoginIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLoginIn(Map<Integer, Class<? extends Packet>> loginIn) {
|
public static void setLoginIn(Map<Integer, Class<? extends PacketIn>> loginIn) {
|
||||||
LoginIn = loginIn;
|
LoginIn = loginIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Class<? extends Packet>, Integer> getLoginOut() {
|
public static Map<Class<? extends PacketOut>, Integer> getLoginOut() {
|
||||||
return LoginOut;
|
return LoginOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLoginOut(Map<Class<? extends Packet>, Integer> loginOut) {
|
public static void setLoginOut(Map<Class<? extends PacketOut>, Integer> loginOut) {
|
||||||
LoginOut = loginOut;
|
LoginOut = loginOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Class<? extends Packet>> getPlayIn() {
|
public static Map<Integer, Class<? extends PacketIn>> getPlayIn() {
|
||||||
return PlayIn;
|
return PlayIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlayIn(Map<Integer, Class<? extends Packet>> playIn) {
|
public static void setPlayIn(Map<Integer, Class<? extends PacketIn>> playIn) {
|
||||||
PlayIn = playIn;
|
PlayIn = playIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Class<? extends Packet>, Integer> getPlayOut() {
|
public static Map<Class<? extends PacketOut>, Integer> getPlayOut() {
|
||||||
return PlayOut;
|
return PlayOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlayOut(Map<Class<? extends Packet>, Integer> playOut) {
|
public static void setPlayOut(Map<Class<? extends PacketOut>, Integer> playOut) {
|
||||||
PlayOut = playOut;
|
PlayOut = playOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================
|
|
||||||
|
|
||||||
public Packet() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketHandshakingIn extends Packet {
|
public class PacketHandshakingIn extends PacketIn {
|
||||||
|
|
||||||
public static enum HandshakeType {
|
public static enum HandshakeType {
|
||||||
STATUS(1),
|
STATUS(1),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.loohp.limbo.Server.Packets;
|
||||||
|
|
||||||
|
public abstract class PacketIn extends Packet {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketLoginInLoginStart extends Packet {
|
public class PacketLoginInLoginStart extends PacketIn {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketLoginOutLoginSuccess extends Packet {
|
public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String username;
|
private String username;
|
||||||
|
|
@ -26,6 +26,7 @@ public class PacketLoginOutLoginSuccess extends Packet {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.loohp.limbo.Server.Packets;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public abstract class PacketOut extends Packet {
|
||||||
|
|
||||||
|
public abstract byte[] getBytes() throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketPlayInChat extends Packet {
|
public class PacketPlayInChat extends PacketIn {
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayInKeepAlive extends Packet {
|
public class PacketPlayInKeepAlive extends PacketIn {
|
||||||
|
|
||||||
long payload;
|
long payload;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayInPosition extends Packet {
|
public class PacketPlayInPosition extends PacketIn {
|
||||||
|
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayInPositionAndLook extends Packet {
|
public class PacketPlayInPositionAndLook extends PacketIn {
|
||||||
|
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketPlayOutChat extends Packet {
|
public class PacketPlayOutChat extends PacketOut {
|
||||||
|
|
||||||
private String json;
|
private String json;
|
||||||
private int position;
|
private int position;
|
||||||
|
|
@ -32,6 +32,7 @@ public class PacketPlayOutChat extends Packet {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayOutKeepAlive extends Packet {
|
public class PacketPlayOutKeepAlive extends PacketOut {
|
||||||
|
|
||||||
long payload;
|
long payload;
|
||||||
|
|
||||||
|
|
@ -16,6 +16,7 @@ public class PacketPlayOutKeepAlive extends Packet {
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import com.loohp.limbo.Utils.GameMode;
|
||||||
|
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
|
|
||||||
public class PacketPlayOutLogin extends Packet {
|
public class PacketPlayOutLogin extends PacketOut {
|
||||||
|
|
||||||
private int entityId;
|
private int entityId;
|
||||||
private boolean isHardcore;
|
private boolean isHardcore;
|
||||||
|
|
@ -103,6 +103,7 @@ public class PacketPlayOutLogin extends Packet {
|
||||||
return isFlat;
|
return isFlat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import net.querz.mca.Section;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
import net.querz.nbt.tag.ListTag;
|
import net.querz.nbt.tag.ListTag;
|
||||||
|
|
||||||
public class PacketPlayOutMapChunk extends Packet {
|
public class PacketPlayOutMapChunk extends PacketOut {
|
||||||
|
|
||||||
private int chunkX;
|
private int chunkX;
|
||||||
private int chunkZ;
|
private int chunkZ;
|
||||||
|
|
@ -38,6 +38,7 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||||
return chunkZ;
|
return chunkZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketPlayOutPlayerAbilities extends Packet {
|
public class PacketPlayOutPlayerAbilities extends PacketOut {
|
||||||
|
|
||||||
public enum PlayerAbilityFlags {
|
public enum PlayerAbilityFlags {
|
||||||
INVULNERABLE(0x01),
|
INVULNERABLE(0x01),
|
||||||
|
|
@ -45,6 +45,7 @@ public class PacketPlayOutPlayerAbilities extends Packet {
|
||||||
return fieldOfField;
|
return fieldOfField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerInfo.PlayerInfoData.Pla
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
import com.loohp.limbo.Utils.GameMode;
|
import com.loohp.limbo.Utils.GameMode;
|
||||||
|
|
||||||
public class PacketPlayOutPlayerInfo extends Packet {
|
public class PacketPlayOutPlayerInfo extends PacketOut {
|
||||||
|
|
||||||
public enum PlayerInfoAction {
|
public enum PlayerInfoAction {
|
||||||
ADD_PLAYER(0), UPDATE_GAMEMODE(1), UPDATE_LATENCY(2), UPDATE_DISPLAY_NAME(3), REMOVE_PLAYER(4);
|
ADD_PLAYER(0), UPDATE_GAMEMODE(1), UPDATE_LATENCY(2), UPDATE_DISPLAY_NAME(3), REMOVE_PLAYER(4);
|
||||||
|
|
@ -49,6 +49,7 @@ public class PacketPlayOutPlayerInfo extends Packet {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketPlayOutPositionAndLook extends Packet {
|
public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||||
|
|
||||||
public enum PlayerTeleportFlags {
|
public enum PlayerTeleportFlags {
|
||||||
X((byte) 0x01),
|
X((byte) 0x01),
|
||||||
|
|
@ -75,6 +75,7 @@ public class PacketPlayOutPositionAndLook extends Packet {
|
||||||
return teleportId;
|
return teleportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketPlayOutShowPlayerSkins extends Packet {
|
public class PacketPlayOutShowPlayerSkins extends PacketOut {
|
||||||
|
|
||||||
private int entityId;
|
private int entityId;
|
||||||
|
|
||||||
|
|
@ -18,6 +18,7 @@ public class PacketPlayOutShowPlayerSkins extends Packet {
|
||||||
return entityId;
|
return entityId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.World.BlockPosition;
|
import com.loohp.limbo.World.BlockPosition;
|
||||||
|
|
||||||
public class PacketPlayOutSpawnPosition extends Packet {
|
public class PacketPlayOutSpawnPosition extends PacketOut {
|
||||||
|
|
||||||
private BlockPosition position;
|
private BlockPosition position;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketPlayOutUpdateViewPosition extends Packet {
|
public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
||||||
|
|
||||||
private int chunkX;
|
private int chunkX;
|
||||||
private int chunkZ;
|
private int chunkZ;
|
||||||
|
|
@ -24,6 +24,7 @@ public class PacketPlayOutUpdateViewPosition extends Packet {
|
||||||
return chunkZ;
|
return chunkZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketStatusInPing extends Packet {
|
public class PacketStatusInPing extends PacketIn {
|
||||||
|
|
||||||
private long payload;
|
private long payload;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package com.loohp.limbo.Server.Packets;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
|
||||||
public class PacketStatusInRequest extends Packet {
|
public class PacketStatusInRequest extends PacketIn {
|
||||||
|
|
||||||
public PacketStatusInRequest() {
|
public PacketStatusInRequest() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PacketStatusOutPong extends Packet {
|
public class PacketStatusOutPong extends PacketOut {
|
||||||
|
|
||||||
private long payload;
|
private long payload;
|
||||||
|
|
||||||
|
|
@ -16,6 +16,7 @@ public class PacketStatusOutPong extends Packet {
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import com.loohp.limbo.Utils.DataTypeIO;
|
import com.loohp.limbo.Utils.DataTypeIO;
|
||||||
|
|
||||||
public class PacketStatusOutResponse extends Packet {
|
public class PacketStatusOutResponse extends PacketOut {
|
||||||
|
|
||||||
private String json;
|
private String json;
|
||||||
|
|
||||||
|
|
@ -19,6 +19,7 @@ public class PacketStatusOutResponse extends Packet {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte[] getBytes() throws IOException {
|
public byte[] getBytes() throws IOException {
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
{
|
||||||
|
"HandshakeIn": {
|
||||||
|
"0x00": "PacketHandshakingIn"
|
||||||
|
},
|
||||||
|
"LoginIn": {
|
||||||
|
"0x00": "PacketLoginInLoginStart"
|
||||||
|
},
|
||||||
|
"LoginOut": {
|
||||||
|
"PacketLoginOutLoginSuccess": "0x02"
|
||||||
|
},
|
||||||
|
"PlayIn": {
|
||||||
|
"0x10": "PacketPlayInKeepAlive",
|
||||||
|
"0x03": "PacketPlayInChat",
|
||||||
|
"0x13": "PacketPlayInPositionAndLook",
|
||||||
|
"0x12": "PacketPlayInPosition"
|
||||||
|
},
|
||||||
|
"PlayOut": {
|
||||||
|
"PacketPlayOutLogin": "0x25",
|
||||||
|
"PacketPlayOutPositionAndLook": "0x35",
|
||||||
|
"PacketPlayOutSpawnPosition": "0x42",
|
||||||
|
"PacketPlayOutChat": "0x0E",
|
||||||
|
"PacketPlayOutPlayerAbilities": "0x31",
|
||||||
|
"PacketPlayOutMapChunk": "0x21",
|
||||||
|
"PacketPlayOutKeepAlive": "0x20",
|
||||||
|
"PacketPlayOutPlayerInfo": "0x33",
|
||||||
|
"PacketPlayOutUpdateViewPosition": "0x40",
|
||||||
|
"PacketPlayOutShowPlayerSkins": "0x44"
|
||||||
|
},
|
||||||
|
"StatusIn": {
|
||||||
|
"0x01": "PacketStatusInPing",
|
||||||
|
"0x00": "PacketStatusInRequest"
|
||||||
|
},
|
||||||
|
"StatusOut": {
|
||||||
|
"PacketStatusOutResponse": "0x00",
|
||||||
|
"PacketStatusOutPong": "0x01"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue