private void handlePackage(ByteBuffer data) {
        PackageReader pr = new PackageReader(data);

        MainCommands mc = MainCommands.values()[pr.readInt()];
        switch (mc) {
            case CLOSE: {
                ServerClient sc = ServerClient.values()[pr.readInt()];
                if (sc == ServerClient.CLIENT) {
                    //closes connection, removes it from the list and sends it to all the clients
                    close();
                }
                break;
            }
            case PING: {
                ServerClient sc = ServerClient.values()[pr.readInt()];
                switch (sc) {
                    case CLIENT: {

                        long timestamp = pr.readLong();
                        PackageWriter pw = new PackageWriter(this);
                        pw.write(mc.ordinal());
                        pw.write(sc.ordinal());
                        pw.write(timestamp);
                        pw.send();

                        break;
                    }
                    case SERVER: {
                        long timestamp = pr.readLong();
                        long now = new Date().getTime();

                        long difference = now - timestamp;
                        ping = (short) difference;

                        System.out.println(this.uuid + ": Ping: " + ping + " ms.");
                        break;
                    }
                }
                break;
            }
            case CONNECTION:{
                ConnectionCommands cc = ConnectionCommands.values()[pr.readInt()];
                switch(cc){
                    case LIST: {
                        List<Connection> cs = Server.connections;
                        int amount = cs.size();

                        PackageWriter pw = new PackageWriter(this);
                        pw.write(MainCommands.CONNECTION.ordinal());
                        pw.write(ConnectionCommands.LIST.ordinal());
                        pw.write(amount);

                        for(Connection c : cs){
                            pw.write(c);
                        }

                        pw.send();
                        break;
                    }

                }


                break;
            }

        }
    }