forked from BLOCKFANTASY/LOOHP-Limbo
Use file to handle packet id mappings
This commit is contained in:
@@ -4,77 +4,71 @@ import java.util.Map;
|
||||
|
||||
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<Class<? extends Packet>, Integer> StatusOut;
|
||||
private static Map<Integer, Class<? extends PacketIn>> StatusIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> StatusOut;
|
||||
|
||||
private static Map<Integer, Class<? extends Packet>> LoginIn;
|
||||
private static Map<Class<? extends Packet>, Integer> LoginOut;
|
||||
private static Map<Integer, Class<? extends PacketIn>> LoginIn;
|
||||
private static Map<Class<? extends PacketOut>, Integer> LoginOut;
|
||||
|
||||
private static Map<Integer, Class<? extends Packet>> PlayIn;
|
||||
private static Map<Class<? extends Packet>, Integer> PlayOut;
|
||||
private static Map<Integer, Class<? extends PacketIn>> PlayIn;
|
||||
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;
|
||||
}
|
||||
|
||||
public static void setHandshakeIn(Map<Integer, Class<? extends Packet>> handshakeIn) {
|
||||
public static void setHandshakeIn(Map<Integer, Class<? extends PacketIn>> handshakeIn) {
|
||||
HandshakeIn = handshakeIn;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends Packet>> getStatusIn() {
|
||||
public static Map<Integer, Class<? extends PacketIn>> getStatusIn() {
|
||||
return StatusIn;
|
||||
}
|
||||
|
||||
public static void setStatusIn(Map<Integer, Class<? extends Packet>> statusIn) {
|
||||
public static void setStatusIn(Map<Integer, Class<? extends PacketIn>> statusIn) {
|
||||
StatusIn = statusIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends Packet>, Integer> getStatusOut() {
|
||||
public static Map<Class<? extends PacketOut>, Integer> getStatusOut() {
|
||||
return StatusOut;
|
||||
}
|
||||
|
||||
public static void setStatusOut(Map<Class<? extends Packet>, Integer> statusOut) {
|
||||
public static void setStatusOut(Map<Class<? extends PacketOut>, Integer> statusOut) {
|
||||
StatusOut = statusOut;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends Packet>> getLoginIn() {
|
||||
public static Map<Integer, Class<? extends PacketIn>> getLoginIn() {
|
||||
return LoginIn;
|
||||
}
|
||||
|
||||
public static void setLoginIn(Map<Integer, Class<? extends Packet>> loginIn) {
|
||||
public static void setLoginIn(Map<Integer, Class<? extends PacketIn>> loginIn) {
|
||||
LoginIn = loginIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends Packet>, Integer> getLoginOut() {
|
||||
public static Map<Class<? extends PacketOut>, Integer> getLoginOut() {
|
||||
return LoginOut;
|
||||
}
|
||||
|
||||
public static void setLoginOut(Map<Class<? extends Packet>, Integer> loginOut) {
|
||||
public static void setLoginOut(Map<Class<? extends PacketOut>, Integer> loginOut) {
|
||||
LoginOut = loginOut;
|
||||
}
|
||||
|
||||
public static Map<Integer, Class<? extends Packet>> getPlayIn() {
|
||||
public static Map<Integer, Class<? extends PacketIn>> getPlayIn() {
|
||||
return PlayIn;
|
||||
}
|
||||
|
||||
public static void setPlayIn(Map<Integer, Class<? extends Packet>> playIn) {
|
||||
public static void setPlayIn(Map<Integer, Class<? extends PacketIn>> playIn) {
|
||||
PlayIn = playIn;
|
||||
}
|
||||
|
||||
public static Map<Class<? extends Packet>, Integer> getPlayOut() {
|
||||
public static Map<Class<? extends PacketOut>, Integer> getPlayOut() {
|
||||
return PlayOut;
|
||||
}
|
||||
|
||||
public static void setPlayOut(Map<Class<? extends Packet>, Integer> playOut) {
|
||||
public static void setPlayOut(Map<Class<? extends PacketOut>, Integer> playOut) {
|
||||
PlayOut = playOut;
|
||||
}
|
||||
|
||||
//===========================================
|
||||
|
||||
public Packet() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.io.IOException;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketHandshakingIn extends Packet {
|
||||
public class PacketHandshakingIn extends PacketIn {
|
||||
|
||||
public static enum HandshakeType {
|
||||
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;
|
||||
|
||||
public class PacketLoginInLoginStart extends Packet {
|
||||
public class PacketLoginInLoginStart extends PacketIn {
|
||||
|
||||
private String username;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketLoginOutLoginSuccess extends Packet {
|
||||
public class PacketLoginOutLoginSuccess extends PacketOut {
|
||||
|
||||
private UUID uuid;
|
||||
private String username;
|
||||
@@ -26,6 +26,7 @@ public class PacketLoginOutLoginSuccess extends Packet {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
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;
|
||||
|
||||
public class PacketPlayInChat extends Packet {
|
||||
public class PacketPlayInChat extends PacketIn {
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayInKeepAlive extends Packet {
|
||||
public class PacketPlayInKeepAlive extends PacketIn {
|
||||
|
||||
long payload;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayInPosition extends Packet {
|
||||
public class PacketPlayInPosition extends PacketIn {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayInPositionAndLook extends Packet {
|
||||
public class PacketPlayInPositionAndLook extends PacketIn {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.UUID;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketPlayOutChat extends Packet {
|
||||
public class PacketPlayOutChat extends PacketOut {
|
||||
|
||||
private String json;
|
||||
private int position;
|
||||
@@ -32,6 +32,7 @@ public class PacketPlayOutChat extends Packet {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutKeepAlive extends Packet {
|
||||
public class PacketPlayOutKeepAlive extends PacketOut {
|
||||
|
||||
long payload;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class PacketPlayOutKeepAlive extends Packet {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.loohp.limbo.Utils.GameMode;
|
||||
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
|
||||
public class PacketPlayOutLogin extends Packet {
|
||||
public class PacketPlayOutLogin extends PacketOut {
|
||||
|
||||
private int entityId;
|
||||
private boolean isHardcore;
|
||||
@@ -103,6 +103,7 @@ public class PacketPlayOutLogin extends Packet {
|
||||
return isFlat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.querz.mca.Section;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import net.querz.nbt.tag.ListTag;
|
||||
|
||||
public class PacketPlayOutMapChunk extends Packet {
|
||||
public class PacketPlayOutMapChunk extends PacketOut {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
@@ -38,6 +38,7 @@ public class PacketPlayOutMapChunk extends Packet {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketPlayOutPlayerAbilities extends Packet {
|
||||
public class PacketPlayOutPlayerAbilities extends PacketOut {
|
||||
|
||||
public enum PlayerAbilityFlags {
|
||||
INVULNERABLE(0x01),
|
||||
@@ -45,6 +45,7 @@ public class PacketPlayOutPlayerAbilities extends Packet {
|
||||
return fieldOfField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
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.GameMode;
|
||||
|
||||
public class PacketPlayOutPlayerInfo extends Packet {
|
||||
public class PacketPlayOutPlayerInfo extends PacketOut {
|
||||
|
||||
public enum PlayerInfoAction {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketPlayOutPositionAndLook extends Packet {
|
||||
public class PacketPlayOutPositionAndLook extends PacketOut {
|
||||
|
||||
public enum PlayerTeleportFlags {
|
||||
X((byte) 0x01),
|
||||
@@ -75,6 +75,7 @@ public class PacketPlayOutPositionAndLook extends Packet {
|
||||
return teleportId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.IOException;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketPlayOutShowPlayerSkins extends Packet {
|
||||
public class PacketPlayOutShowPlayerSkins extends PacketOut {
|
||||
|
||||
private int entityId;
|
||||
|
||||
@@ -18,6 +18,7 @@ public class PacketPlayOutShowPlayerSkins extends Packet {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.IOException;
|
||||
|
||||
import com.loohp.limbo.World.BlockPosition;
|
||||
|
||||
public class PacketPlayOutSpawnPosition extends Packet {
|
||||
public class PacketPlayOutSpawnPosition extends PacketOut {
|
||||
|
||||
private BlockPosition position;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.IOException;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketPlayOutUpdateViewPosition extends Packet {
|
||||
public class PacketPlayOutUpdateViewPosition extends PacketOut {
|
||||
|
||||
private int chunkX;
|
||||
private int chunkZ;
|
||||
@@ -24,6 +24,7 @@ public class PacketPlayOutUpdateViewPosition extends Packet {
|
||||
return chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.loohp.limbo.Server.Packets;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketStatusInPing extends Packet {
|
||||
public class PacketStatusInPing extends PacketIn {
|
||||
|
||||
private long payload;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.loohp.limbo.Server.Packets;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
|
||||
public class PacketStatusInRequest extends Packet {
|
||||
public class PacketStatusInRequest extends PacketIn {
|
||||
|
||||
public PacketStatusInRequest() {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketStatusOutPong extends Packet {
|
||||
public class PacketStatusOutPong extends PacketOut {
|
||||
|
||||
private long payload;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class PacketStatusOutPong extends Packet {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.loohp.limbo.Utils.DataTypeIO;
|
||||
|
||||
public class PacketStatusOutResponse extends Packet {
|
||||
public class PacketStatusOutResponse extends PacketOut {
|
||||
|
||||
private String json;
|
||||
|
||||
@@ -19,6 +19,7 @@ public class PacketStatusOutResponse extends Packet {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBytes() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user