// Path: core/src/com/laststandstudio/space/engine/Networking/Common/PacketRegistry.java
// public class PacketRegistry {
// 
//     private static HashMap<Integer, Class<? extends Packet>> registeredPackets = new HashMap<>();
//     private static HashMap<Integer, Object> registeredPacketHandlers = new HashMap<>();
// 
// 
//     public static boolean registerPacket(Integer id, Class<? extends Packet> packet, PacketHandler handler) {
//         if (registeredPackets.containsKey(id) || registeredPackets.containsValue(packet) || registeredPacketHandlers.containsKey(id)) {
//             return false;
//         } else {
//             registeredPackets.put(id, packet);
//             registeredPacketHandlers.put(id, handler);
//             return true;
//         }
//     }
// 
//     public static Class<? extends Packet> getPacket(Integer id) {
//         if (registeredPackets.containsKey(id)) {
//             return registeredPackets.get(id);
//         } else {
//             return null;
//         }
//     }
// 
//     public static void submitPacket(Packet packet) {
// 
//         if (registeredPackets.containsKey(packet.getPacketId())) {
//             ((PacketHandler)registeredPacketHandlers.get(packet.getPacketId())).handlePacket(packet);
//         }
//     }
// }


import com.laststandstudio.space.engine.Networking.Common.Packet;
import com.laststandstudio.space.engine.Networking.Common.Packet01Text;
import com.laststandstudio.space.engine.Networking.Common.PacketRegistry;
import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
        if (thread != null) {
            thread.sendPacket(packet);
        }
    }

    private static class ClientThread extends Thread {

        @Override
        public void run() {

            try {

                try {
                    echoSocket = new Socket(serverHostname, 7683);
                    out = new ObjectOutputStream(echoSocket.getOutputStream());
                    in = new ObjectInputStream(echoSocket.getInputStream());
                } catch (UnknownHostException e) {
                    System.err.println("Don't know about host: " + serverHostname);
                } catch (IOException e) {
                    System.err.println("Couldn't get I/O for "
                            + "the connection to: " + serverHostname);
                }

                BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
                String userInput;

                while ((userInput = stdIn.readLine()) != null) {
                    Packet packet = new Packet01Text(userInput);
                    out.writeObject(packet.prepare());
                    Packet newPacket = (Packet) in.readObject();
// Path: core/src/com/laststandstudio/space/engine/Networking/Common/PacketRegistry.java
// public class PacketRegistry {
// 
//     private static HashMap<Integer, Class<? extends Packet>> registeredPackets = new HashMap<>();
//     private static HashMap<Integer, Object> registeredPacketHandlers = new HashMap<>();
// 
// 
//     public static boolean registerPacket(Integer id, Class<? extends Packet> packet, PacketHandler handler) {
//         if (registeredPackets.containsKey(id) || registeredPackets.containsValue(packet) || registeredPacketHandlers.containsKey(id)) {
//             return false;
//         } else {
//             registeredPackets.put(id, packet);
//             registeredPacketHandlers.put(id, handler);
//             return true;
//         }
//     }
// 
//     public static Class<? extends Packet> getPacket(Integer id) {
//         if (registeredPackets.containsKey(id)) {
//             return registeredPackets.get(id);
//         } else {
//             return null;
//         }
//     }
// 
//     public static void submitPacket(Packet packet) {
// 
//         if (registeredPackets.containsKey(packet.getPacketId())) {
//             ((PacketHandler)registeredPacketHandlers.get(packet.getPacketId())).handlePacket(packet);
//         }
//     }
// }


// Path: core/src/com/laststandstudio/space/engine/Networking/Client/Client.java
import com.laststandstudio.space.engine.Networking.Common.Packet;
import com.laststandstudio.space.engine.Networking.Common.Packet01Text;
import com.laststandstudio.space.engine.Networking.Common.PacketRegistry;
import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

        if (thread != null) {
            thread.sendPacket(packet);
        }
    }

    private static class ClientThread extends Thread {

        @Override
        public void run() {

            try {

                try {
                    echoSocket = new Socket(serverHostname, 7683);
                    out = new ObjectOutputStream(echoSocket.getOutputStream());
                    in = new ObjectInputStream(echoSocket.getInputStream());
                } catch (UnknownHostException e) {
                    System.err.println("Don't know about host: " + serverHostname);
                } catch (IOException e) {
                    System.err.println("Couldn't get I/O for "
                            + "the connection to: " + serverHostname);
                }

                BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
                String userInput;

                while ((userInput = stdIn.readLine()) != null) {
                    Packet packet = new Packet01Text(userInput);
                    out.writeObject(packet.prepare());
                    Packet newPacket = (Packet) in.readObject();
                    PacketRegistry.submitPacket(newPacket);