public void handlePacket(Packet packet, Server server){
        int i = 0;
        while(i < registered.size()){
            if(registered.get(i).isInstance(packet)){
                handlers.get(i).handle(packet,server);
                return;
            }
            i++;
        }
        throw new RuntimeException("Packet not registered: "+packet);
    }